builder-settings-types 0.0.149 → 0.0.151

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 $="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let R=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=$[e[c]&63];return t};function S(c){if(c===null||typeof c!="object")return c;if(c instanceof Date)return new Date(c.getTime());if(Array.isArray(c)){const i=[];for(let s=0;s<c.length;s++)i[s]=S(c[s]);return i}const t={};for(const i in c)Object.prototype.hasOwnProperty.call(c,i)&&(t[i]=S(c[i]));const e=Object.getPrototypeOf(c);return e!==Object.prototype&&Object.setPrototypeOf(t,e),t}function j(c){switch(c){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}class m{constructor(t={}){this.props=t,this.id=t.id||R(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||""}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=S(this.props),i=new t(e);return i.value=S(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const a=document.createElement("div");if(a.className="icon-container",t.icon){const o=this.createIcon(t.icon,t.iconClassName);a.appendChild(o)}if(t.title){const o=this.createLabel(t.title,t.labelClassName);a.appendChild(o)}e.appendChild(a)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||j(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"";const n=a=>{const o=a.target;let l=o.value;switch(t.inputType){case"number":l=Number(o.value);break;case"color":l=o.value;break;case"date":l=o.value;break;case"select":l=o.value;break;case"text":l=o.value;break;case"button":l=o.value;break;default:l=o.value}this.value=l,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}}function T(c,t){for(const e in c)if(c.hasOwnProperty(e)){const i=c[e];t(e,i)}}const x=class x{constructor(t){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastValues={},this.lastChangeTime=0,this.CHANGE_DEBOUNCE=100,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.hasFocus=!1,this.focusTrackingEnabled=!1,this.handleFocus=()=>{},this.blurDebounceTime=100,this.lastBlurTime=0,this.isProcessingBlur=!1,this.isInteracting=!1,this.interactionStartTime=0,this.modifiedSettings=new Set,this.activeSettingId=null,this.hasValueChanged=!1,this.handleInteractionStart=e=>{this.isInteracting||(this.isInteracting=!0,this.interactionStartTime=Date.now(),this.modifiedSettings.clear(),console.log(`[${this.title}] Setting interaction started`))},this.handleChange=e=>{if(e.target instanceof HTMLElement){this.hasValueChanged=!0;const i=e.target.closest("[data-setting-id]");if(i){const s=i.getAttribute("data-setting-id");typeof s=="string"&&(this.activeSettingId=s)}}},typeof t.id=="string"&&t.id.trim()!==""?this.id=t.id.trim():this.id=R(),typeof t.title=="string"?this.title=t.title:(this.title="Untitled Setting Group",console.warn(`SettingGroup constructor: Invalid title provided, defaulting to '${this.title}'.`,t)),this.settings=t.settings,typeof t.description=="string"?this.description=t.description:t.description===null||t.description===void 0?this.description=void 0:(this.description=String(t.description),console.warn("SettingGroup constructor: Invalid description type, coercing to string.",t)),this.icon=t.icon,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.hideCondition=t.hideCondition,this.onBlur=t.onBlur,this.blurDebounceTime=t.blurDebounceTime??100,Object.assign(this,t.settings),this.initialValues=this.getValues()}static hide(){this.hiddenElements.forEach(t=>{t&&(t.style.display="none")})}static show(){this.hiddenElements.forEach(t=>{t&&(t.style.display="")})}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.hasValueChanged=!0,this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),T(this.settings,(i,s)=>{var n;if(s instanceof x)s.setOnChange(a=>{this.hasValueChanged=!0;const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(s instanceof m){const a=()=>{this.hasValueChanged=!0,e()};this.changeHandlers.add(a),s.setOnChange(a)}else{const a=()=>{this.hasValueChanged=!0,e()};this.changeHandlers.add(a),(n=s.setOnChange)==null||n.call(s,a)}}),this}setOnBlur(t,e){return this.onBlur=t,this.pendingBlurHandler=t,this.focusTrackingEnabled=!0,e!==void 0&&(this.blurDebounceTime=e),this.handleBlur=i=>{if(!this.hasValueChanged&&!i)return;let n=null;if((i==null?void 0:i.target)instanceof HTMLElement){const a=i.target.closest("[data-setting-id]");if(a){const o=a.getAttribute("data-setting-id");typeof o=="string"&&(n=o)}}this.blurTimeout&&clearTimeout(this.blurTimeout),this.blurTimeout=setTimeout(()=>{try{this.saveChangesImmediately();const a=this.getValues();(this.activeSettingId===null&&n!==null||n===null&&this.activeSettingId!==null||this.activeSettingId!==n||this.hasValueChanged)&&this.onBlur&&(this.onBlur(a||{}),this.hasValueChanged=!1),this.activeSettingId=n}catch(a){console.error("Error in blur handler:",a),this.hasValueChanged=!1,this.activeSettingId=null}},this.blurDebounceTime)},this.elementRef&&this.setupFocusHandlers(),this}hasFocusWithin(){if(!this.elementRef)return!1;const t=document.activeElement;return this.elementRef.contains(t)||this.hasFocus}setupFocusHandlers(){if(!this.elementRef||!this.focusTrackingEnabled)return;this.elementRef.removeEventListener("focusout",this.handleBlur),this.elementRef.removeEventListener("change",this.handleChange),this.elementRef.removeEventListener("input",this.handleChange),this.elementRef.addEventListener("focusout",this.handleBlur),this.elementRef.addEventListener("change",this.handleChange),this.elementRef.addEventListener("input",this.handleChange);const t=this.elementRef.closest("form");t&&(t.removeEventListener("submit",this.handleBlur),t.addEventListener("submit",this.handleBlur)),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.elementRef&&document.activeElement&&this.elementRef.contains(document.activeElement)&&this.handleBlur()})}cleanup(){if(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.elementRef.removeEventListener("change",this.handleChange),this.elementRef.removeEventListener("input",this.handleChange);const t=this.elementRef.closest("form");t&&t.removeEventListener("submit",this.handleBlur)}document.removeEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.elementRef&&document.activeElement&&this.elementRef.contains(document.activeElement)&&this.handleBlur()}),T(this.settings,(t,e)=>{typeof e.cleanup=="function"&&e.cleanup()}),this.changeHandlers.clear(),this.activeSettingId=null,this.hasValueChanged=!1}clone(){const t={};T(this.settings,(n,a)=>{typeof a.clone=="function"?t[n]=a.clone():(console.warn(`Setting with key '${n}' does not have a clone method. Copying reference.`),t[n]=a)});const e={title:this.title,settings:t,description:this.description,icon:this.icon,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,hideCondition:this.hideCondition},i=this.constructor,s=new i(e);return s.initialValues=this.getValues(),s}calculateChanges(t,e){const i={};return new Set([...Object.keys(t),...Object.keys(e)]).forEach(n=>{const a=t[n],o=e[n];JSON.stringify(a)!==JSON.stringify(o)&&(i[n]={from:a,to:o})}),i}hide(){this.elementRef&&(this.elementRef.style.display="none",this.isHidden=!0)}show(){this.elementRef&&(this.elementRef.style.display="",this.isHidden=!1)}getValues(t){try{if(t===void 0){const e={};for(const i in this.settings)if(this.settings.hasOwnProperty(i)){const s=this.settings[i];if(!s)continue;s instanceof x?e[i]=s.getValues():typeof s.value<"u"&&(e[i]=s.value)}return e}else{const e=this.settings[t];return e?(this.isInteracting&&typeof t=="string"&&this.modifiedSettings.add(t),e instanceof x?e.getValues():typeof e.value<"u"?e.value:void 0):void 0}}catch(e){return console.error("Error in getValues:",e),{}}}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,x.hiddenElements.add(t),this.hideCondition&&this.hideCondition()&&(t.style.display="none"),this.isMain&&t.classList.add("main-group");const e=document.createElement("div");e.className="setting-group-title",this.isCollapsed&&e.classList.add("collapsed-view"),e.setAttribute("role","button"),e.setAttribute("aria-expanded",(!this.isCollapsed).toString()),e.setAttribute("tabindex","0");const i=document.createElement("div");if(i.className="title-section",this.icon){const r=document.createElement("span");r.className="group-icon",r.innerHTML=this.icon,i.appendChild(r)}this.custom&&t.classList.add("custom_class");const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");if(n.className="actions-section",this.description&&this.isCollapsed){const r=document.createElement("span");r.className="info-marker",r.innerHTML=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let R=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=$[e[c]&63];return t};function M(c){if(c===null||typeof c!="object")return c;if(c instanceof Date)return new Date(c.getTime());if(Array.isArray(c)){const i=[];for(let s=0;s<c.length;s++)i[s]=M(c[s]);return i}const t={};for(const i in c)Object.prototype.hasOwnProperty.call(c,i)&&(t[i]=M(c[i]));const e=Object.getPrototypeOf(c);return e!==Object.prototype&&Object.setPrototypeOf(t,e),t}function j(c){switch(c){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}class m{constructor(t={}){this.props=t,this.id=t.id||R(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||""}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=M(this.props),i=new t(e);return i.value=M(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const a=document.createElement("div");if(a.className="icon-container",t.icon){const o=this.createIcon(t.icon,t.iconClassName);a.appendChild(o)}if(t.title){const o=this.createLabel(t.title,t.labelClassName);a.appendChild(o)}e.appendChild(a)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||j(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"";const n=a=>{const o=a.target;let l=o.value;switch(t.inputType){case"number":l=Number(o.value);break;case"color":l=o.value;break;case"date":l=o.value;break;case"select":l=o.value;break;case"text":l=o.value;break;case"button":l=o.value;break;default:l=o.value}this.value=l,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}}function T(c,t){for(const e in c)if(c.hasOwnProperty(e)){const i=c[e];t(e,i)}}const w=class w{constructor(t){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastValues={},this.lastChangeTime=0,this.CHANGE_DEBOUNCE=100,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.id=t.id||R(),this.title=t.title,this.settings=t.settings,this.description=t.description,this.icon=t.icon,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.hideCondition=t.hideCondition,this.onBlur=t.onBlur,Object.assign(this,t.settings),this.initialValues=this.getValues()}static hide(){this.hiddenElements.forEach(t=>{t&&(t.style.display="none")})}static show(){this.hiddenElements.forEach(t=>{t&&(t.style.display="")})}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),T(this.settings,(i,s)=>{var n;if(s instanceof w)s.setOnChange(a=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(s instanceof m){const a=()=>{e()};this.changeHandlers.add(a),s.setOnChange(a)}else{const a=()=>{e()};this.changeHandlers.add(a),(n=s.setOnChange)==null||n.call(s,a)}}),this}setOnBlur(t){return this.onBlur=t,this.pendingBlurHandler=t,this.handleBlur=e=>{(e==null?void 0:e.target)instanceof HTMLElement&&e.target.closest(".setting-group")!==this.elementRef||(this.blurTimeout&&clearTimeout(this.blurTimeout),this.blurTimeout=setTimeout(()=>{t()},100))},this.elementRef&&this.setupBlurHandlers(),this}setupBlurHandlers(){this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.elementRef&&this.elementRef.addEventListener("focusout",this.handleBlur,!0),T(this.settings,(t,e)=>{var i;if(e instanceof w)e.setOnBlur(this.handleBlur);else{const s=(i=this.elementRef)==null?void 0:i.querySelector(`[data-setting-id="${e.id}"]`);s&&s.addEventListener("focusout",this.handleBlur,!0)}})}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()}clone(){const t={};T(this.settings,(n,a)=>{typeof a.clone=="function"?t[n]=a.clone():(console.warn(`Setting with key '${n}' does not have a clone method. Copying reference.`),t[n]=a)});const e={title:this.title,settings:t,description:this.description,icon:this.icon,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,hideCondition:this.hideCondition},i=this.constructor,s=new i(e);return s.initialValues=this.getValues(),s}calculateChanges(t,e){const i={};return new Set([...Object.keys(t),...Object.keys(e)]).forEach(n=>{const a=t[n],o=e[n];JSON.stringify(a)!==JSON.stringify(o)&&(i[n]={from:a,to:o})}),i}hide(){this.elementRef&&(this.elementRef.style.display="none",this.isHidden=!0)}show(){this.elementRef&&(this.elementRef.style.display="",this.isHidden=!1)}getValues(t){if(t===void 0){const e={};for(const i in this.settings)if(this.settings.hasOwnProperty(i)){const s=this.settings[i];s instanceof w?e[i]=s.getValues():e[i]=s.value}return e}else{const e=this.settings[t];return e?e instanceof w?e.getValues():e.value:void 0}}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,w.hiddenElements.add(t),this.hideCondition&&this.hideCondition()&&(t.style.display="none"),this.isMain&&t.classList.add("main-group");const e=document.createElement("div");e.className="setting-group-title",this.isCollapsed&&e.classList.add("collapsed-view"),e.setAttribute("role","button"),e.setAttribute("aria-expanded",(!this.isCollapsed).toString()),e.setAttribute("tabindex","0");const i=document.createElement("div");if(i.className="title-section",this.icon){const r=document.createElement("span");r.className="group-icon",r.innerHTML=this.icon,i.appendChild(r)}this.custom&&t.classList.add("custom_class");const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");if(n.className="actions-section",this.description&&this.isCollapsed){const r=document.createElement("span");r.className="info-marker",r.innerHTML=`
2
2
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
3
3
  <path d="M8 5.33333V8M8 10.6667H8.00667M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z"
4
4
  stroke="currentColor" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
@@ -12,7 +12,7 @@
12
12
  <path d="M8 5.33333V8M8 10.6667H8.00667M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z"
13
13
  stroke="currentColor" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
14
14
  </svg>
15
- `,d.title=this.description,n.insertBefore(d,a)}}else{if(!r){const d=document.createElement("div");d.className="setting-group-description",d.textContent=this.description,o.insertBefore(d,o.firstChild)}u&&u.remove()}};if(e.onclick=l,e.onkeydown=r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),l())},Object.keys(this.settings).length>0){for(const r in this.settings)if(this.settings.hasOwnProperty(r)){const u=this.settings[r];o.appendChild(u.draw())}}else{const r=document.createElement("div");r.className="setting-group-empty",r.textContent="No settings in this group",o.appendChild(r)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(o),this.elementRef=t,this.pendingBlurHandler&&(this.setupFocusHandlers(),this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}updateVisibility(){this.elementRef&&this.hideCondition&&(this.elementRef.style.display=this.hideCondition()?"none":"")}toggle(){this.isHidden?this.show():this.hide()}saveChangesImmediately(){if(!this.onChange)return;this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null);const t=this.getValues(),e=this.calculateChanges(this.initialValues,t);Object.keys(e).length>0&&(this.initialValues=t,this.onChange(t),this.updateVisibility())}};x.hiddenElements=new Set;let f=x;class M extends m{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}draw(){const t=e=>{this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t})}}const B="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";class H extends M{constructor(t){super({...t,icon:t.icon||B,title:t.title||"Color"}),this.inputType="color",this.detectChange=t.detectChange}hexToRgb(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}rgbToHex(t){const[e,i,s]=t.split(",").map(a=>parseInt(a.trim()));if(isNaN(e)||isNaN(i)||isNaN(s))return"#000000";const n=a=>{const o=a.toString(16);return o.length===1?"0"+o:o};return`#${n(e)}${n(i)}${n(s)}`}draw(){const t=document.createElement("div");t.className="color-setting-wrapper";const e=document.createElement("div");e.className="icon-container";const i=this.createIcon(this.props.icon||B),s=this.createLabel(this.title||"Color");e.appendChild(i),e.appendChild(s);const n=document.createElement("div");n.className="color-input-wrapper";const a=d=>{const g=d.value.split(",").map(I=>parseInt(I.trim()));if(g.length!==3||g.some(isNaN))return d.style.border="1px solid red",!1;const[p,C,v]=g,y=p>=0&&p<=255&&C>=0&&C<=255&&v>=0&&v<=255;return d.style.border=y?"":"1px solid red",y},o=document.createElement("div");o.className="color-preview",o.style.backgroundColor=this.value?`rgb(${this.value})`:"";const l=this.createInput({value:this.value,inputType:"text",inputClassName:"color-text-input"}),h=l.querySelector("input");h.readOnly=!0;const r=this.createInput({value:this.value?this.rgbToHex(this.value):"",inputType:this.inputType,inputClassName:"color-picker"}),u=r.querySelector("input");return h.oninput=d=>{var p;let g=d.target.value.trim();a(h)&&(this.value=g,(p=this.onChange)==null||p.call(this,g),u.value=this.rgbToHex(g),o.style.backgroundColor=`rgb(${g})`)},u.oninput=d=>{var C,v;const g=d.target.value,p=this.hexToRgb(g);this.value=p,(C=this.onChange)==null||C.call(this,p),(v=this.detectChange)==null||v.call(this,p),h.value=p,o.style.backgroundColor=`rgb(${p})`},u.onchange=d=>{var C,v;const g=d.target.value,p=this.hexToRgb(g);this.value=p,(C=this.onChange)==null||C.call(this,p),(v=this.detectChange)==null||v.call(this,p),h.value=p,o.style.backgroundColor=`rgb(${p})`},n.appendChild(o),n.appendChild(r),n.appendChild(l),t.appendChild(e),t.appendChild(n),this.value&&(h.value=this.value,u.value=this.rgbToHex(this.value),o.style.backgroundColor=`rgb(${this.value})`),t}}class b extends m{constructor(t){super(t),this.inputType="number",this.inputElement=null,this.mobileValue=t.mobile,this.validateProps(),this.value=this.validateValue(this.value)}draw(){const t=s=>{this.props.minValue!==void 0&&(s.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(s.max=String(this.props.maxValue)),this.props.className&&s.classList.add(this.props.className),s.addEventListener("input",()=>{const n=this.props.minValue??Number.MIN_SAFE_INTEGER,a=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(s.value);o<n&&(o=n),o>a&&(o=a),String(o)!==s.value&&(s.value=String(o)),this.setValue(o)}),s.addEventListener("blur",()=>{var a,o;const n=this.validateValue(Number(s.value));n!==Number(s.value)&&(s.value=String(n),this.setValue(n)),(o=(a=this.props).onBlur)==null||o.call(a)})},e=this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,icon:this.props.icon,inputClassName:"number-setting-input "+(this.props.inputClassName||""),wrapperClassName:"number-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t});if(this.inputElement=e.querySelector("input.number-setting-input"),!this.props.suffix||this.props.suffix==="none")return e;e.classList.add("suffix-wrapper"),this.inputElement&&(this.inputElement.style.paddingRight="35px");const i=document.createElement("span");return i.className="suffix-label",i.textContent=this.props.suffix,e.appendChild(i),e}setValue(t){const e=this.validateValue(t);super.setValue(e),this.inputElement&&this.inputElement.value!==String(e)&&(this.inputElement.value=String(e??""))}validateValue(t){(t==null||isNaN(t))&&(t=this.props.default??0);const e=this.props.minValue??Number.MIN_SAFE_INTEGER,i=this.props.maxValue??Number.MAX_SAFE_INTEGER;let s=Number(t);return s<e&&(s=e),s>i&&(s=i),s}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t}validateProps(){this.props.minValue!==void 0&&(this.props.default??0)<this.props.minValue&&console.warn(`Default value ${this.props.default} is less than minValue ${this.props.minValue}`),this.props.maxValue!==void 0&&(this.props.default??0)>this.props.maxValue&&console.warn(`Default value ${this.props.default} is greater than maxValue ${this.props.maxValue}`)}}const W=`
15
+ `,d.title=this.description,n.insertBefore(d,a)}}else{if(!r){const d=document.createElement("div");d.className="setting-group-description",d.textContent=this.description,o.insertBefore(d,o.firstChild)}u&&u.remove()}};if(e.onclick=l,e.onkeydown=r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),l())},Object.keys(this.settings).length>0){for(const r in this.settings)if(this.settings.hasOwnProperty(r)){const u=this.settings[r];o.appendChild(u.draw())}}else{const r=document.createElement("div");r.className="setting-group-empty",r.textContent="No settings in this group",o.appendChild(r)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(o),this.elementRef=t,this.pendingBlurHandler&&(this.setupBlurHandlers(),this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}updateVisibility(){this.elementRef&&this.hideCondition&&(this.elementRef.style.display=this.hideCondition()?"none":"")}toggle(){this.isHidden?this.show():this.hide()}};w.hiddenElements=new Set;let f=w;class S extends m{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}draw(){const t=e=>{this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t})}}const B="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";class H extends S{constructor(t){super({...t,icon:t.icon||B,title:t.title||"Color"}),this.inputType="color",this.element=null,this.detectChange=t.detectChange}hexToRgb(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}rgbToHex(t){const[e,i,s]=t.split(",").map(a=>parseInt(a.trim()));if(isNaN(e)||isNaN(i)||isNaN(s))return"#000000";const n=a=>{const o=a.toString(16);return o.length===1?"0"+o:o};return`#${n(e)}${n(i)}${n(s)}`}draw(){const t=document.createElement("div");t.className="color-setting-wrapper",this.element=t;const e=document.createElement("div");e.className="icon-container";const i=this.createIcon(this.props.icon||B),s=this.createLabel(this.title||"Color");e.appendChild(i),e.appendChild(s);const n=document.createElement("div");n.className="color-input-wrapper";const a=d=>{const g=d.value.split(",").map(I=>parseInt(I.trim()));if(g.length!==3||g.some(isNaN))return d.style.border="1px solid red",!1;const[p,C,v]=g,y=p>=0&&p<=255&&C>=0&&C<=255&&v>=0&&v<=255;return d.style.border=y?"":"1px solid red",y},o=document.createElement("div");o.className="color-preview",o.style.backgroundColor=this.value?`rgb(${this.value})`:"";const l=this.createInput({value:this.value,inputType:"text",inputClassName:"color-text-input"}),h=l.querySelector("input");h.readOnly=!0;const r=this.createInput({value:this.value?this.rgbToHex(this.value):"",inputType:this.inputType,inputClassName:"color-picker"}),u=r.querySelector("input");return h.oninput=d=>{var p;let g=d.target.value.trim();a(h)&&(this.value=g,(p=this.onChange)==null||p.call(this,g),u.value=this.rgbToHex(g),o.style.backgroundColor=`rgb(${g})`)},u.oninput=d=>{var C,v;const g=d.target.value,p=this.hexToRgb(g);this.value=p,(C=this.onChange)==null||C.call(this,p),(v=this.detectChange)==null||v.call(this,p),h.value=p,o.style.backgroundColor=`rgb(${p})`},u.onchange=d=>{var C,v;const g=d.target.value,p=this.hexToRgb(g);this.value=p,(C=this.onChange)==null||C.call(this,p),(v=this.detectChange)==null||v.call(this,p),h.value=p,o.style.backgroundColor=`rgb(${p})`},n.appendChild(o),n.appendChild(r),n.appendChild(l),t.appendChild(e),t.appendChild(n),this.value&&(h.value=this.value,u.value=this.rgbToHex(this.value),o.style.backgroundColor=`rgb(${this.value})`),t}getElement(){return this.element}}class b extends m{constructor(t){super(t),this.inputType="number",this.inputElement=null,this.mobileValue=t.mobile,this.validateProps(),this.value=this.validateValue(this.value)}draw(){const t=s=>{this.props.minValue!==void 0&&(s.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(s.max=String(this.props.maxValue)),this.props.className&&s.classList.add(this.props.className),s.addEventListener("input",()=>{const n=this.props.minValue??Number.MIN_SAFE_INTEGER,a=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(s.value);o<n&&(o=n),o>a&&(o=a),String(o)!==s.value&&(s.value=String(o)),this.setValue(o)}),s.addEventListener("blur",()=>{var a,o;const n=this.validateValue(Number(s.value));n!==Number(s.value)&&(s.value=String(n),this.setValue(n)),(o=(a=this.props).onBlur)==null||o.call(a)})},e=this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,icon:this.props.icon,inputClassName:"number-setting-input "+(this.props.inputClassName||""),wrapperClassName:"number-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t});if(this.inputElement=e.querySelector("input.number-setting-input"),!this.props.suffix||this.props.suffix==="none")return e;e.classList.add("suffix-wrapper"),this.inputElement&&(this.inputElement.style.paddingRight="35px");const i=document.createElement("span");return i.className="suffix-label",i.textContent=this.props.suffix,e.appendChild(i),e}setValue(t){const e=this.validateValue(t);super.setValue(e),this.inputElement&&this.inputElement.value!==String(e)&&(this.inputElement.value=String(e??""))}validateValue(t){(t==null||isNaN(t))&&(t=this.props.default??0);const e=this.props.minValue??Number.MIN_SAFE_INTEGER,i=this.props.maxValue??Number.MAX_SAFE_INTEGER;let s=Number(t);return s<e&&(s=e),s>i&&(s=i),s}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t}validateProps(){this.props.minValue!==void 0&&(this.props.default??0)<this.props.minValue&&console.warn(`Default value ${this.props.default} is less than minValue ${this.props.minValue}`),this.props.maxValue!==void 0&&(this.props.default??0)>this.props.maxValue&&console.warn(`Default value ${this.props.default} is greater than maxValue ${this.props.maxValue}`)}}const W=`
16
16
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
17
17
  <path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
18
18
  <path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
@@ -41,13 +41,13 @@
41
41
  <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"
42
42
  stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
43
43
  </svg>
44
- `}].forEach(n=>{const a=document.createElement("button");a.className="align-option-button",a.innerHTML=n.icon,this.value===n.name&&a.classList.add("selected"),a.addEventListener("click",()=>{var o;i.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),a.classList.add("selected"),this.value=n.name,(o=this.onChange)==null||o.call(this,this.value)}),i.appendChild(a)}),t.appendChild(i),t}}class D extends m{constructor(t){super(t),this.inputType="button"}draw(){const t=document.createElement("button");t.className="button-setting "+(this.props.className||""),t.textContent=this.props.label,t.addEventListener("click",()=>{this.props.onClick&&this.props.onClick()});const e=document.createElement("div");return e.className="button-setting-wrapper "+(this.props.wrapperClassName||""),e.appendChild(t),e}}class F extends m{constructor(t={}){super(t),this.inputType={width:"number",height:"number"},this.aspectRatio=1,this.isUpdating=!1;const e=t.width||0,i=t.height||0;this.value||(this.value={width:e,height:i}),this.minWidth=t.minWidth??0,this.maxWidth=t.maxWidth,this.minHeight=t.minHeight??0,this.maxHeight=t.maxHeight,this.locked=t.locked??!1,this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.widthSetting=new b({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:q}),this.heightSetting=new b({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:U}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(t){if(!this.isUpdating&&!isNaN(t)){this.maxWidth&&t>this.maxWidth&&(t=this.maxWidth),this.isUpdating=!0;try{let e=t,i=this.value.height;this.locked&&this.aspectRatio>0&&(i=Math.round(e/this.aspectRatio),this.maxHeight&&i>this.maxHeight&&(i=this.maxHeight,e=Math.round(i*this.aspectRatio),this.maxWidth&&e>this.maxWidth&&(e=this.maxWidth,i>0&&(this.aspectRatio=e/i)))),this.value={width:e,height:i},this.widthSetting.setValue(e),this.locked&&this.heightSetting.setValue(i),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}handleHeightChange(t){if(!this.isUpdating&&!isNaN(t)){this.maxHeight&&t>this.maxHeight&&(t=this.maxHeight),this.isUpdating=!0;try{let e=t,i=this.value.width;this.locked&&this.aspectRatio>0&&(i=Math.round(e*this.aspectRatio),this.maxWidth&&i>this.maxWidth&&(i=this.maxWidth,e=Math.round(i/this.aspectRatio),this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight,e>0&&(this.aspectRatio=i/e)))),this.value={width:i,height:e},this.locked&&this.widthSetting.setValue(i),this.heightSetting.setValue(e),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}toggleLock(t){if(this.locked=!this.locked,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}t.innerHTML=this.getLockSVG(this.locked),t.setAttribute("aria-pressed",String(this.locked)),t.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const e=t.closest(".dimension-setting-container");e&&(this.locked?e.classList.add("aspect-locked"):e.classList.remove("aspect-locked"))}getLockSVG(t){return t?`
44
+ `}].forEach(n=>{const a=document.createElement("button");a.className="align-option-button",a.innerHTML=n.icon,this.value===n.name&&a.classList.add("selected"),a.addEventListener("click",()=>{var o;i.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),a.classList.add("selected"),this.value=n.name,(o=this.onChange)==null||o.call(this,this.value)}),i.appendChild(a)}),t.appendChild(i),t}}class q extends m{constructor(t){super(t),this.inputType="button"}draw(){const t=document.createElement("button");t.className="button-setting "+(this.props.className||""),t.textContent=this.props.label,t.addEventListener("click",()=>{this.props.onClick&&this.props.onClick()});const e=document.createElement("div");return e.className="button-setting-wrapper "+(this.props.wrapperClassName||""),e.appendChild(t),e}}class D extends m{constructor(t={}){super(t),this.inputType={width:"number",height:"number"},this.aspectRatio=1,this.isUpdating=!1;const e=t.width||0,i=t.height||0;this.value||(this.value={width:e,height:i}),this.minWidth=t.minWidth??0,this.maxWidth=t.maxWidth,this.minHeight=t.minHeight??0,this.maxHeight=t.maxHeight,this.locked=t.locked??!1,this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.widthSetting=new b({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:F}),this.heightSetting=new b({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:U}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(t){if(!this.isUpdating&&!isNaN(t)){this.maxWidth&&t>this.maxWidth&&(t=this.maxWidth),this.isUpdating=!0;try{let e=t,i=this.value.height;this.locked&&this.aspectRatio>0&&(i=Math.round(e/this.aspectRatio),this.maxHeight&&i>this.maxHeight&&(i=this.maxHeight,e=Math.round(i*this.aspectRatio),this.maxWidth&&e>this.maxWidth&&(e=this.maxWidth,i>0&&(this.aspectRatio=e/i)))),this.value={width:e,height:i},this.widthSetting.setValue(e),this.locked&&this.heightSetting.setValue(i),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}handleHeightChange(t){if(!this.isUpdating&&!isNaN(t)){this.maxHeight&&t>this.maxHeight&&(t=this.maxHeight),this.isUpdating=!0;try{let e=t,i=this.value.width;this.locked&&this.aspectRatio>0&&(i=Math.round(e*this.aspectRatio),this.maxWidth&&i>this.maxWidth&&(i=this.maxWidth,e=Math.round(i/this.aspectRatio),this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight,e>0&&(this.aspectRatio=i/e)))),this.value={width:i,height:e},this.locked&&this.widthSetting.setValue(i),this.heightSetting.setValue(e),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}toggleLock(t){if(this.locked=!this.locked,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}t.innerHTML=this.getLockSVG(this.locked),t.setAttribute("aria-pressed",String(this.locked)),t.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const e=t.closest(".dimension-setting-container");e&&(this.locked?e.classList.add("aspect-locked"):e.classList.remove("aspect-locked"))}getLockSVG(t){return t?`
45
45
  <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
46
46
  <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" stroke-linecap="round" stroke-linejoin="round"/>
47
47
  </svg>`:`
48
48
  <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
49
49
  <path d="M2.91663 4.58333V3.33333C2.91663 2.18274 3.84937 1.25 4.99996 1.25M3.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" stroke-linecap="round" stroke-linejoin="round"/>
50
- </svg>`}setValue(t){if(t&&typeof t.width=="number"&&typeof t.height=="number"){let e=Math.max(this.minWidth,t.width);this.maxWidth&&(e=Math.min(this.maxWidth,e));let i=Math.max(this.minHeight,t.height);this.maxHeight&&(i=Math.min(this.maxHeight,i)),this.value={width:e,height:i},this.locked&&this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.isUpdating=!0;try{this.widthSetting.setValue(this.value.width),this.heightSetting.setValue(this.value.height)}finally{this.isUpdating=!1}}}draw(){const t=document.createElement("div");t.className="dimension-setting-container",this.locked&&t.classList.add("aspect-locked");const e=this.widthSetting.draw(),i=this.heightSetting.draw(),s=document.createElement("div");s.className="dimension-bracket";const n=document.createElement("button");return n.className="dimension-lock-icon",n.setAttribute("type","button"),n.setAttribute("aria-pressed",String(this.locked)),n.setAttribute("aria-label",this.locked?"Unlock aspect ratio":"Lock aspect ratio"),n.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio",n.innerHTML=this.getLockSVG(this.locked),n.onclick=a=>{a.preventDefault(),this.toggleLock(n)},s.appendChild(n),t.appendChild(e),t.appendChild(s),t.appendChild(i),t}isLocked(){return this.locked}setLocked(t){if(this.locked!==t){if(this.locked=t,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}const e=document.querySelector(".dimension-setting-container .dimension-lock-icon");if(e instanceof HTMLElement){e.innerHTML=this.getLockSVG(this.locked),e.setAttribute("aria-pressed",String(this.locked)),e.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const i=e.closest(".dimension-setting-container");i&&(this.locked?i.classList.add("aspect-locked"):i.classList.remove("aspect-locked"))}}}}const q=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
50
+ </svg>`}setValue(t){if(t&&typeof t.width=="number"&&typeof t.height=="number"){let e=Math.max(this.minWidth,t.width);this.maxWidth&&(e=Math.min(this.maxWidth,e));let i=Math.max(this.minHeight,t.height);this.maxHeight&&(i=Math.min(this.maxHeight,i)),this.value={width:e,height:i},this.locked&&this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.isUpdating=!0;try{this.widthSetting.setValue(this.value.width),this.heightSetting.setValue(this.value.height)}finally{this.isUpdating=!1}}}draw(){const t=document.createElement("div");t.className="dimension-setting-container",this.locked&&t.classList.add("aspect-locked");const e=this.widthSetting.draw(),i=this.heightSetting.draw(),s=document.createElement("div");s.className="dimension-bracket";const n=document.createElement("button");return n.className="dimension-lock-icon",n.setAttribute("type","button"),n.setAttribute("aria-pressed",String(this.locked)),n.setAttribute("aria-label",this.locked?"Unlock aspect ratio":"Lock aspect ratio"),n.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio",n.innerHTML=this.getLockSVG(this.locked),n.onclick=a=>{a.preventDefault(),this.toggleLock(n)},s.appendChild(n),t.appendChild(e),t.appendChild(s),t.appendChild(i),t}isLocked(){return this.locked}setLocked(t){if(this.locked!==t){if(this.locked=t,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}const e=document.querySelector(".dimension-setting-container .dimension-lock-icon");if(e instanceof HTMLElement){e.innerHTML=this.getLockSVG(this.locked),e.setAttribute("aria-pressed",String(this.locked)),e.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const i=e.closest(".dimension-setting-container");i&&(this.locked?i.classList.add("aspect-locked"):i.classList.remove("aspect-locked"))}}}}const F=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
51
51
  <path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
52
52
  </svg>`,U=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
53
53
  <path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
@@ -73,7 +73,7 @@
73
73
  `))}draw(){const t=document.createElement("div");t.className="upload-setting-wrapper",t.setAttribute("data-setting-id",this.id),t.addEventListener("focusout",l=>{var h;l.relatedTarget&&t.contains(l.relatedTarget)||(h=this.onBlur)==null||h.call(this)},!0);const e=!!(this.props.title||this.props.icon);if(e||t.classList.add("no-label"),e){const l=document.createElement("div");if(l.className="icon-title-container",this.props.icon){const h=this.createIcon(this.props.icon);l.appendChild(h)}if(this.props.title){const h=this.createLabel(this.props.title);l.appendChild(h)}t.appendChild(l)}const i=document.createElement("div");i.className="preview-button-container";const s=this.value&&this.value!=="";s||i.classList.add("no-image");const n=document.createElement("div");if(n.className="preview-placeholder",n.innerHTML=z,this.previewWrapper=document.createElement("div"),this.previewWrapper.className="preview-wrapper",this.previewEl=document.createElement("img"),this.previewEl.className="upload-preview",this.props.delete){const l=document.createElement("button");l.className="delete-button",l.type="button",l.title="Delete image",l.innerHTML=P,this.previewWrapper.appendChild(l),l.onclick=h=>{var r;h.stopPropagation(),this.value="",o.value="",this.updatePreviewState(null),(r=this.onChange)==null||r.call(this,"")}}this.previewWrapper.appendChild(this.previewEl);const a=document.createElement("button");a.className="upload-button",a.innerHTML=`
74
74
  <span class="upload-icon">${O}</span>
75
75
  <span class="upload-label">Upload</span>
76
- `;const o=document.createElement("input");return o.type="file",o.accept="image/*",o.style.display="none",i.appendChild(n),i.appendChild(this.previewWrapper),i.appendChild(a),t.appendChild(i),t.appendChild(o),s?this.updatePreviewState(this.value):this.updatePreviewState(null),a.onclick=()=>{o.click()},o.onchange=async()=>{var h,r,u,d;const l=(h=o.files)==null?void 0:h[0];if(l)try{a.classList.add("loading"),a.disabled=!0;const g=new FormData,p=this.props.formFieldName||"file";g.append(p,l,l.name);const C=this.props.uploadUrl;if(!C)throw new Error("No uploadUrl provided to UploadSetting.");const v=this.props.requestMethod||"POST",y={...this.props.requestHeaders||{}},k=await(await fetch(C,{method:v,body:g,headers:y})).json();console.log("Upload response:",k);let w;if(this.props.parseResponse)w=this.props.parseResponse(k);else if(w=(r=k==null?void 0:k.data)==null?void 0:r.url,!w)throw new Error("No URL found in response. Provide a parseResponse if needed.");console.log("Final URL:",w),this.value=w,this.updatePreviewState(w),(u=this.onChange)==null||u.call(this,w),(d=this.onBlur)==null||d.call(this)}catch(g){console.error("Error uploading file:",g)}finally{a.classList.remove("loading"),a.disabled=!1,o.value=""}else o.value=""},t}}class Z extends b{constructor(t={}){const e={title:t.title||"Height",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||J,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}}const J=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
76
+ `;const o=document.createElement("input");return o.type="file",o.accept="image/*",o.style.display="none",i.appendChild(n),i.appendChild(this.previewWrapper),i.appendChild(a),t.appendChild(i),t.appendChild(o),s?this.updatePreviewState(this.value):this.updatePreviewState(null),a.onclick=()=>{o.click()},o.onchange=async()=>{var h,r,u,d;const l=(h=o.files)==null?void 0:h[0];if(l)try{a.classList.add("loading"),a.disabled=!0;const g=new FormData,p=this.props.formFieldName||"file";g.append(p,l,l.name);const C=this.props.uploadUrl;if(!C)throw new Error("No uploadUrl provided to UploadSetting.");const v=this.props.requestMethod||"POST",y={...this.props.requestHeaders||{}},k=await(await fetch(C,{method:v,body:g,headers:y})).json();console.log("Upload response:",k);let x;if(this.props.parseResponse)x=this.props.parseResponse(k);else if(x=(r=k==null?void 0:k.data)==null?void 0:r.url,!x)throw new Error("No URL found in response. Provide a parseResponse if needed.");console.log("Final URL:",x),this.value=x,this.updatePreviewState(x),(u=this.onChange)==null||u.call(this,x),(d=this.onBlur)==null||d.call(this)}catch(g){console.error("Error uploading file:",g)}finally{a.classList.remove("loading"),a.disabled=!1,o.value=""}else o.value=""},t}}class Z extends b{constructor(t={}){const e={title:t.title||"Height",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||J,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}}const J=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
77
77
  <path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
78
78
  </svg>`;class X extends b{constructor(t={}){const e={title:t.title||"Width",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||Q,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}}const Q=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
79
79
  <path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
@@ -137,7 +137,7 @@
137
137
  <path d="M2.25 2.75H2.2575M2.25 9.5H2.2575M2.25 12.875H2.2575M2.25 6.125H2.2575M5.625 2.75H5.6325M5.625 9.5H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
138
138
  </svg>`,ft=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
139
139
  <path d="M5.625 2.75H5.6325M5.625 9.5H5.6325M5.625 16.25H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M12.375 16.25H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 16.25H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 16.25H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
140
- </svg>`;class Ct extends f{constructor(t,e,i){super({title:`Tab ${t+1}`,hideCondition:i==null?void 0:i.hideCondition,collapsed:i==null?void 0:i.collapsed,settings:{name:new M({title:"Tab Name",default:`Tab ${t+1}`}),content:new M({title:"Content",default:""})}}),this.onDeleteCallback=e}draw(){const t=super.draw(),e=t.querySelector(".setting-group-arrow");e&&e.parentElement&&e.parentElement.removeChild(e);const i=t.querySelector(".setting-group-title");if(i){const s=document.createElement("div");s.className="tab-delete-container";const n=document.createElement("button");n.className="tab-delete-button",n.innerHTML=`
140
+ </svg>`;class Ct extends f{constructor(t,e,i){super({title:`Tab ${t+1}`,hideCondition:i==null?void 0:i.hideCondition,collapsed:i==null?void 0:i.collapsed,settings:{name:new S({title:"Tab Name",default:`Tab ${t+1}`}),content:new S({title:"Content",default:""})}}),this.onDeleteCallback=e}draw(){const t=super.draw(),e=t.querySelector(".setting-group-arrow");e&&e.parentElement&&e.parentElement.removeChild(e);const i=t.querySelector(".setting-group-title");if(i){const s=document.createElement("div");s.className="tab-delete-container";const n=document.createElement("button");n.className="tab-delete-button",n.innerHTML=`
141
141
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#f87171" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="trash-icon">
142
142
  <polyline points="3 6 5 6 21 6"></polyline>
143
143
  <path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"></path>
@@ -166,4 +166,4 @@
166
166
  `:`
167
167
  background-color: ${i};
168
168
  opacity: ${s/100};
169
- `}}exports.AlignSetting=A;exports.BackgroundSettingSet=bt;exports.BorderSettingSet=lt;exports.ButtonSetting=D;exports.ColorSetting=H;exports.DimensionSetting=F;exports.GapSetting=it;exports.HeaderTypographySettingSet=dt;exports.HeightSetting=Z;exports.MarginBottomSetting=nt;exports.MarginSettingGroup=ut;exports.NumberSetting=b;exports.OpacitySetting=L;exports.SelectApiSettings=K;exports.SelectSetting=N;exports.Setting=m;exports.SettingGroup=f;exports.StringSetting=M;exports.TabsContainerGroup=vt;exports.TabsSettings=E;exports.Toggle=tt;exports.UploadSetting=_;exports.WidthSetting=X;exports.iterateSettings=T;
169
+ `}}exports.AlignSetting=A;exports.BackgroundSettingSet=bt;exports.BorderSettingSet=lt;exports.ButtonSetting=q;exports.ColorSetting=H;exports.DimensionSetting=D;exports.GapSetting=it;exports.HeaderTypographySettingSet=dt;exports.HeightSetting=Z;exports.MarginBottomSetting=nt;exports.MarginSettingGroup=ut;exports.NumberSetting=b;exports.OpacitySetting=L;exports.SelectApiSettings=K;exports.SelectSetting=N;exports.Setting=m;exports.SettingGroup=f;exports.StringSetting=S;exports.TabsContainerGroup=vt;exports.TabsSettings=E;exports.Toggle=tt;exports.UploadSetting=_;exports.WidthSetting=X;exports.iterateSettings=T;
@@ -122,22 +122,10 @@ function M(c, t) {
122
122
  t(e, i);
123
123
  }
124
124
  }
125
- const E = class E {
125
+ const w = class w {
126
126
  constructor(t) {
127
127
  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.lastValues = {}, this.lastChangeTime = 0, this.CHANGE_DEBOUNCE = 100, this.handleBlur = () => {
128
- }, this.pendingBlurHandler = null, this.hasFocus = !1, this.focusTrackingEnabled = !1, this.handleFocus = () => {
129
- }, this.blurDebounceTime = 100, this.lastBlurTime = 0, this.isProcessingBlur = !1, this.isInteracting = !1, this.interactionStartTime = 0, this.modifiedSettings = /* @__PURE__ */ new Set(), this.activeSettingId = null, this.hasValueChanged = !1, this.handleInteractionStart = (e) => {
130
- this.isInteracting || (this.isInteracting = !0, this.interactionStartTime = Date.now(), this.modifiedSettings.clear(), console.log(`[${this.title}] Setting interaction started`));
131
- }, this.handleChange = (e) => {
132
- if (e.target instanceof HTMLElement) {
133
- this.hasValueChanged = !0;
134
- const i = e.target.closest("[data-setting-id]");
135
- if (i) {
136
- const s = i.getAttribute("data-setting-id");
137
- typeof s == "string" && (this.activeSettingId = s);
138
- }
139
- }
140
- }, typeof t.id == "string" && t.id.trim() !== "" ? this.id = t.id.trim() : this.id = R(), typeof t.title == "string" ? this.title = t.title : (this.title = "Untitled Setting Group", console.warn(`SettingGroup constructor: Invalid title provided, defaulting to '${this.title}'.`, t)), this.settings = t.settings, typeof t.description == "string" ? this.description = t.description : t.description === null || t.description === void 0 ? this.description = void 0 : (this.description = String(t.description), console.warn("SettingGroup constructor: Invalid description type, coercing to string.", t)), this.icon = t.icon, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.hideCondition = t.hideCondition, this.onBlur = t.onBlur, this.blurDebounceTime = t.blurDebounceTime ?? 100, Object.assign(this, t.settings), this.initialValues = this.getValues();
128
+ }, this.pendingBlurHandler = null, this.id = t.id || R(), this.title = t.title, this.settings = t.settings, this.description = t.description, this.icon = t.icon, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.hideCondition = t.hideCondition, this.onBlur = t.onBlur, Object.assign(this, t.settings), this.initialValues = this.getValues();
141
129
  }
142
130
  static hide() {
143
131
  this.hiddenElements.forEach((t) => {
@@ -157,77 +145,52 @@ const E = class E {
157
145
  this.initialValues,
158
146
  i
159
147
  );
160
- Object.keys(s).length > 0 && (this.hasValueChanged = !0, this.lastChangeTime = Date.now(), this.initialValues = i, t(i), this.updateVisibility()), this.isHandlingChange = !1;
148
+ Object.keys(s).length > 0 && (this.lastChangeTime = Date.now(), this.initialValues = i, t(i), this.updateVisibility()), this.isHandlingChange = !1;
161
149
  }, 50));
162
150
  };
163
151
  return this.changeHandlers.clear(), M(this.settings, (i, s) => {
164
152
  var n;
165
- if (s instanceof E)
153
+ if (s instanceof w)
166
154
  s.setOnChange((a) => {
167
- this.hasValueChanged = !0;
168
155
  const o = this.getValues();
169
156
  this.initialValues = o, t(o);
170
157
  }), this.changeHandlers.add(() => t(this.getValues()));
171
158
  else if (s instanceof m) {
172
159
  const a = () => {
173
- this.hasValueChanged = !0, e();
160
+ e();
174
161
  };
175
162
  this.changeHandlers.add(a), s.setOnChange(a);
176
163
  } else {
177
164
  const a = () => {
178
- this.hasValueChanged = !0, e();
165
+ e();
179
166
  };
180
167
  this.changeHandlers.add(a), (n = s.setOnChange) == null || n.call(s, a);
181
168
  }
182
169
  }), this;
183
170
  }
184
- setOnBlur(t, e) {
185
- return this.onBlur = t, this.pendingBlurHandler = t, this.focusTrackingEnabled = !0, e !== void 0 && (this.blurDebounceTime = e), this.handleBlur = (i) => {
186
- if (!this.hasValueChanged && !i) return;
187
- let n = null;
188
- if ((i == null ? void 0 : i.target) instanceof HTMLElement) {
189
- const a = i.target.closest("[data-setting-id]");
190
- if (a) {
191
- const o = a.getAttribute("data-setting-id");
192
- typeof o == "string" && (n = o);
193
- }
171
+ setOnBlur(t) {
172
+ return this.onBlur = t, this.pendingBlurHandler = t, this.handleBlur = (e) => {
173
+ (e == null ? void 0 : e.target) instanceof HTMLElement && e.target.closest(".setting-group") !== this.elementRef || (this.blurTimeout && clearTimeout(this.blurTimeout), this.blurTimeout = setTimeout(() => {
174
+ t();
175
+ }, 100));
176
+ }, this.elementRef && this.setupBlurHandlers(), this;
177
+ }
178
+ setupBlurHandlers() {
179
+ this.elementRef && this.elementRef.removeEventListener("focusout", this.handleBlur), this.elementRef && this.elementRef.addEventListener("focusout", this.handleBlur, !0), M(this.settings, (t, e) => {
180
+ var i;
181
+ if (e instanceof w)
182
+ e.setOnBlur(this.handleBlur);
183
+ else {
184
+ const s = (i = this.elementRef) == null ? void 0 : i.querySelector(`[data-setting-id="${e.id}"]`);
185
+ s && s.addEventListener("focusout", this.handleBlur, !0);
194
186
  }
195
- this.blurTimeout && clearTimeout(this.blurTimeout), this.blurTimeout = setTimeout(() => {
196
- try {
197
- this.saveChangesImmediately();
198
- const a = this.getValues();
199
- (this.activeSettingId === null && n !== null || n === null && this.activeSettingId !== null || this.activeSettingId !== n || this.hasValueChanged) && this.onBlur && (this.onBlur(a || {}), this.hasValueChanged = !1), this.activeSettingId = n;
200
- } catch (a) {
201
- console.error("Error in blur handler:", a), this.hasValueChanged = !1, this.activeSettingId = null;
202
- }
203
- }, this.blurDebounceTime);
204
- }, this.elementRef && this.setupFocusHandlers(), this;
205
- }
206
- hasFocusWithin() {
207
- if (!this.elementRef) return !1;
208
- const t = document.activeElement;
209
- return this.elementRef.contains(t) || this.hasFocus;
210
- }
211
- setupFocusHandlers() {
212
- if (!this.elementRef || !this.focusTrackingEnabled) return;
213
- this.elementRef.removeEventListener("focusout", this.handleBlur), this.elementRef.removeEventListener("change", this.handleChange), this.elementRef.removeEventListener("input", this.handleChange), this.elementRef.addEventListener("focusout", this.handleBlur), this.elementRef.addEventListener("change", this.handleChange), this.elementRef.addEventListener("input", this.handleChange);
214
- const t = this.elementRef.closest("form");
215
- t && (t.removeEventListener("submit", this.handleBlur), t.addEventListener("submit", this.handleBlur)), document.addEventListener("visibilitychange", () => {
216
- document.visibilityState === "hidden" && this.elementRef && document.activeElement && this.elementRef.contains(document.activeElement) && this.handleBlur();
217
187
  });
218
188
  }
189
+ // Clean up method to be called when the group is destroyed
219
190
  cleanup() {
220
- if (this.changeTimeout && (clearTimeout(this.changeTimeout), this.changeTimeout = null), this.blurTimeout && (clearTimeout(this.blurTimeout), this.blurTimeout = null), this.elementRef) {
221
- this.elementRef.removeEventListener("focusout", this.handleBlur), this.elementRef.removeEventListener("change", this.handleChange), this.elementRef.removeEventListener("input", this.handleChange);
222
- const t = this.elementRef.closest("form");
223
- t && t.removeEventListener("submit", this.handleBlur);
224
- }
225
- document.removeEventListener("visibilitychange", () => {
226
- document.visibilityState === "hidden" && this.elementRef && document.activeElement && this.elementRef.contains(document.activeElement) && this.handleBlur();
227
- }), M(this.settings, (t, e) => {
228
- typeof e.cleanup == "function" && e.cleanup();
229
- }), this.changeHandlers.clear(), this.activeSettingId = null, this.hasValueChanged = !1;
191
+ 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();
230
192
  }
193
+ // Add the clone method here
231
194
  clone() {
232
195
  const t = {};
233
196
  M(this.settings, (n, a) => {
@@ -236,12 +199,17 @@ const E = class E {
236
199
  const e = {
237
200
  title: this.title,
238
201
  settings: t,
202
+ // Cast needed as we build it dynamically
239
203
  description: this.description,
240
204
  icon: this.icon,
241
205
  collapsed: this.isCollapsed,
242
206
  main: this.isMain,
243
207
  custom: this.custom,
244
208
  hideCondition: this.hideCondition
209
+ // Note: Cloning event handlers (onBlur, onChange) is complex and often not desired.
210
+ // The new clone will typically need its own handlers set up.
211
+ // We intentionally do not copy onBlur or onChange here.
212
+ // id is generated anew in the constructor
245
213
  }, i = this.constructor, s = new i(e);
246
214
  return s.initialValues = this.getValues(), s;
247
215
  }
@@ -262,27 +230,22 @@ const E = class E {
262
230
  this.elementRef && (this.elementRef.style.display = "", this.isHidden = !1);
263
231
  }
264
232
  getValues(t) {
265
- try {
266
- if (t === void 0) {
267
- const e = {};
268
- for (const i in this.settings)
269
- if (this.settings.hasOwnProperty(i)) {
270
- const s = this.settings[i];
271
- if (!s) continue;
272
- s instanceof E ? e[i] = s.getValues() : typeof s.value < "u" && (e[i] = s.value);
273
- }
274
- return e;
275
- } else {
276
- const e = this.settings[t];
277
- return e ? (this.isInteracting && typeof t == "string" && this.modifiedSettings.add(t), e instanceof E ? e.getValues() : typeof e.value < "u" ? e.value : void 0) : void 0;
278
- }
279
- } catch (e) {
280
- return console.error("Error in getValues:", e), {};
233
+ if (t === void 0) {
234
+ const e = {};
235
+ for (const i in this.settings)
236
+ if (this.settings.hasOwnProperty(i)) {
237
+ const s = this.settings[i];
238
+ s instanceof w ? e[i] = s.getValues() : e[i] = s.value;
239
+ }
240
+ return e;
241
+ } else {
242
+ const e = this.settings[t];
243
+ return e ? e instanceof w ? e.getValues() : e.value : void 0;
281
244
  }
282
245
  }
283
246
  draw() {
284
247
  const t = document.createElement("div");
285
- t.className = "setting-group", t.id = `setting-group-${this.id}`, E.hiddenElements.add(t), this.hideCondition && this.hideCondition() && (t.style.display = "none"), this.isMain && t.classList.add("main-group");
248
+ t.className = "setting-group", t.id = `setting-group-${this.id}`, w.hiddenElements.add(t), this.hideCondition && this.hideCondition() && (t.style.display = "none"), this.isMain && t.classList.add("main-group");
286
249
  const e = document.createElement("div");
287
250
  e.className = "setting-group-title", this.isCollapsed && e.classList.add("collapsed-view"), e.setAttribute("role", "button"), e.setAttribute(
288
251
  "aria-expanded",
@@ -290,21 +253,21 @@ const E = class E {
290
253
  ), e.setAttribute("tabindex", "0");
291
254
  const i = document.createElement("div");
292
255
  if (i.className = "title-section", this.icon) {
293
- const h = document.createElement("span");
294
- h.className = "group-icon", h.innerHTML = this.icon, i.appendChild(h);
256
+ const r = document.createElement("span");
257
+ r.className = "group-icon", r.innerHTML = this.icon, i.appendChild(r);
295
258
  }
296
259
  this.custom && t.classList.add("custom_class");
297
260
  const s = document.createElement("h3");
298
261
  s.textContent = this.title, i.appendChild(s);
299
262
  const n = document.createElement("div");
300
263
  if (n.className = "actions-section", this.description && this.isCollapsed) {
301
- const h = document.createElement("span");
302
- h.className = "info-marker", h.innerHTML = `
264
+ const r = document.createElement("span");
265
+ r.className = "info-marker", r.innerHTML = `
303
266
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
304
267
  <path d="M8 5.33333V8M8 10.6667H8.00667M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z"
305
268
  stroke="currentColor" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
306
269
  </svg>
307
- `, h.title = this.description, n.appendChild(h);
270
+ `, r.title = this.description, n.appendChild(r);
308
271
  }
309
272
  const a = document.createElement("span");
310
273
  a.className = "setting-group-arrow", a.innerHTML = `
@@ -314,20 +277,20 @@ const E = class E {
314
277
  `, this.isCollapsed && a.classList.add("rotated"), n.appendChild(a);
315
278
  const o = document.createElement("div");
316
279
  if (o.className = "setting-group-content", this.isCollapsed && (o.classList.add("collapsed"), e.classList.add("collapsed-view"), a.classList.add("rotated"), t.classList.add("collapsed")), this.isMain && o.classList.add("main-content"), this.description && !this.isCollapsed) {
317
- const h = document.createElement("div");
318
- h.className = "setting-group-description", h.textContent = this.description, o.appendChild(h);
280
+ const r = document.createElement("div");
281
+ r.className = "setting-group-description", r.textContent = this.description, o.appendChild(r);
319
282
  }
320
283
  const l = () => {
321
284
  this.isCollapsed = !this.isCollapsed, o.classList.toggle("collapsed"), e.classList.toggle("collapsed-view"), a.classList.toggle("rotated"), t.classList.toggle("collapsed", this.isCollapsed), e.setAttribute(
322
285
  "aria-expanded",
323
286
  (!this.isCollapsed).toString()
324
287
  );
325
- const h = o.querySelector(
288
+ const r = o.querySelector(
326
289
  ".setting-group-description"
327
290
  ), u = n.querySelector(".info-marker");
328
291
  if (this.description)
329
292
  if (this.isCollapsed) {
330
- if (h && h.remove(), !u) {
293
+ if (r && r.remove(), !u) {
331
294
  const d = document.createElement("span");
332
295
  d.className = "info-marker", d.innerHTML = `
333
296
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -337,7 +300,7 @@ const E = class E {
337
300
  `, d.title = this.description, n.insertBefore(d, a);
338
301
  }
339
302
  } else {
340
- if (!h) {
303
+ if (!r) {
341
304
  const d = document.createElement("div");
342
305
  d.className = "setting-group-description", d.textContent = this.description, o.insertBefore(
343
306
  d,
@@ -347,19 +310,19 @@ const E = class E {
347
310
  u && u.remove();
348
311
  }
349
312
  };
350
- if (e.onclick = l, e.onkeydown = (h) => {
351
- (h.key === "Enter" || h.key === " ") && (h.preventDefault(), l());
313
+ if (e.onclick = l, e.onkeydown = (r) => {
314
+ (r.key === "Enter" || r.key === " ") && (r.preventDefault(), l());
352
315
  }, Object.keys(this.settings).length > 0) {
353
- for (const h in this.settings)
354
- if (this.settings.hasOwnProperty(h)) {
355
- const u = this.settings[h];
316
+ for (const r in this.settings)
317
+ if (this.settings.hasOwnProperty(r)) {
318
+ const u = this.settings[r];
356
319
  o.appendChild(u.draw());
357
320
  }
358
321
  } else {
359
- const h = document.createElement("div");
360
- h.className = "setting-group-empty", h.textContent = "No settings in this group", o.appendChild(h);
322
+ const r = document.createElement("div");
323
+ r.className = "setting-group-empty", r.textContent = "No settings in this group", o.appendChild(r);
361
324
  }
362
- return e.appendChild(i), e.appendChild(n), t.appendChild(e), t.appendChild(o), this.elementRef = t, this.pendingBlurHandler && (this.setupFocusHandlers(), this.pendingBlurHandler = null), t;
325
+ return e.appendChild(i), e.appendChild(n), t.appendChild(e), t.appendChild(o), this.elementRef = t, this.pendingBlurHandler && (this.setupBlurHandlers(), this.pendingBlurHandler = null), t;
363
326
  }
364
327
  collapse() {
365
328
  if (!this.elementRef || this.isCollapsed) return;
@@ -385,17 +348,10 @@ const E = class E {
385
348
  toggle() {
386
349
  this.isHidden ? this.show() : this.hide();
387
350
  }
388
- // Force save changes immediately without debounce
389
- saveChangesImmediately() {
390
- if (!this.onChange) return;
391
- this.changeTimeout && (clearTimeout(this.changeTimeout), this.changeTimeout = null);
392
- const t = this.getValues(), e = this.calculateChanges(this.initialValues, t);
393
- Object.keys(e).length > 0 && (this.initialValues = t, this.onChange(t), this.updateVisibility());
394
- }
395
351
  };
396
- E.hiddenElements = /* @__PURE__ */ new Set();
397
- let f = E;
398
- class H extends m {
352
+ w.hiddenElements = /* @__PURE__ */ new Set();
353
+ let f = w;
354
+ class S extends m {
399
355
  constructor(t = {}) {
400
356
  super(t), this.inputType = "text", t.onChange && this.setOnChange(t.onChange);
401
357
  }
@@ -416,13 +372,13 @@ class H extends m {
416
372
  }
417
373
  }
418
374
  const I = "<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";
419
- class O extends H {
375
+ class O extends S {
420
376
  constructor(t) {
421
377
  super({
422
378
  ...t,
423
379
  icon: t.icon || I,
424
380
  title: t.title || "Color"
425
- }), this.inputType = "color", this.detectChange = t.detectChange;
381
+ }), this.inputType = "color", this.element = null, this.detectChange = t.detectChange;
426
382
  }
427
383
  hexToRgb(t) {
428
384
  t = t.replace("#", "");
@@ -440,7 +396,7 @@ class O extends H {
440
396
  }
441
397
  draw() {
442
398
  const t = document.createElement("div");
443
- t.className = "color-setting-wrapper";
399
+ t.className = "color-setting-wrapper", this.element = t;
444
400
  const e = document.createElement("div");
445
401
  e.className = "icon-container";
446
402
  const i = this.createIcon(this.props.icon || I), s = this.createLabel(this.title || "Color");
@@ -459,26 +415,29 @@ class O extends H {
459
415
  value: this.value,
460
416
  inputType: "text",
461
417
  inputClassName: "color-text-input"
462
- }), r = l.querySelector("input");
463
- r.readOnly = !0;
464
- const h = this.createInput({
418
+ }), h = l.querySelector("input");
419
+ h.readOnly = !0;
420
+ const r = this.createInput({
465
421
  value: this.value ? this.rgbToHex(this.value) : "",
466
422
  inputType: this.inputType,
467
423
  inputClassName: "color-picker"
468
- }), u = h.querySelector("input");
469
- return r.oninput = (d) => {
424
+ }), u = r.querySelector("input");
425
+ return h.oninput = (d) => {
470
426
  var p;
471
427
  let g = d.target.value.trim();
472
- a(r) && (this.value = g, (p = this.onChange) == null || p.call(this, g), u.value = this.rgbToHex(g), o.style.backgroundColor = `rgb(${g})`);
428
+ a(h) && (this.value = g, (p = this.onChange) == null || p.call(this, g), u.value = this.rgbToHex(g), o.style.backgroundColor = `rgb(${g})`);
473
429
  }, u.oninput = (d) => {
474
430
  var C, v;
475
431
  const g = d.target.value, p = this.hexToRgb(g);
476
- this.value = p, (C = this.onChange) == null || C.call(this, p), (v = this.detectChange) == null || v.call(this, p), r.value = p, o.style.backgroundColor = `rgb(${p})`;
432
+ this.value = p, (C = this.onChange) == null || C.call(this, p), (v = this.detectChange) == null || v.call(this, p), h.value = p, o.style.backgroundColor = `rgb(${p})`;
477
433
  }, u.onchange = (d) => {
478
434
  var C, v;
479
435
  const g = d.target.value, p = this.hexToRgb(g);
480
- this.value = p, (C = this.onChange) == null || C.call(this, p), (v = this.detectChange) == null || v.call(this, p), r.value = p, o.style.backgroundColor = `rgb(${p})`;
481
- }, n.appendChild(o), n.appendChild(h), n.appendChild(l), t.appendChild(e), t.appendChild(n), this.value && (r.value = this.value, u.value = this.rgbToHex(this.value), o.style.backgroundColor = `rgb(${this.value})`), t;
436
+ this.value = p, (C = this.onChange) == null || C.call(this, p), (v = this.detectChange) == null || v.call(this, p), h.value = p, o.style.backgroundColor = `rgb(${p})`;
437
+ }, n.appendChild(o), n.appendChild(r), n.appendChild(l), t.appendChild(e), t.appendChild(n), this.value && (h.value = this.value, u.value = this.rgbToHex(this.value), o.style.backgroundColor = `rgb(${this.value})`), t;
438
+ }
439
+ getElement() {
440
+ return this.element;
482
441
  }
483
442
  }
484
443
  class b extends m {
@@ -610,8 +569,8 @@ class B extends m {
610
569
  selectOption(t, e, i) {
611
570
  var n, a, o;
612
571
  const s = this._options[e];
613
- s && (this.value = s.value, (n = this.onChange) == null || n.call(this, this.value), this.selectedOptionIndex = e, this.isOpen = !1, i.textContent = s.name, (a = this.optionsListEl) == null || a.classList.remove("open"), (o = this.svgContainer) == null || o.classList.remove("open"), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((r, h) => {
614
- h === e ? r.classList.add("selected") : r.classList.remove("selected");
572
+ s && (this.value = s.value, (n = this.onChange) == null || n.call(this, this.value), this.selectedOptionIndex = e, this.isOpen = !1, i.textContent = s.name, (a = this.optionsListEl) == null || a.classList.remove("open"), (o = this.svgContainer) == null || o.classList.remove("open"), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((h, r) => {
573
+ r === e ? h.classList.add("selected") : h.classList.remove("selected");
615
574
  }));
616
575
  }
617
576
  updateOptionsList() {
@@ -709,7 +668,7 @@ class lt extends m {
709
668
  return e.className = "button-setting-wrapper " + (this.props.wrapperClassName || ""), e.appendChild(t), e;
710
669
  }
711
670
  }
712
- class ht extends m {
671
+ class rt extends m {
713
672
  constructor(t = {}) {
714
673
  super(t), this.inputType = { width: "number", height: "number" }, this.aspectRatio = 1, this.isUpdating = !1;
715
674
  const e = t.width || 0, i = t.height || 0;
@@ -729,7 +688,7 @@ class ht extends m {
729
688
  suffix: "px",
730
689
  minValue: this.minHeight,
731
690
  maxValue: this.maxHeight,
732
- icon: D
691
+ icon: q
733
692
  }), this.widthSetting.setOnChange(this.handleWidthChange.bind(this)), this.heightSetting.setOnChange(this.handleHeightChange.bind(this));
734
693
  }
735
694
  handleWidthChange(t) {
@@ -823,18 +782,18 @@ class ht extends m {
823
782
  }
824
783
  const G = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
825
784
  <path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
826
- </svg>`, D = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
785
+ </svg>`, q = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
827
786
  <path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
828
- </svg>`, S = `
787
+ </svg>`, H = `
829
788
  <svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
830
789
  <path d="M5 10.5L7.5 8M7.5 8L10 10.5M7.5 8V13.625M12.5 10.9643C13.2634 10.3338 13.75 9.37996 13.75 8.3125C13.75 6.41402 12.211 4.875 10.3125 4.875C10.1759 4.875 10.0482 4.80375 9.97882 4.68609C9.16379 3.30302 7.65902 2.375 5.9375 2.375C3.34867 2.375 1.25 4.47367 1.25 7.0625C1.25 8.35381 1.77215 9.52317 2.61684 10.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
831
790
  </svg>
832
- `, F = `
791
+ `, D = `
833
792
  <svg width="91" height="71" viewBox="0 0 91 71" fill="none" xmlns="http://www.w3.org/2000/svg">
834
793
  <rect width="91" height="71" rx="4" fill="#F2F4F7"/>
835
794
  <path d="M37 31.5L39.5 29M39.5 29L42 31.5M39.5 29V34.625M44.5 31.9643C45.2634 31.3338 45.75 30.38 45.75 29.3125C45.75 27.414 44.211 25.875 42.3125 25.875C42.1759 25.875 42.0482 25.8037 41.9788 25.6861C41.1638 24.303 39.659 23.375 37.9375 23.375C35.3487 23.375 33.25 25.4737 33.25 28.0625C33.25 29.3538 33.7721 30.5232 34.6168 31.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
836
795
  </svg>
837
- `, q = `
796
+ `, F = `
838
797
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 12 12" fill="none">
839
798
  <path d="M8 3V2.6C8 2.03995 8 1.75992 7.89101 1.54601C7.79513 1.35785 7.64215 1.20487 7.45399 1.10899C7.24008 1 6.96005 1 6.4 1H5.6C5.03995 1 4.75992 1 4.54601 1.10899C4.35785 1.20487 4.20487 1.35785 4.10899 1.54601C4 1.75992 4 2.03995 4 2.6V3M5 5.75V8.25M7 5.75V8.25M1.5 3H10.5M9.5 3V8.6C9.5 9.44008 9.5 9.86012 9.33651 10.181C9.1927 10.4632 8.96323 10.6927 8.68099 10.8365C8.36012 11 7.94008 11 7.1 11H4.9C4.05992 11 3.63988 11 3.31901 10.8365C3.03677 10.6927 2.8073 10.4632 2.66349 10.181C2.5 9.86012 2.5 9.44008 2.5 8.6V3" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
840
799
  </svg>
@@ -847,29 +806,29 @@ class U extends m {
847
806
  if (!this.previewWrapper || !this.previewEl) return;
848
807
  const e = this.previewWrapper.parentElement, i = e == null ? void 0 : e.querySelector(".upload-button"), s = e == null ? void 0 : e.querySelector(".preview-placeholder");
849
808
  t && t !== "" ? (this.previewWrapper.classList.add("has-image"), this.previewEl.src = t, this.previewWrapper.style.display = "block", this.previewEl.style.display = "block", s && s instanceof HTMLElement && (s.style.display = "none"), e && e.classList.remove("no-image"), i && (i.innerHTML = `
850
- <span class="upload-icon">${S}</span>
809
+ <span class="upload-icon">${H}</span>
851
810
  <span class="upload-label">Replace</span>
852
811
  `)) : (this.previewWrapper.classList.remove("has-image"), this.previewEl.src = "", this.previewEl.style.display = "none", this.previewWrapper.style.display = "none", s && s instanceof HTMLElement && (s.style.display = "block"), e && e.classList.add("no-image"), i && (i.innerHTML = `
853
- <span class="upload-icon">${S}</span>
812
+ <span class="upload-icon">${H}</span>
854
813
  <span class="upload-label">Upload</span>
855
814
  `));
856
815
  }
857
816
  draw() {
858
817
  const t = document.createElement("div");
859
818
  t.className = "upload-setting-wrapper", t.setAttribute("data-setting-id", this.id), t.addEventListener("focusout", (l) => {
860
- var r;
861
- l.relatedTarget && t.contains(l.relatedTarget) || (r = this.onBlur) == null || r.call(this);
819
+ var h;
820
+ l.relatedTarget && t.contains(l.relatedTarget) || (h = this.onBlur) == null || h.call(this);
862
821
  }, !0);
863
822
  const e = !!(this.props.title || this.props.icon);
864
823
  if (e || t.classList.add("no-label"), e) {
865
824
  const l = document.createElement("div");
866
825
  if (l.className = "icon-title-container", this.props.icon) {
867
- const r = this.createIcon(this.props.icon);
868
- l.appendChild(r);
826
+ const h = this.createIcon(this.props.icon);
827
+ l.appendChild(h);
869
828
  }
870
829
  if (this.props.title) {
871
- const r = this.createLabel(this.props.title);
872
- l.appendChild(r);
830
+ const h = this.createLabel(this.props.title);
831
+ l.appendChild(h);
873
832
  }
874
833
  t.appendChild(l);
875
834
  }
@@ -878,25 +837,25 @@ class U extends m {
878
837
  const s = this.value && this.value !== "";
879
838
  s || i.classList.add("no-image");
880
839
  const n = document.createElement("div");
881
- if (n.className = "preview-placeholder", n.innerHTML = F, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview", this.props.delete) {
840
+ if (n.className = "preview-placeholder", n.innerHTML = D, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview", this.props.delete) {
882
841
  const l = document.createElement("button");
883
- l.className = "delete-button", l.type = "button", l.title = "Delete image", l.innerHTML = q, this.previewWrapper.appendChild(l), l.onclick = (r) => {
884
- var h;
885
- r.stopPropagation(), this.value = "", o.value = "", this.updatePreviewState(null), (h = this.onChange) == null || h.call(this, "");
842
+ l.className = "delete-button", l.type = "button", l.title = "Delete image", l.innerHTML = F, this.previewWrapper.appendChild(l), l.onclick = (h) => {
843
+ var r;
844
+ h.stopPropagation(), this.value = "", o.value = "", this.updatePreviewState(null), (r = this.onChange) == null || r.call(this, "");
886
845
  };
887
846
  }
888
847
  this.previewWrapper.appendChild(this.previewEl);
889
848
  const a = document.createElement("button");
890
849
  a.className = "upload-button", a.innerHTML = `
891
- <span class="upload-icon">${S}</span>
850
+ <span class="upload-icon">${H}</span>
892
851
  <span class="upload-label">Upload</span>
893
852
  `;
894
853
  const o = document.createElement("input");
895
854
  return o.type = "file", o.accept = "image/*", o.style.display = "none", i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(a), t.appendChild(i), t.appendChild(o), s ? this.updatePreviewState(this.value) : this.updatePreviewState(null), a.onclick = () => {
896
855
  o.click();
897
856
  }, o.onchange = async () => {
898
- var r, h, u, d;
899
- const l = (r = o.files) == null ? void 0 : r[0];
857
+ var h, r, u, d;
858
+ const l = (h = o.files) == null ? void 0 : h[0];
900
859
  if (l)
901
860
  try {
902
861
  a.classList.add("loading"), a.disabled = !0;
@@ -911,14 +870,14 @@ class U extends m {
911
870
  headers: L
912
871
  })).json();
913
872
  console.log("Upload response:", k);
914
- let w;
873
+ let x;
915
874
  if (this.props.parseResponse)
916
- w = this.props.parseResponse(k);
917
- else if (w = (h = k == null ? void 0 : k.data) == null ? void 0 : h.url, !w)
875
+ x = this.props.parseResponse(k);
876
+ else if (x = (r = k == null ? void 0 : k.data) == null ? void 0 : r.url, !x)
918
877
  throw new Error(
919
878
  "No URL found in response. Provide a parseResponse if needed."
920
879
  );
921
- console.log("Final URL:", w), this.value = w, this.updatePreviewState(w), (u = this.onChange) == null || u.call(this, w), (d = this.onBlur) == null || d.call(this);
880
+ console.log("Final URL:", x), this.value = x, this.updatePreviewState(x), (u = this.onChange) == null || u.call(this, x), (d = this.onBlur) == null || d.call(this);
922
881
  } catch (g) {
923
882
  console.error("Error uploading file:", g);
924
883
  } finally {
@@ -929,7 +888,7 @@ class U extends m {
929
888
  }, t;
930
889
  }
931
890
  }
932
- class rt extends b {
891
+ class ht extends b {
933
892
  // Store mobile value
934
893
  constructor(t = {}) {
935
894
  const e = {
@@ -1038,7 +997,7 @@ class dt extends m {
1038
997
  const a = new Set(this._options.map((l) => JSON.stringify(l.value))), o = n.filter((l) => !a.has(JSON.stringify(l.value)));
1039
998
  if (this._options.push(...o), this.isLoading = !1, this.hasInitializedOptions = !0, this.value !== void 0) {
1040
999
  const l = this._options.findIndex(
1041
- (r) => JSON.stringify(r.value) === JSON.stringify(this.value)
1000
+ (h) => JSON.stringify(h.value) === JSON.stringify(this.value)
1042
1001
  );
1043
1002
  this.selectedOptionIndex = l !== -1 ? l : null;
1044
1003
  } else
@@ -1050,7 +1009,7 @@ class dt extends m {
1050
1009
  const a = new Set(this._options.map((l) => JSON.stringify(l.value))), o = n.filter((l) => !a.has(JSON.stringify(l.value)));
1051
1010
  if (this._options.push(...o), this.isLoading = !1, this.value !== void 0) {
1052
1011
  const l = this._options.findIndex(
1053
- (r) => JSON.stringify(r.value) === JSON.stringify(this.value)
1012
+ (h) => JSON.stringify(h.value) === JSON.stringify(this.value)
1054
1013
  );
1055
1014
  this.selectedOptionIndex = l !== -1 ? l : null;
1056
1015
  } else
@@ -1061,7 +1020,7 @@ class dt extends m {
1061
1020
  })), t;
1062
1021
  }
1063
1022
  selectApiOption(t, e, i) {
1064
- var l, r, h, u;
1023
+ var l, h, r, u;
1065
1024
  const s = t.target, n = s.querySelector(".select-api-radio") || ((l = s.closest(".select-api-option")) == null ? void 0 : l.querySelector(".select-api-radio"));
1066
1025
  n && (n.checked = !0), this.selectedOptionIndex = e;
1067
1026
  const a = this._options[e].value;
@@ -1073,7 +1032,7 @@ class dt extends m {
1073
1032
  const d = i.firstChild;
1074
1033
  d && d.tagName === "SPAN" && (d.textContent = this._options[e].name);
1075
1034
  }
1076
- this.isOpen = !1, (r = this.optionsListEl) == null || r.classList.remove("open"), (h = this.svgContainer) == null || h.classList.remove("open"), (u = this.onChange) == null || u.call(this, a), this.detectChangeCallback && this.detectChangeCallback(a);
1035
+ this.isOpen = !1, (h = this.optionsListEl) == null || h.classList.remove("open"), (r = this.svgContainer) == null || r.classList.remove("open"), (u = this.onChange) == null || u.call(this, a), this.detectChangeCallback && this.detectChangeCallback(a);
1077
1036
  }
1078
1037
  updateOptionsList() {
1079
1038
  !this.optionsListEl || !this.buttonEl || (this.optionsListEl.innerHTML = "", this._options.forEach((t, e) => {
@@ -1129,19 +1088,19 @@ class ut extends m {
1129
1088
  i.className = "toggle-switch";
1130
1089
  const s = document.createElement("input");
1131
1090
  s.type = "checkbox", s.checked = ((o = (a = this.props.options) == null ? void 0 : a.find((l) => l.value === this.value)) == null ? void 0 : o.status) ?? !1, s.addEventListener("change", () => {
1132
- var r, h;
1133
- const l = ((h = (r = this.props.options) == null ? void 0 : r.find((u) => u.status === s.checked)) == null ? void 0 : h.value) ?? "";
1091
+ var h, r;
1092
+ const l = ((r = (h = this.props.options) == null ? void 0 : h.find((u) => u.status === s.checked)) == null ? void 0 : r.value) ?? "";
1134
1093
  this.value = l, this.onChange && this.onChange(this.value), this.detectChangeCallback && this.detectChangeCallback(this.value);
1135
1094
  });
1136
1095
  const n = document.createElement("span");
1137
1096
  if (n.className = "toggle-slider", this.props.activeColor || this.props.inactiveColor) {
1138
- const l = document.createElement("style"), r = this.props.activeColor || "#4CAF50", h = this.props.inactiveColor || "#ccc";
1097
+ const l = document.createElement("style"), h = this.props.activeColor || "#4CAF50", r = this.props.inactiveColor || "#ccc";
1139
1098
  l.textContent = `
1140
1099
  .toggle-switch input:checked + .toggle-slider {
1141
- background-color: ${r};
1100
+ background-color: ${h};
1142
1101
  }
1143
1102
  .toggle-switch .toggle-slider {
1144
- background-color: ${h};
1103
+ background-color: ${r};
1145
1104
  }
1146
1105
  `, document.head.appendChild(l);
1147
1106
  }
@@ -1186,10 +1145,10 @@ class pt extends m {
1186
1145
  let o = parseFloat(a.value);
1187
1146
  o = this.validateValue(o), String(o) !== a.value && (a.value = String(o)), this.inputValues[t] = o, this.setValue(o);
1188
1147
  }), s.addEventListener("blur", (n) => {
1189
- var l, r;
1148
+ var l, h;
1190
1149
  const a = n.target;
1191
1150
  let o = parseFloat(a.value);
1192
- o = this.validateValue(o), String(o) !== a.value && (a.value = String(o), this.inputValues[t] = o, this.setValue(o)), (r = (l = this.props).onBlur) == null || r.call(l);
1151
+ o = this.validateValue(o), String(o) !== a.value && (a.value = String(o), this.inputValues[t] = o, this.setValue(o)), (h = (l = this.props).onBlur) == null || h.call(l);
1193
1152
  }), i.appendChild(s), this.props.suffix && this.props.suffix !== "none") {
1194
1153
  const n = document.createElement("span");
1195
1154
  n.className = "gap-suffix", n.textContent = this.props.suffix, i.appendChild(n), s.style.paddingRight = "30px";
@@ -1206,7 +1165,7 @@ class pt extends m {
1206
1165
  return this.mobileValue;
1207
1166
  }
1208
1167
  }
1209
- class x extends f {
1168
+ class E extends f {
1210
1169
  // ms
1211
1170
  constructor(t) {
1212
1171
  var o;
@@ -1231,7 +1190,7 @@ class x extends f {
1231
1190
  tabs: this.tabValues,
1232
1191
  activeTabId: this.activeTabId
1233
1192
  }, Object.values(e.settings).forEach((i) => {
1234
- i instanceof x && (i._parentTabsSettings = this);
1193
+ i instanceof E && (i._parentTabsSettings = this);
1235
1194
  }), this.connectChildChangeHandlers());
1236
1195
  }
1237
1196
  /**
@@ -1259,7 +1218,7 @@ class x extends f {
1259
1218
  });
1260
1219
  }), this.tabs.forEach((e) => {
1261
1220
  Object.entries(e.settings).forEach(([i, s]) => {
1262
- (s instanceof f || s instanceof m) && (s instanceof x ? (s._parentTabsSettings = this, s.setOnChange((n) => {
1221
+ (s instanceof f || s instanceof m) && (s instanceof E ? (s._parentTabsSettings = this, s.setOnChange((n) => {
1263
1222
  Promise.resolve().then(() => {
1264
1223
  this.tabValues[e.id] = this.getTabValues(e), this.triggerDebouncedChange();
1265
1224
  });
@@ -1289,21 +1248,21 @@ class x extends f {
1289
1248
  handleTabClick(t) {
1290
1249
  var o, l;
1291
1250
  if (t === this.activeTabId) return;
1292
- const e = this.tabs.find((r) => r.id === this.activeTabId);
1251
+ const e = this.tabs.find((h) => h.id === this.activeTabId);
1293
1252
  e && (this.tabValues[this.activeTabId] = this.getTabValues(e)), this.previousTabId = this.activeTabId, this.activeTabId = t;
1294
1253
  const i = (o = this.tabsContainer) == null ? void 0 : o.querySelectorAll(".tab-button");
1295
- i == null || i.forEach((r) => {
1296
- if (r instanceof HTMLElement) {
1297
- const h = this.tabs.find((u) => u.label === r.textContent);
1298
- r.classList.toggle("active", (h == null ? void 0 : h.id) === t);
1254
+ i == null || i.forEach((h) => {
1255
+ if (h instanceof HTMLElement) {
1256
+ const r = this.tabs.find((u) => u.label === h.textContent);
1257
+ h.classList.toggle("active", (r == null ? void 0 : r.id) === t);
1299
1258
  }
1300
1259
  }), this.updateSettingsFromTab(t);
1301
1260
  const s = (l = this.container) == null ? void 0 : l.querySelector(".setting-group-content");
1302
1261
  if (s) {
1303
1262
  s.innerHTML = "";
1304
- const r = this.settings;
1305
- Object.values(r).forEach((h) => {
1306
- s.appendChild(h.draw());
1263
+ const h = this.settings;
1264
+ Object.values(h).forEach((r) => {
1265
+ s.appendChild(r.draw());
1307
1266
  });
1308
1267
  }
1309
1268
  const n = this.getValues();
@@ -1369,7 +1328,7 @@ class x extends f {
1369
1328
  activeTabId: this.activeTabId
1370
1329
  }, this.tabs.forEach((t) => {
1371
1330
  Object.values(t.settings).forEach((e) => {
1372
- e instanceof x && e.updateInitialValues();
1331
+ e instanceof E && e.updateInitialValues();
1373
1332
  });
1374
1333
  }));
1375
1334
  }
@@ -1393,7 +1352,7 @@ class x extends f {
1393
1352
  getTabValues(t) {
1394
1353
  const e = {};
1395
1354
  return Object.entries(t.settings).forEach(([i, s]) => {
1396
- s instanceof x || s instanceof f ? e[i] = s.getValues() : (s instanceof m, e[i] = s.value);
1355
+ s instanceof E || s instanceof f ? e[i] = s.getValues() : (s instanceof m, e[i] = s.value);
1397
1356
  }), e;
1398
1357
  }
1399
1358
  /**
@@ -1421,7 +1380,7 @@ class x extends f {
1421
1380
  settings: {}
1422
1381
  // We don't clone callbacks - they should be set up again on the clone
1423
1382
  };
1424
- return new x(e);
1383
+ return new E(e);
1425
1384
  }
1426
1385
  /**
1427
1386
  * Override setValue method to update the TabsSettings state
@@ -1629,9 +1588,9 @@ class V extends m {
1629
1588
  draw() {
1630
1589
  const t = this.value === "auto" ? "text" : "number", e = (o) => {
1631
1590
  this.value !== "auto" && (this.props.minValue !== void 0 && (o.min = String(this.props.minValue)), this.props.maxValue !== void 0 && (o.max = String(this.props.maxValue)), this.props.className && o.classList.add(this.props.className), o.addEventListener("input", () => {
1632
- const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, r = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
1633
- let h = Number(o.value);
1634
- h < l && (h = l), h > r && (h = r), o.value = String(h);
1591
+ const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, h = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
1592
+ let r = Number(o.value);
1593
+ r < l && (r = l), r > h && (r = h), o.value = String(r);
1635
1594
  }));
1636
1595
  }, i = this.createInput({
1637
1596
  value: this.value,
@@ -1658,8 +1617,8 @@ class V extends m {
1658
1617
  if (l.toLowerCase() === "auto")
1659
1618
  this.value = "auto";
1660
1619
  else {
1661
- const r = Number(l);
1662
- isNaN(r) || (this.value = r);
1620
+ const h = Number(l);
1621
+ isNaN(h) || (this.value = h);
1663
1622
  }
1664
1623
  this.onChange && this.onChange(this.value);
1665
1624
  }), i;
@@ -1725,11 +1684,11 @@ class ot extends f {
1725
1684
  hideCondition: i == null ? void 0 : i.hideCondition,
1726
1685
  collapsed: i == null ? void 0 : i.collapsed,
1727
1686
  settings: {
1728
- name: new H({
1687
+ name: new S({
1729
1688
  title: "Tab Name",
1730
1689
  default: `Tab ${t + 1}`
1731
1690
  }),
1732
- content: new H({
1691
+ content: new S({
1733
1692
  title: "Content",
1734
1693
  default: ""
1735
1694
  })
@@ -1911,10 +1870,10 @@ export {
1911
1870
  mt as BorderSettingSet,
1912
1871
  lt as ButtonSetting,
1913
1872
  O as ColorSetting,
1914
- ht as DimensionSetting,
1873
+ rt as DimensionSetting,
1915
1874
  pt as GapSetting,
1916
1875
  ft as HeaderTypographySettingSet,
1917
- rt as HeightSetting,
1876
+ ht as HeightSetting,
1918
1877
  gt as MarginBottomSetting,
1919
1878
  Ct as MarginSettingGroup,
1920
1879
  b as NumberSetting,
@@ -1923,9 +1882,9 @@ export {
1923
1882
  B as SelectSetting,
1924
1883
  m as Setting,
1925
1884
  f as SettingGroup,
1926
- H as StringSetting,
1885
+ S as StringSetting,
1927
1886
  vt as TabsContainerGroup,
1928
- x as TabsSettings,
1887
+ E as TabsSettings,
1929
1888
  ut as Toggle,
1930
1889
  U as UploadSetting,
1931
1890
  ct as WidthSetting,
package/dist/index.d.ts CHANGED
@@ -100,10 +100,12 @@ export declare interface ButtonSettingProps extends SettingProps<void> {
100
100
  export declare class ColorSetting extends StringSetting {
101
101
  inputType: InputTypes;
102
102
  detectChange?: (value: string | undefined) => void;
103
+ private element;
103
104
  constructor(props: ColorSettingProps);
104
105
  private hexToRgb;
105
106
  private rgbToHex;
106
107
  draw(): HTMLElement;
108
+ getElement(): HTMLElement | null;
107
109
  }
108
110
 
109
111
  export declare interface ColorSettingProps extends StringSettingsProps {
@@ -423,7 +425,7 @@ export declare class SettingGroup<T extends Record<string, Setting<any, any> | S
423
425
  icon?: string;
424
426
  id: string;
425
427
  onChange?: ((value: T) => void) | undefined;
426
- onBlur?: (values?: any) => void;
428
+ onBlur?: () => void;
427
429
  private isCollapsed;
428
430
  private isMain;
429
431
  private elementRef;
@@ -441,25 +443,12 @@ export declare class SettingGroup<T extends Record<string, Setting<any, any> | S
441
443
  private readonly CHANGE_DEBOUNCE;
442
444
  private handleBlur;
443
445
  private pendingBlurHandler;
444
- private hasFocus;
445
- private focusTrackingEnabled;
446
- private handleFocus;
447
- private blurDebounceTime;
448
- private lastBlurTime;
449
- private isProcessingBlur;
450
- private isInteracting;
451
- private interactionStartTime;
452
- private modifiedSettings;
453
- private activeSettingId;
454
- private hasValueChanged;
455
446
  constructor(groupProps: SettingGroupProps<T>);
456
447
  static hide(): void;
457
448
  static show(): void;
458
449
  setOnChange(onChange: (value: T) => void): SettingGroup<T>;
459
- setOnBlur(onBlur: (values?: any) => void, debounceTime?: number): SettingGroup<T>;
460
- private hasFocusWithin;
461
- private setupFocusHandlers;
462
- private handleInteractionStart;
450
+ setOnBlur(onBlur: () => void): SettingGroup<T>;
451
+ private setupBlurHandlers;
463
452
  cleanup(): void;
464
453
  clone(): SettingGroup<T>;
465
454
  calculateChanges(oldValues: Record<string, any>, newValues: Record<string, any>): Record<string, any>;
@@ -471,8 +460,6 @@ export declare class SettingGroup<T extends Record<string, Setting<any, any> | S
471
460
  expand(): void;
472
461
  updateVisibility(): void;
473
462
  toggle(): void;
474
- private saveChangesImmediately;
475
- private handleChange;
476
463
  }
477
464
 
478
465
  export declare type SettingGroupProps<T> = {
@@ -484,9 +471,8 @@ export declare type SettingGroupProps<T> = {
484
471
  description?: string;
485
472
  icon?: string;
486
473
  hideCondition?: () => boolean;
487
- onBlur?: (values?: any) => void;
474
+ onBlur?: () => void;
488
475
  custom?: boolean;
489
- blurDebounceTime?: number;
490
476
  };
491
477
 
492
478
  export declare interface SettingProps<T> {
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.149",
4
+ "version": "0.0.151",
5
5
  "type": "module",
6
6
  "main": "dist/builder-settings-types.cjs.js",
7
7
  "module": "dist/builder-settings-types.es.js",