builder-settings-types 0.0.236 → 0.0.239

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 G="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let O=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=G[e[c]&63];return t};function z(c){let t=0,e=c.parentElement;for(;e;)e.classList.contains("setting-group")&&e!==c&&t++,e=e.parentElement;return t}function b(c,t){const e=Math.min(Math.max(t,0),5);c.setAttribute("data-nesting-level",e.toString()),e>0?c.style.setProperty("--visual-indent",`${e*2}px`):(c.style.removeProperty("--visual-indent"),c.style.marginLeft="")}function V(c,t=0){c.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(i=>{const s=i,n=t+1;b(s,n),V(s,n)})}const P={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class j{constructor(t={}){this.observedElements=new Set,this.config={...P,...t},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(t=>{let e=!1;t.forEach(i=>{i.type==="childList"&&i.addedNodes.forEach(s=>{s instanceof HTMLElement&&(s.classList.contains("setting-group")?[s]:Array.from(s.querySelectorAll(".setting-group"))).length>0&&(e=!0)})}),e&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(t){this.observedElements.add(t),this.updateElementNesting(t)}untrackElement(t){this.observedElements.delete(t)}updateElementNesting(t){const e=z(t);this.applyNestingWithConfig(t,e)}updateAllNesting(){this.observedElements.forEach(t=>{t.isConnected?this.updateElementNesting(t):this.observedElements.delete(t)})}applyNestingWithConfig(t,e){const i=Math.min(Math.max(e,0),this.config.maxLevel);if(t.setAttribute("data-nesting-level",i.toString()),i>0){const s=i*this.config.visualIndentMultiplier;t.style.setProperty("--visual-indent",`${s}px`)}else t.style.removeProperty("--visual-indent"),t.style.marginLeft=""}recalculateNesting(t=document.body){t.querySelectorAll(".setting-group").forEach(i=>{const s=i;this.updateElementNesting(s),this.trackElement(s)})}getNestingStats(){const t={};return this.observedElements.forEach(e=>{const i=parseInt(e.getAttribute("data-nesting-level")||"0",10);t[i]=(t[i]||0)+1}),t}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const N=new j;function y(c){if(c===null||typeof c!="object")return c;if(c instanceof Date)return new Date(c.getTime());if(c instanceof Array)return c.map(t=>y(t));if(typeof c=="object"){const t={};for(const e in c)Object.prototype.hasOwnProperty.call(c,e)&&(t[e]=y(c[e]));return t}return c}function W(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 g{constructor(t={}){this.props=t,this.id=t.id||O(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||"",this.includeGetJson=t.includeGetJson!==void 0?t.includeGetJson:!0}static SetUploadUrl(t){globalThis.DefaultUploadUrl=t,g.DefaultUploadUrl=t}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=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=y(this.props),i=new t(e);return i.value=y(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 o=document.createElement("div");if(o.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);o.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);o.appendChild(l)}e.appendChild(o)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||W(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"";const n=o=>{const l=o.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},a=o=>{o.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",a),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 w(c){return c instanceof g}function p(c){return c instanceof v}function D(c){return w(c)||p(c)}function x(c,t){for(const e in c)if(Object.prototype.hasOwnProperty.call(c,e)){const i=c[e];t(e,i)}}const k=class k{constructor(t){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastChangeTime=0,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.nestingLevel=0,this.id=t.id||O(),this.title=t.title,this.settings=t.settings,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.nestingLevel=0,this.includeGetJson=t.includeGetJson??!0,this.addItemCfg=t.addItem,this.deleteItemCfg=t.deleteItem,Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel()}propagateNestingLevel(){const t=this.nestingLevel+1;x(this.settings,(e,i)=>{p(i)&&(i.nestingLevel=t,i.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(t){this.nestingLevel=t,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}updateNestingStyles(){this.elementRef&&(b(this.elementRef,this.nestingLevel),V(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([t,e])=>{try{if(p(e)){const i=e.getValues();e.setValue(i)}else if(typeof e.setValue=="function"){const i=e.value;i!==void 0&&e.setValue(i)}}catch(i){console.warn(`Error refreshing UI for setting ${t}:`,i)}})}removeSetting(t){var s;const e=this.settings[t];if(!e)return;if(delete this.settings[t],this.elementRef){const n=this.elementRef.querySelector(".setting-group-content");if(n){const a=Array.from(n.querySelectorAll(".setting-group, .setting"));for(const o of a){const l=o.id;if(l&&l.includes(e.id)){o.remove();break}}}}typeof e.cleanup=="function"&&e.cleanup(),this.updateNestingStyles();const i=this.getValues();this.initialValues=i,(s=this.onChange)==null||s.call(this,i)}updateVisibility(){this.elementRef}clone(){const t={};x(this.settings,(s,n)=>{const a=String(s);typeof n.clone=="function"?t[a]=n.clone():(console.warn(`Setting with key '${a}' does not have a clone method. Copying reference.`),t[a]=n)});const e={title:this.title,settings:t,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg},i=H(e);return i.initialValues=this.getValues(),i}resetDefault(){const t=this.originalDefaultValues;this.setValue(t),this.onChange&&this.onChange(this.getValues())}setMobileValues(t){!t||typeof t!="object"||(Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(p(s)||w(s))&&typeof s.setMobileValue=="function"&&s.setMobileValue(i)}),this.setValue(t),this.onChange&&this.onChange(this.getValues()))}getMobileValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(p(s))e[i]=s.getMobileValues();else{const n=s;e[i]=n.mobileValue!==void 0?n.mobileValue:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(p(e))return e.getMobileValues();const i=e;return i.mobileValue!==void 0?i.mobileValue:i.value}}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),x(this.settings,(i,s)=>{var n;if(p(s))s.setOnChange(()=>{const a=this.getValues();this.initialValues=a,t(a)}),this.changeHandlers.add(()=>t(this.getValues()));else if(w(s)){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}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear()}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{let n=this.settings[i];if(!n&&this.addItemCfg&&i.startsWith(this.addItemCfg.keyPrefix)){const a=i.slice(this.addItemCfg.keyPrefix.length),o=Number(a);if(Number.isFinite(o)){const l=this.addItemCfg.createItem(o);this.addSetting(i,l),n=l}}n&&(p(n)||w(n))&&typeof n.setValue=="function"&&n.setValue(s)}),setTimeout(()=>{this.forceChildUIRefresh()},0);const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}wireChild(t){var i;const e=()=>{var n;const s=this.getValues();this.initialValues=s,(n=this.onChange)==null||n.call(this,s),this.updateVisibility()};p(t)?t.setOnChange(()=>e()):w(t)?t.setOnChange(()=>e()):(i=t.setOnChange)==null||i.call(t,()=>e())}addSetting(t,e){var s,n;if(this.settings[t]=e,this.wireChild(e),this.elementRef){const a=this.elementRef.querySelector(".setting-group-content");if(a){p(e)&&typeof e.setNestingLevel=="function"&&e.setNestingLevel(this.nestingLevel+1);const o=e.draw(),l=this.deleteItemCfg??this.addItemCfg;if(l){const d=l.keyPrefix??((s=this.addItemCfg)==null?void 0:s.keyPrefix);d&&t.startsWith(d)&&this.addDeleteButtonToElement(o,t)}const r=a.querySelector(".sg-add-button-bottom");r?a.insertBefore(o,r):a.appendChild(o),N.trackElement(o),b(o,this.nestingLevel+1),V(o,this.nestingLevel+1);const h=o.style.display;o.style.display="none",o.offsetHeight,o.style.display=h,this.updateNestingStyles()}}const i=this.getValues();this.initialValues=i,(n=this.onChange)==null||n.call(this,i)}addDeleteButtonToElement(t,e,i){let s=null;try{s=t.querySelector(":scope > .setting-group-title")}catch{s=null}if(!s){const r=Array.from(t.querySelectorAll(".setting-group-title"));for(const h of r)if(h.closest(".setting-group")===t){s=h;break}s||(s=r[0]??null)}if(!s)return;const n=s.querySelector(".actions-section");if(!n)return;const a=document.createElement("button");a.type="button",a.className="sg-delete-button",i?i.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,a.title="Delete",a.style.cssText=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let O=(h=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(h|=0));for(;h--;)t+=G[e[h]&63];return t};function z(h){let t=0,e=h.parentElement;for(;e;)e.classList.contains("setting-group")&&e!==h&&t++,e=e.parentElement;return t}function b(h,t){const e=Math.min(Math.max(t,0),5);h.setAttribute("data-nesting-level",e.toString()),e>0?h.style.setProperty("--visual-indent",`${e*2}px`):(h.style.removeProperty("--visual-indent"),h.style.marginLeft="")}function V(h,t=0){h.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(i=>{const s=i,n=t+1;b(s,n),V(s,n)})}const P={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class j{constructor(t={}){this.observedElements=new Set,this.config={...P,...t},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(t=>{let e=!1;t.forEach(i=>{i.type==="childList"&&i.addedNodes.forEach(s=>{s instanceof HTMLElement&&(s.classList.contains("setting-group")?[s]:Array.from(s.querySelectorAll(".setting-group"))).length>0&&(e=!0)})}),e&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(t){this.observedElements.add(t),this.updateElementNesting(t)}untrackElement(t){this.observedElements.delete(t)}updateElementNesting(t){const e=z(t);this.applyNestingWithConfig(t,e)}updateAllNesting(){this.observedElements.forEach(t=>{t.isConnected?this.updateElementNesting(t):this.observedElements.delete(t)})}applyNestingWithConfig(t,e){const i=Math.min(Math.max(e,0),this.config.maxLevel);if(t.setAttribute("data-nesting-level",i.toString()),i>0){const s=i*this.config.visualIndentMultiplier;t.style.setProperty("--visual-indent",`${s}px`)}else t.style.removeProperty("--visual-indent"),t.style.marginLeft=""}recalculateNesting(t=document.body){t.querySelectorAll(".setting-group").forEach(i=>{const s=i;this.updateElementNesting(s),this.trackElement(s)})}getNestingStats(){const t={};return this.observedElements.forEach(e=>{const i=parseInt(e.getAttribute("data-nesting-level")||"0",10);t[i]=(t[i]||0)+1}),t}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const N=new j;function y(h){if(h===null||typeof h!="object")return h;if(h instanceof Date)return new Date(h.getTime());if(h instanceof Array)return h.map(t=>y(t));if(typeof h=="object"){const t={};for(const e in h)Object.prototype.hasOwnProperty.call(h,e)&&(t[e]=y(h[e]));return t}return h}function W(h){switch(h){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 g{constructor(t={}){this.props=t,this.id=t.id||O(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||"",this.includeGetJson=t.includeGetJson!==void 0?t.includeGetJson:!0}static SetUploadUrl(t){globalThis.DefaultUploadUrl=t,g.DefaultUploadUrl=t}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=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=y(this.props),i=new t(e);return i.value=y(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 o=document.createElement("div");if(o.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);o.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);o.appendChild(l)}e.appendChild(o)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||W(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"";const n=o=>{const l=o.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},a=o=>{o.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",a),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 w(h){return h instanceof g}function p(h){return h instanceof v}function D(h){return w(h)||p(h)}function x(h,t){for(const e in h)if(Object.prototype.hasOwnProperty.call(h,e)){const i=h[e];t(e,i)}}const k=class k{constructor(t){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastChangeTime=0,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.nestingLevel=0,this.id=t.id||O(),this.title=t.title,this.settings=t.settings,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.nestingLevel=0,this.includeGetJson=t.includeGetJson??!0,this.addItemCfg=t.addItem,this.deleteItemCfg=t.deleteItem,Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel()}propagateNestingLevel(){const t=this.nestingLevel+1;x(this.settings,(e,i)=>{p(i)&&(i.nestingLevel=t,i.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(t){this.nestingLevel=t,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}updateNestingStyles(){this.elementRef&&(b(this.elementRef,this.nestingLevel),V(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([t,e])=>{try{if(p(e)){const i=e.getValues();e.setValue(i)}else if(typeof e.setValue=="function"){const i=e.value;i!==void 0&&e.setValue(i)}}catch(i){console.warn(`Error refreshing UI for setting ${t}:`,i)}})}removeSetting(t){var s;const e=this.settings[t];if(!e)return;if(delete this.settings[t],this.elementRef){const n=this.elementRef.querySelector(".setting-group-content");if(n){const a=Array.from(n.querySelectorAll(".setting-group, .setting"));for(const o of a){const l=o.id;if(l&&"id"in e&&typeof e.id=="string"&&l.includes(e.id)){o.remove();break}}}}typeof e.cleanup=="function"&&e.cleanup(),this.updateNestingStyles();const i=this.getValues();this.initialValues=i,(s=this.onChange)==null||s.call(this,i)}updateVisibility(){this.elementRef}clone(){const t={};x(this.settings,(s,n)=>{const a=String(s);typeof n.clone=="function"?t[a]=n.clone():(console.warn(`Setting with key '${a}' does not have a clone method. Copying reference.`),t[a]=n)});const e={title:this.title,settings:t,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg},i=H(e);return i.initialValues=this.getValues(),i}resetDefault(){const t=this.originalDefaultValues;this.setValue(t),this.onChange&&this.onChange(this.getValues())}setMobileValues(t){!t||typeof t!="object"||(Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(p(s)||w(s))&&typeof s.setMobileValue=="function"&&s.setMobileValue(i)}),this.setValue(t),this.onChange&&this.onChange(this.getValues()))}getMobileValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(p(s))e[i]=s.getMobileValues();else{const n=s;e[i]=n.mobileValue!==void 0?n.mobileValue:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(p(e))return e.getMobileValues();const i=e;return i.mobileValue!==void 0?i.mobileValue:i.value}}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),x(this.settings,(i,s)=>{var n;if(p(s))s.setOnChange(()=>{const a=this.getValues();this.initialValues=a,t(a)}),this.changeHandlers.add(()=>t(this.getValues()));else if(w(s)){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}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear()}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{let n=this.settings[i];if(!n&&this.addItemCfg&&i.startsWith(this.addItemCfg.keyPrefix)){const a=i.slice(this.addItemCfg.keyPrefix.length),o=Number(a);if(Number.isFinite(o)){const l=this.addItemCfg.createItem(o);this.addSetting(i,l),n=l}}n&&(p(n)||w(n))&&typeof n.setValue=="function"&&n.setValue(s)}),setTimeout(()=>{this.forceChildUIRefresh()},0);const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}wireChild(t){var i;const e=()=>{var n;const s=this.getValues();this.initialValues=s,(n=this.onChange)==null||n.call(this,s),this.updateVisibility()};p(t)?t.setOnChange(()=>e()):w(t)?t.setOnChange(()=>e()):(i=t.setOnChange)==null||i.call(t,()=>e())}addSetting(t,e){var s,n;if(this.settings[t]=e,this.wireChild(e),this.elementRef){const a=this.elementRef.querySelector(".setting-group-content");if(a){p(e)&&typeof e.setNestingLevel=="function"&&e.setNestingLevel(this.nestingLevel+1);const o=e.draw(),l=this.deleteItemCfg??this.addItemCfg;if(l){const d=l.keyPrefix??((s=this.addItemCfg)==null?void 0:s.keyPrefix);d&&t.startsWith(d)&&this.addDeleteButtonToElement(o,t)}const r=a.querySelector(".sg-add-button-bottom");r?a.insertBefore(o,r):a.appendChild(o),N.trackElement(o),b(o,this.nestingLevel+1),V(o,this.nestingLevel+1);const c=o.style.display;o.style.display="none",o.offsetHeight,o.style.display=c,this.updateNestingStyles()}}const i=this.getValues();this.initialValues=i,(n=this.onChange)==null||n.call(this,i)}addDeleteButtonToElement(t,e,i){let s=null;try{s=t.querySelector(":scope > .setting-group-title")}catch{s=null}if(!s){const r=Array.from(t.querySelectorAll(".setting-group-title"));for(const c of r)if(c.closest(".setting-group")===t){s=c;break}s||(s=r[0]??null)}if(!s)return;const n=s.querySelector(".actions-section");if(!n)return;const a=document.createElement("button");a.type="button",a.className="sg-delete-button",i?i.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,a.title="Delete",a.style.cssText=`
2
2
  background: none;
3
3
  border: none;
4
4
  cursor: pointer;
@@ -15,7 +15,7 @@
15
15
  <path d="M2 4h12M5.333 4V2.667a1.333 1.333 0 0 1 1.334-1.334h2.666a1.333 1.333 0 0 1 1.334 1.334V4m2 0v9.333a1.333 1.333 0 0 1-1.334 1.334H4.667a1.333 1.333 0 0 1-1.334-1.334V4h8.667Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
16
16
  <path d="M6.667 7.333v4M9.333 7.333v4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
17
17
  </svg>
18
- `;a.innerHTML=o,a.addEventListener("mouseenter",()=>{a.style.backgroundColor="#fef2f2"}),a.addEventListener("mouseleave",()=>{a.style.backgroundColor="transparent"}),a.addEventListener("click",r=>{r.stopPropagation(),r.preventDefault(),this.showDeleteConfirmation().then(h=>{h&&(i&&i.deleteItemCfg?this.removeSetting(e):this.removeSetting(e))})});const l=n.querySelector(".setting-group-arrow");l?n.insertBefore(a,l):n.appendChild(a)}showDeleteConfirmation(){return new Promise(t=>{const e=document.createElement("div");e.className="sg-modal-overlay",e.style.cssText=`
18
+ `;a.innerHTML=o,a.addEventListener("mouseenter",()=>{a.style.backgroundColor="#fef2f2"}),a.addEventListener("mouseleave",()=>{a.style.backgroundColor="transparent"}),a.addEventListener("click",r=>{r.stopPropagation(),r.preventDefault(),this.showDeleteConfirmation().then(c=>{c&&(i&&i.deleteItemCfg?this.removeSetting(e):this.removeSetting(e))})});const l=n.querySelector(".setting-group-arrow");l?n.insertBefore(a,l):n.appendChild(a)}showDeleteConfirmation(){return new Promise(t=>{const e=document.createElement("div");e.className="sg-modal-overlay",e.style.cssText=`
19
19
  position: fixed;
20
20
  top: 0;
21
21
  left: 0;
@@ -70,16 +70,16 @@
70
70
  font-weight: 500;
71
71
  cursor: pointer;
72
72
  transition: all 0.2s;
73
- `,o.addEventListener("mouseenter",()=>{o.style.backgroundColor="#f9fafb",o.style.borderColor="#9ca3af"}),o.addEventListener("mouseleave",()=>{o.style.backgroundColor="white",o.style.borderColor="#d1d5db"}),l.addEventListener("mouseenter",()=>{l.style.backgroundColor="#dc2626"}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="#ef4444"});const r=()=>{e.style.opacity="0",i.style.transform="scale(0.95)",setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e)},200)};o.addEventListener("click",()=>{r(),t(!1)}),l.addEventListener("click",()=>{r(),t(!0)}),e.addEventListener("click",d=>{d.target===e&&(r(),t(!1))});const h=d=>{d.key==="Escape"&&(r(),t(!1),document.removeEventListener("keydown",h))};document.addEventListener("keydown",h),a.appendChild(o),a.appendChild(l),i.appendChild(s),i.appendChild(n),i.appendChild(a),e.appendChild(i),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.opacity="1",i.style.transform="scale(1)"}),setTimeout(()=>l.focus(),100)})}getNextIndexFromPrefix(t){const e=Object.keys(this.settings).filter(i=>i.startsWith(t)).map(i=>{const s=Number(i.slice(t.length));return Number.isFinite(s)?s:-1}).filter(i=>i>=0);return e.length?Math.max(...e)+1:0}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}getValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];p(s)?e[i]=s.getValues():e[i]=s.value}return e}else{const e=this.settings[t];return e?p(e)?e.getValues():e.value:void 0}}getValuesForJson(t){if(t===void 0){if(this.includeGetJson===!1)return null;const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(p(s))e[i]=s.getValuesForJson();else{const n=s;n.includeGetJson===!1?e[i]=null:e[i]=n.value}}return e}else{const e=this.settings[t];if(!e)return;if(p(e))return e.includeGetJson===!1?null:e.getValuesForJson();{const i=e;return i.includeGetJson===!1?null:i.value}}}getDefaultValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(p(s))e[i]=s.getDefaultValues();else{const n=s;e[i]=n.default!==void 0?n.default:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(p(e))return e.getDefaultValues();const i=e;return i.default!==void 0?i.default:i.value}}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,k.hiddenElements.add(t),this.isMain&&t.classList.add("main-group"),this.custom&&t.classList.add("custom_class"),b(t,this.nestingLevel);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");i.className="title-section";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="actions-section";const a=document.createElement("span");a.className="setting-group-arrow",a.innerHTML=`
73
+ `,o.addEventListener("mouseenter",()=>{o.style.backgroundColor="#f9fafb",o.style.borderColor="#9ca3af"}),o.addEventListener("mouseleave",()=>{o.style.backgroundColor="white",o.style.borderColor="#d1d5db"}),l.addEventListener("mouseenter",()=>{l.style.backgroundColor="#dc2626"}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="#ef4444"});const r=()=>{e.style.opacity="0",i.style.transform="scale(0.95)",setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e)},200)};o.addEventListener("click",()=>{r(),t(!1)}),l.addEventListener("click",()=>{r(),t(!0)}),e.addEventListener("click",d=>{d.target===e&&(r(),t(!1))});const c=d=>{d.key==="Escape"&&(r(),t(!1),document.removeEventListener("keydown",c))};document.addEventListener("keydown",c),a.appendChild(o),a.appendChild(l),i.appendChild(s),i.appendChild(n),i.appendChild(a),e.appendChild(i),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.opacity="1",i.style.transform="scale(1)"}),setTimeout(()=>l.focus(),100)})}getNextIndexFromPrefix(t){const e=Object.keys(this.settings).filter(i=>i.startsWith(t)).map(i=>{const s=Number(i.slice(t.length));return Number.isFinite(s)?s:-1}).filter(i=>i>=0);return e.length?Math.max(...e)+1:0}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}getValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];p(s)?e[i]=s.getValues():e[i]=s.value}return e}else{const e=this.settings[t];return e?p(e)?e.getValues():e.value:void 0}}getValuesForJson(t){if(t===void 0){if(this.includeGetJson===!1)return null;const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(p(s))e[i]=s.getValuesForJson();else{const n=s;n.includeGetJson===!1?e[i]=null:e[i]=n.value}}return e}else{const e=this.settings[t];if(!e)return;if(p(e))return e.includeGetJson===!1?null:e.getValuesForJson();{const i=e;return i.includeGetJson===!1?null:i.value}}}getDefaultValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(p(s))e[i]=s.getDefaultValues();else{const n=s;e[i]=n.default!==void 0?n.default:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(p(e))return e.getDefaultValues();const i=e;return i.default!==void 0?i.default:i.value}}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,k.hiddenElements.add(t),this.isMain&&t.classList.add("main-group"),this.custom&&t.classList.add("custom_class"),b(t,this.nestingLevel);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");i.className="title-section";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="actions-section";const a=document.createElement("span");a.className="setting-group-arrow",a.innerHTML=`
74
74
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
75
75
  <path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
76
76
  </svg>
77
- `,this.isCollapsed&&a.classList.add("rotated"),n.appendChild(a);const o=document.createElement("div");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");const l=()=>{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("aria-expanded",(!this.isCollapsed).toString())};if(e.onclick=l,e.onkeydown=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),l())},Object.keys(this.settings).length>0){for(const h in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,h)){const d=this.settings[h];p(d)&&typeof d.setNestingLevel=="function"&&d.setNestingLevel(this.nestingLevel+1);const u=d.draw();p(d)&&d.deleteItemCfg&&this.addDeleteButtonToElement(u,h,d),o.appendChild(u)}}else{const h=document.createElement("div");h.className="setting-group-empty",h.textContent="No settings in this group",o.appendChild(h)}if(this.addItemCfg){const h=document.createElement("button");h.type="button",h.className="sg-add-button-bottom",h.style.marginTop="8px";const d=`
77
+ `,this.isCollapsed&&a.classList.add("rotated"),n.appendChild(a);const o=document.createElement("div");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");const l=()=>{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("aria-expanded",(!this.isCollapsed).toString())};if(e.onclick=l,e.onkeydown=c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),l())},Object.keys(this.settings).length>0){for(const c in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,c)){const d=this.settings[c];p(d)&&typeof d.setNestingLevel=="function"&&d.setNestingLevel(this.nestingLevel+1);const u=d.draw();p(d)&&d.deleteItemCfg&&this.addDeleteButtonToElement(u,c,d),o.appendChild(u)}}else{const c=document.createElement("div");c.className="setting-group-empty",c.textContent="No settings in this group",o.appendChild(c)}if(this.addItemCfg){const c=document.createElement("button");c.type="button",c.className="sg-add-button-bottom",c.style.marginTop="8px";const d=`
78
78
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none"
79
79
  xmlns="http://www.w3.org/2000/svg">
80
80
  <path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
81
81
  stroke-width="1.5" stroke-linecap="round"/>
82
- </svg>`;h.innerHTML=`${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,h.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault();const M=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),R=this.addItemCfg.createItem(M),F=`${this.addItemCfg.keyPrefix}${M}`;this.addSetting(F,R)}),o.appendChild(h)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(o),this.elementRef=t,N.trackElement(t),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(t){try{const e=JSON.parse(t);let i=e;const s=Object.keys(this.settings),n=Object.keys(e);if(!s.some(o=>n.includes(o))&&n.length===1){const o=n[0];i=e[o]}this.setValue(i)}catch(e){throw console.error("Invalid JSON provided to setJson:",e),new Error("Invalid JSON format")}}};k.hiddenElements=new Set;let v=k;function _(c){return new I(c)}class I extends v{constructor(t){super(t);const e=Object.keys(this.settings)[0];this.activeTabId=e||""}getActiveTabId(){return this.activeTabId}switchToTab(t){this.settings[t]&&(this.activeTabId=t,this.updateTabUI())}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(e=>{e.getAttribute("data-tab-id")===this.activeTabId?e.classList.add("active"):e.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([e,i])=>{e===this.activeTabId?i.classList.add("active"):i.classList.remove("active")})}draw(){const t=super.draw();t.classList.add("tabs-settings-container");const e=t.querySelector(".setting-group-content");if(!e)return t;e.innerHTML="";const i=document.createElement("div");i.className="tabs-title";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="tabs-header",this.tabsContainer=n;const a=document.createElement("div");if(a.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((o,l)=>{const r=document.createElement("button");r.className="tab-button",r.type="button",r.setAttribute("data-tab-id",o),r.textContent=o,r.addEventListener("click",()=>this.switchToTab(o)),n.appendChild(r);const h=document.createElement("div");h.className="tab-panel",this.contentContainers[o]=h;const d=this.settings[o];d&&(p(d)&&typeof d.setNestingLevel=="function"&&d.setNestingLevel(this.getNestingLevel()+1),h.appendChild(d.draw())),a.appendChild(h),l===0&&!this.activeTabId&&(this.activeTabId=o)}),e.appendChild(i),e.appendChild(n),e.appendChild(a),!this.activeTabId){const o=Object.keys(this.settings)[0];this.activeTabId=o||""}return this.updateTabUI(),t}}function H(c){return new v(c)}function J(c){return c}class T extends g{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 U="<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 m extends T{constructor(t){super({...t,icon:t.icon||U,title:t.title||"Color",default:t.default?m.normalizeColorValue(t.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=t.detectChange}static normalizeColorValue(t){return t.startsWith("#")?m.normalizeHexValue(t):t.includes(",")?m.rgbToHexStatic(t):m.normalizeHexValue(t)}static normalizeHexValue(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length!==6?(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(t)?`#${t.toLowerCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000")}static rgbToHexStatic(t){const e=t.split(",").map(h=>parseInt(h.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "#000000"`),"#000000";const[i,s,n]=e,a=Math.max(0,Math.min(255,i)),o=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n)),r=h=>{const d=h.toString(16);return d.length===1?"0"+d:d};return`#${r(a)}${r(o)}${r(l)}`}setValue(t){if(t===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof t=="string"){const e=m.normalizeColorValue(t);this.value=e,this.colorInputEl&&(this.colorInputEl.value=e),this.textInputEl&&(this.textInputEl.value=e),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}else this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000")}hexToRgb(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}draw(){const t=document.createElement("div");if(t.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const l=document.createElement("div");if(l.className="icon-container",this.props.icon){const r=document.createElement("span");r.className="input-icon",r.innerHTML=this.props.icon,l.appendChild(r)}if(this.props.title){const r=document.createElement("span");r.className="input-label",r.textContent=this.props.title,l.appendChild(r)}t.appendChild(l)}const e=document.createElement("div");e.className="color-input-wrapper";const i=l=>{const r=l.value.trim();if(!r)return e.classList.remove("error"),!0;const d=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r);return d?e.classList.remove("error"):e.classList.add("error"),d},s=document.createElement("input");s.type="color",s.className="color-picker",s.value=this.value||"#000000",s.setAttribute("aria-label","Choose color"),s.setAttribute("title","Click to open color picker"),this.colorInputEl=s;const n=document.createElement("div");n.className="color-preview";const a=this.value||"#000000";n.style.backgroundColor=a;const o=document.createElement("input");return o.type="text",o.className="color-text-input",o.value=this.value||"",o.placeholder="#000000",o.setAttribute("pattern","#[0-9A-Fa-f]{6}"),o.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),o.setAttribute("aria-label","Hex color value"),o.setAttribute("maxlength","7"),this.textInputEl=o,this.textInputEl.addEventListener("input",l=>{var h,d;let r=l.target.value.trim();if(this.textInputEl&&i(this.textInputEl)){const u=m.normalizeColorValue(r);this.value=u,(h=this.onChange)==null||h.call(this,u),(d=this.detectChange)==null||d.call(this,u),this.colorInputEl&&(this.colorInputEl.value=u),n.style.backgroundColor=u}}),this.colorInputEl.addEventListener("input",l=>{var d,u;const r=l.target.value,h=m.normalizeColorValue(r);this.value=h,(d=this.onChange)==null||d.call(this,h),(u=this.detectChange)==null||u.call(this,h),this.textInputEl&&(this.textInputEl.value=h),n.style.backgroundColor=h,e.classList.remove("error")}),this.colorInputEl.addEventListener("change",l=>{var d,u;const r=l.target.value,h=m.normalizeColorValue(r);this.value=h,(d=this.onChange)==null||d.call(this,h),(u=this.detectChange)==null||u.call(this,h),this.textInputEl&&(this.textInputEl.value=h),n.style.backgroundColor=h}),e.appendChild(s),e.appendChild(n),e.appendChild(o),t.appendChild(e),this.element=t,t}getElement(){return this.element}getNormalizedValue(){return this.value?m.normalizeColorValue(this.value):"#000000"}isValidHex(){return this.value?/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(this.value):!1}toRgb(){return this.isValidHex()?this.hexToRgb(this.value):"0, 0, 0"}}const q=`
82
+ </svg>`;c.innerHTML=`${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,c.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault();const M=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),R=this.addItemCfg.createItem(M),F=`${this.addItemCfg.keyPrefix}${M}`;this.addSetting(F,R)}),o.appendChild(c)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(o),this.elementRef=t,N.trackElement(t),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(t){try{const e=JSON.parse(t);let i=e;const s=Object.keys(this.settings),n=Object.keys(e);if(!s.some(o=>n.includes(o))&&n.length===1){const o=n[0];i=e[o]}this.setValue(i)}catch(e){throw console.error("Invalid JSON provided to setJson:",e),new Error("Invalid JSON format")}}};k.hiddenElements=new Set;let v=k;function _(h){return new I(h)}class I extends v{constructor(t){super(t);const e=Object.keys(this.settings)[0];this.activeTabId=e||""}getActiveTabId(){return this.activeTabId}switchToTab(t){this.settings[t]&&(this.activeTabId=t,this.updateTabUI())}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(e=>{e.getAttribute("data-tab-id")===this.activeTabId?e.classList.add("active"):e.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([e,i])=>{e===this.activeTabId?i.classList.add("active"):i.classList.remove("active")})}draw(){const t=super.draw();t.classList.add("tabs-settings-container");const e=t.querySelector(".setting-group-content");if(!e)return t;e.innerHTML="";const i=document.createElement("div");i.className="tabs-title";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="tabs-header",this.tabsContainer=n;const a=document.createElement("div");if(a.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((o,l)=>{const r=document.createElement("button");r.className="tab-button",r.type="button",r.setAttribute("data-tab-id",o),r.textContent=o,r.addEventListener("click",()=>this.switchToTab(o)),n.appendChild(r);const c=document.createElement("div");c.className="tab-panel",this.contentContainers[o]=c;const d=this.settings[o];d&&(p(d)&&typeof d.setNestingLevel=="function"&&d.setNestingLevel(this.getNestingLevel()+1),c.appendChild(d.draw())),a.appendChild(c),l===0&&!this.activeTabId&&(this.activeTabId=o)}),e.appendChild(i),e.appendChild(n),e.appendChild(a),!this.activeTabId){const o=Object.keys(this.settings)[0];this.activeTabId=o||""}return this.updateTabUI(),t}}function H(h){return new v(h)}function J(h){return h}class T extends g{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 U="<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 m extends T{constructor(t){super({...t,icon:t.icon||U,title:t.title||"Color",default:t.default?m.normalizeColorValue(t.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=t.detectChange}static normalizeColorValue(t){return t.startsWith("#")?m.normalizeHexValue(t):t.includes(",")?m.rgbToHexStatic(t):m.normalizeHexValue(t)}static normalizeHexValue(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length!==6?(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(t)?`#${t.toLowerCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000")}static rgbToHexStatic(t){const e=t.split(",").map(c=>parseInt(c.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "#000000"`),"#000000";const[i,s,n]=e,a=Math.max(0,Math.min(255,i)),o=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n)),r=c=>{const d=c.toString(16);return d.length===1?"0"+d:d};return`#${r(a)}${r(o)}${r(l)}`}setValue(t){if(t===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof t=="string"){const e=m.normalizeColorValue(t);this.value=e,this.colorInputEl&&(this.colorInputEl.value=e),this.textInputEl&&(this.textInputEl.value=e),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}else this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000")}hexToRgb(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}draw(){const t=document.createElement("div");if(t.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const l=document.createElement("div");if(l.className="icon-container",this.props.icon){const r=document.createElement("span");r.className="input-icon",r.innerHTML=this.props.icon,l.appendChild(r)}if(this.props.title){const r=document.createElement("span");r.className="input-label",r.textContent=this.props.title,l.appendChild(r)}t.appendChild(l)}const e=document.createElement("div");e.className="color-input-wrapper";const i=l=>{const r=l.value.trim();if(!r)return e.classList.remove("error"),!0;const d=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r);return d?e.classList.remove("error"):e.classList.add("error"),d},s=document.createElement("input");s.type="color",s.className="color-picker",s.value=this.value||"#000000",s.setAttribute("aria-label","Choose color"),s.setAttribute("title","Click to open color picker"),this.colorInputEl=s;const n=document.createElement("div");n.className="color-preview";const a=this.value||"#000000";n.style.backgroundColor=a;const o=document.createElement("input");return o.type="text",o.className="color-text-input",o.value=this.value||"",o.placeholder="#000000",o.setAttribute("pattern","#[0-9A-Fa-f]{6}"),o.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),o.setAttribute("aria-label","Hex color value"),o.setAttribute("maxlength","7"),this.textInputEl=o,this.textInputEl.addEventListener("input",l=>{var c,d;let r=l.target.value.trim();if(this.textInputEl&&i(this.textInputEl)){const u=m.normalizeColorValue(r);this.value=u,(c=this.onChange)==null||c.call(this,u),(d=this.detectChange)==null||d.call(this,u),this.colorInputEl&&(this.colorInputEl.value=u),n.style.backgroundColor=u}}),this.colorInputEl.addEventListener("input",l=>{var d,u;const r=l.target.value,c=m.normalizeColorValue(r);this.value=c,(d=this.onChange)==null||d.call(this,c),(u=this.detectChange)==null||u.call(this,c),this.textInputEl&&(this.textInputEl.value=c),n.style.backgroundColor=c,e.classList.remove("error")}),this.colorInputEl.addEventListener("change",l=>{var d,u;const r=l.target.value,c=m.normalizeColorValue(r);this.value=c,(d=this.onChange)==null||d.call(this,c),(u=this.detectChange)==null||u.call(this,c),this.textInputEl&&(this.textInputEl.value=c),n.style.backgroundColor=c}),e.appendChild(s),e.appendChild(n),e.appendChild(o),t.appendChild(e),this.element=t,t}getElement(){return this.element}getNormalizedValue(){return this.value?m.normalizeColorValue(this.value):"#000000"}isValidHex(){return this.value?/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(this.value):!1}toRgb(){return this.isValidHex()?this.hexToRgb(this.value):"0, 0, 0"}}const q=`
83
83
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
84
84
  <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"/>
85
85
  <path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
@@ -92,7 +92,7 @@
92
92
  <svg xmlns="http://www.w3.org/2000/svg" class="svg-select" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down">
93
93
  <polyline points="6 9 12 15 18 9"></polyline>
94
94
  </svg>
95
- `;class L extends g{constructor(t={}){if(super(t),this.inputType="select",this._options=[],this.isOpen=!1,this.selectedOptionIndex=null,this.optionsListEl=null,this.svgContainer=null,this.buttonEl=null,this.isLoading=!1,this.container=null,this.clickOutsideListener=null,this.resizeListener=null,t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync&&(this.isLoading=!0),this.value!==void 0){const e=this._options.findIndex(i=>i.value===this.value);e>=0&&(this.selectedOptionIndex=e)}}setValue(t){super.setValue(t);const e=this._options.findIndex(i=>i.value===t);e>=0?this.selectedOptionIndex=e:this.selectedOptionIndex=null,this.updateButtonText()}createOption(t,e){const i=document.createElement("li");return i.classList.add("select-option"),i.textContent=t.name,i.dataset.index=String(e),this.selectedOptionIndex===e&&i.classList.add("selected"),i}draw(){const t=document.createElement("div");if(t.classList.add("select-container"),this.container=t,this.props.icon||this.props.title){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const a=this.createIcon(this.props.icon);n.appendChild(a)}if(this.props.title){const a=this.createLabel(this.props.title);n.appendChild(a)}t.appendChild(n)}else{const n=document.createElement("div");t.appendChild(n)}const e=document.createElement("div");e.classList.add("select-button"),this.isLoading?e.classList.add("loading"):e.textContent=this.selectedOptionIndex!==null?this._options[this.selectedOptionIndex].name:this.props.placeholder||"Select an option",e.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,this.isOpen?this.checkDropdownPosition():this.cleanupDropdownPosition(),(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},t.appendChild(e),this.buttonEl=e;const i=document.createElement("ul");i.classList.add("select-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectOption(l,a,e),i.appendChild(o)}),document.body.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=X,t.appendChild(s),this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{this._options.push(...n),this.isLoading=!1,this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText("Failed to load options")})),this.clickOutsideListener&&document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=n=>{var a,o;this.isOpen&&!t.contains(n.target)&&(this.isOpen=!1,(a=this.optionsListEl)==null||a.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"),this.cleanupDropdownPosition())},document.addEventListener("click",this.clickOutsideListener),this.resizeListener&&window.removeEventListener("resize",this.resizeListener),this.resizeListener=()=>{this.isOpen&&this.checkDropdownPosition()},window.addEventListener("resize",this.resizeListener),t}checkDropdownPosition(){if(!this.optionsListEl||!this.buttonEl||!this.container)return;const t=this.buttonEl.getBoundingClientRect();this.optionsListEl.classList.remove("dropdown-up"),this.optionsListEl.style.position="fixed",this.optionsListEl.style.top=`${t.bottom+2}px`,this.optionsListEl.style.bottom="auto",this.optionsListEl.style.left=`${t.left}px`,this.optionsListEl.style.right="auto",this.optionsListEl.style.width=`${t.width}px`;const e=Math.min(this._options.length*40+12,280);if(window.innerHeight-t.bottom<e){const s=Math.max(10,window.innerHeight-e-10);this.optionsListEl.style.top=`${s}px`}}selectOption(t,e,i){var n,a,o;const s=this._options[e];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.cleanupDropdownPosition(),this.optionsListEl&&this.optionsListEl.querySelectorAll(".select-option").forEach((r,h)=>{h===e?r.classList.add("selected"):r.classList.remove("selected")}))}cleanupDropdownPosition(){this.optionsListEl&&(this.optionsListEl.style.position="",this.optionsListEl.style.top="",this.optionsListEl.style.bottom="",this.optionsListEl.style.left="",this.optionsListEl.style.right="",this.optionsListEl.style.width="")}updateOptionsList(){if(this.optionsListEl){if(this.optionsListEl.innerHTML="",this._options.length===0){const t=document.createElement("li");t.classList.add("select-option","empty-message"),t.textContent="No options available",this.optionsListEl.appendChild(t);return}this._options.forEach((t,e)=>{const i=this.createOption(t,e);i.onclick=s=>{this.buttonEl&&this.selectOption(s,e,this.buttonEl)},this.optionsListEl.appendChild(i)})}}updateButtonText(t){if(!this.buttonEl)return;if(this.isLoading){this.buttonEl.classList.add("loading"),this.buttonEl.textContent=this.props.loadingText||"Loading options...";return}this.buttonEl.classList.remove("loading","error");let e;t?((t.includes("Failed")||t.includes("Error"))&&this.buttonEl.classList.add("error"),e=t):this.selectedOptionIndex!==null&&this._options[this.selectedOptionIndex]?e=this._options[this.selectedOptionIndex].name:e=this.props.placeholder||"Select an option",this.buttonEl.textContent=e}destroy(){this.clickOutsideListener&&(document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=null),this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null),this.cleanupDropdownPosition(),this.optionsListEl&&this.optionsListEl.parentNode&&this.optionsListEl.parentNode.removeChild(this.optionsListEl),super.destroy()}}class B extends g{constructor(t={}){super(t),this.inputType="button",this.value||(this.value="center")}draw(){const t=document.createElement("div");t.className="align-setting-wrapper";const e=document.createElement("label");e.className="align-setting-label",e.textContent=this.title||"Align",t.appendChild(e);const i=document.createElement("div");return i.className="align-options-container",[{name:"left",icon:`
95
+ `;class L extends g{constructor(t={}){if(super(t),this.inputType="select",this._options=[],this.isOpen=!1,this.selectedOptionIndex=null,this.optionsListEl=null,this.svgContainer=null,this.buttonEl=null,this.isLoading=!1,this.container=null,this.clickOutsideListener=null,this.resizeListener=null,t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync&&(this.isLoading=!0),this.value!==void 0){const e=this._options.findIndex(i=>i.value===this.value);e>=0&&(this.selectedOptionIndex=e)}}setValue(t){super.setValue(t);const e=this._options.findIndex(i=>i.value===t);e>=0?this.selectedOptionIndex=e:this.selectedOptionIndex=null,this.updateButtonText()}createOption(t,e){const i=document.createElement("li");return i.classList.add("select-option"),i.textContent=t.name,i.dataset.index=String(e),this.selectedOptionIndex===e&&i.classList.add("selected"),i}draw(){const t=document.createElement("div");if(t.classList.add("select-container"),this.container=t,this.props.icon||this.props.title){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const a=this.createIcon(this.props.icon);n.appendChild(a)}if(this.props.title){const a=this.createLabel(this.props.title);n.appendChild(a)}t.appendChild(n)}else{const n=document.createElement("div");t.appendChild(n)}const e=document.createElement("div");e.classList.add("select-button"),this.isLoading?e.classList.add("loading"):e.textContent=this.selectedOptionIndex!==null?this._options[this.selectedOptionIndex].name:this.props.placeholder||"Select an option",e.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,this.isOpen?this.checkDropdownPosition():this.cleanupDropdownPosition(),(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},t.appendChild(e),this.buttonEl=e;const i=document.createElement("ul");i.classList.add("select-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectOption(l,a,e),i.appendChild(o)}),document.body.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=X,t.appendChild(s),this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{this._options.push(...n),this.isLoading=!1,this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText("Failed to load options")})),this.clickOutsideListener&&document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=n=>{var a,o;this.isOpen&&!t.contains(n.target)&&(this.isOpen=!1,(a=this.optionsListEl)==null||a.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"),this.cleanupDropdownPosition())},document.addEventListener("click",this.clickOutsideListener),this.resizeListener&&window.removeEventListener("resize",this.resizeListener),this.resizeListener=()=>{this.isOpen&&this.checkDropdownPosition()},window.addEventListener("resize",this.resizeListener),t}checkDropdownPosition(){if(!this.optionsListEl||!this.buttonEl||!this.container)return;const t=this.buttonEl.getBoundingClientRect();this.optionsListEl.classList.remove("dropdown-up"),this.optionsListEl.style.position="fixed",this.optionsListEl.style.top=`${t.bottom+2}px`,this.optionsListEl.style.bottom="auto",this.optionsListEl.style.left=`${t.left}px`,this.optionsListEl.style.right="auto",this.optionsListEl.style.width=`${t.width}px`;const e=Math.min(this._options.length*40+12,280);if(window.innerHeight-t.bottom<e){const s=Math.max(10,window.innerHeight-e-10);this.optionsListEl.style.top=`${s}px`}}selectOption(t,e,i){var n,a,o;const s=this._options[e];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.cleanupDropdownPosition(),this.optionsListEl&&this.optionsListEl.querySelectorAll(".select-option").forEach((r,c)=>{c===e?r.classList.add("selected"):r.classList.remove("selected")}))}cleanupDropdownPosition(){this.optionsListEl&&(this.optionsListEl.style.position="",this.optionsListEl.style.top="",this.optionsListEl.style.bottom="",this.optionsListEl.style.left="",this.optionsListEl.style.right="",this.optionsListEl.style.width="")}updateOptionsList(){if(this.optionsListEl){if(this.optionsListEl.innerHTML="",this._options.length===0){const t=document.createElement("li");t.classList.add("select-option","empty-message"),t.textContent="No options available",this.optionsListEl.appendChild(t);return}this._options.forEach((t,e)=>{const i=this.createOption(t,e);i.onclick=s=>{this.buttonEl&&this.selectOption(s,e,this.buttonEl)},this.optionsListEl.appendChild(i)})}}updateButtonText(t){if(!this.buttonEl)return;if(this.isLoading){this.buttonEl.classList.add("loading"),this.buttonEl.textContent=this.props.loadingText||"Loading options...";return}this.buttonEl.classList.remove("loading","error");let e;t?((t.includes("Failed")||t.includes("Error"))&&this.buttonEl.classList.add("error"),e=t):this.selectedOptionIndex!==null&&this._options[this.selectedOptionIndex]?e=this._options[this.selectedOptionIndex].name:e=this.props.placeholder||"Select an option",this.buttonEl.textContent=e}destroy(){this.clickOutsideListener&&(document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=null),this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null),this.cleanupDropdownPosition(),this.optionsListEl&&this.optionsListEl.parentNode&&this.optionsListEl.parentNode.removeChild(this.optionsListEl),super.destroy()}}class B extends g{constructor(t={}){super(t),this.inputType="button",this.value||(this.value="center")}draw(){const t=document.createElement("div");t.className="align-setting-wrapper";const e=document.createElement("label");e.className="align-setting-label",e.textContent=this.title||"Align",t.appendChild(e);const i=document.createElement("div");return i.className="align-options-container",[{name:"left",icon:`
96
96
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
97
97
  <path d="M10.5 7.5C11.1989 7.5 11.5484 7.5 11.824 7.38582C12.1916 7.23358 12.4836 6.94157 12.6358 6.57402C12.75 6.29837 12.75 5.94891 12.75 5.25C12.75 4.55109 12.75 4.20163 12.6358 3.92598C12.4836 3.55843 12.1916 3.26642 11.824 3.11418C11.5484 3 11.1989 3 10.5 3L4.5 3C3.80109 3 3.45163 3 3.17598 3.11418C2.80843 3.26642 2.51642 3.55843 2.36418 3.92597C2.25 4.20163 2.25 4.55109 2.25 5.25C2.25 5.94891 2.25 6.29837 2.36418 6.57402C2.51642 6.94157 2.80843 7.23358 3.17598 7.38582C3.45163 7.5 3.80109 7.5 4.5 7.5L10.5 7.5Z"
98
98
  stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
@@ -113,7 +113,7 @@
113
113
  <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"
114
114
  stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
115
115
  </svg>
116
- `}].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 g{constructor(t){super(t),this.inputType="button",this.bgWithAlpha="rgba(145, 158, 171, 0.08)"}draw(){const t=document.createElement("button");t.className="button-setting "+(this.props.className||""),t.textContent=this.props.label,t.style.borderColor=this.props.borderColor||"rgba(145, 158, 171, 0.32)";const e=this.props.backgroundColor||"rgba(0,0,0,0)",i=this.props.textColor||"black";t.style.backgroundColor=e,t.style.color=i;let s=e;const n=e.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i);if(n){let o=+n[1],l=+n[2],r=+n[3],h=+n[4];h>=1?(o=Math.round(o*.9),l=Math.round(l*.9),r=Math.round(r*.9)):h=Math.min(1,h+.12),s=`rgba(${o},${l},${r},${h})`}t.addEventListener("mouseenter",()=>{console.log("hoverBg",s),t.style.setProperty("background-color",s,"important")}),t.addEventListener("mouseleave",()=>{t.style.setProperty("background-color",e,"important")}),t.addEventListener("click",()=>{var o,l;return(l=(o=this.props).onClick)==null?void 0:l.call(o)});const a=document.createElement("div");return a.className="button-setting-wrapper "+(this.props.wrapperClassName||""),a.appendChild(t),a}}class Y extends g{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 f({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:tt}),this.heightSetting=new f({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:et}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(t){if(!this.isUpdating&&!(isNaN(t)||t<0)){t=Math.max(this.minWidth,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)||t<0)){t=Math.max(this.minHeight,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")),t.style.transform="scale(0.9)",setTimeout(()=>{t.style.transform="scale(1)"},100)}getLockSVG(t){return t?`
116
+ `}].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 g{constructor(t){super(t),this.inputType="button",this.bgWithAlpha="rgba(145, 158, 171, 0.08)"}draw(){const t=document.createElement("button");t.className="button-setting "+(this.props.className||""),t.textContent=this.props.label,t.style.borderColor=this.props.borderColor||"rgba(145, 158, 171, 0.32)";const e=this.props.backgroundColor||"rgba(0,0,0,0)",i=this.props.textColor||"black";t.style.backgroundColor=e,t.style.color=i;let s=e;const n=e.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i);if(n){let o=+n[1],l=+n[2],r=+n[3],c=+n[4];c>=1?(o=Math.round(o*.9),l=Math.round(l*.9),r=Math.round(r*.9)):c=Math.min(1,c+.12),s=`rgba(${o},${l},${r},${c})`}t.addEventListener("mouseenter",()=>{console.log("hoverBg",s),t.style.setProperty("background-color",s,"important")}),t.addEventListener("mouseleave",()=>{t.style.setProperty("background-color",e,"important")}),t.addEventListener("click",()=>{var o,l;return(l=(o=this.props).onClick)==null?void 0:l.call(o)});const a=document.createElement("div");return a.className="button-setting-wrapper "+(this.props.wrapperClassName||""),a.appendChild(t),a}}class Y extends g{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 f({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:tt}),this.heightSetting=new f({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:et}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(t){if(!this.isUpdating&&!(isNaN(t)||t<0)){t=Math.max(this.minWidth,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)||t<0)){t=Math.max(this.minHeight,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")),t.style.transform="scale(0.9)",setTimeout(()=>{t.style.transform="scale(1)"},100)}getLockSVG(t){return t?`
117
117
  <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
118
118
  <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"/>
119
119
  </svg>`:`
@@ -172,12 +172,12 @@
172
172
  <svg xmlns="http://www.w3.org/2000/svg" class="svg-select-api" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down">
173
173
  <polyline points="6 9 12 15 18 9"></polyline>
174
174
  </svg>
175
- `;class ht extends g{constructor(t={}){if(super(t),this.inputType="select",this._options=[],this.isOpen=!1,this.selectedOptionIndex=null,this.optionsListEl=null,this.svgContainer=null,this.buttonEl=null,this.isLoading=!1,this.container=null,this.hasInitializedOptions=!1,this.selectedOptionIndex=null,t.default!==void 0&&(this.value=t.default),this.initializeOptions(t),!t.getOptionsAsync&&this.value!==void 0){const e=this._options.findIndex(i=>JSON.stringify(i.value)===JSON.stringify(this.value));e!==-1&&(this.selectedOptionIndex=e)}t.onChange&&this.setOnChange(t.onChange),t.detectChange&&(this.detectChangeCallback=t.detectChange)}initializeOptions(t){this.hasInitializedOptions&&!t.getOptionsAsync||(this._options=[],t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync?this.isLoading=!0:this.hasInitializedOptions=!0)}createOption(t,e){const i=document.createElement("li");i.classList.add("select-api-option"),i.textContent=t.name,i.dataset.index=String(e);const s=document.createElement("input");return s.type="radio",s.classList.add("select-api-radio"),s.name="select-api-radio-group",i.appendChild(s),this.selectedOptionIndex===e&&(s.checked=!0),i}draw(){const t=document.createElement("div");t.classList.add("select-api-container"),this.container=t;const e=document.createElement("div");if(e.classList.add("select-api-button"),this.props.title){e.classList.add("has-label");const n=document.createElement("div");n.className="select-label",n.textContent=this.props.title,e.appendChild(n);const a=document.createElement("span");if(a.className="select-value",this.isLoading)a.textContent=this.props.loadingText||"Loading options...";else{const o=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,l=o&&typeof o.name=="string"?o.name:"Select an option";a.textContent=l}e.appendChild(a)}else{const n=document.createElement("span");if(this.isLoading)n.textContent=this.props.loadingText||"Loading options...";else{const a=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,o=a&&typeof a.name=="string"?a.name:"Select an option";n.textContent=o}e.appendChild(n)}e.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},t.appendChild(e),this.buttonEl=e;const i=document.createElement("ul");i.classList.add("select-api-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectApiOption(l,a,e),i.appendChild(o)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=ct,t.appendChild(s),s.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&!this.hasInitializedOptions?(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const a=new Set(this._options.map(l=>JSON.stringify(l.value))),o=n.filter(l=>!a.has(JSON.stringify(l.value)));if(this._options.push(...o),this.isLoading=!1,this.hasInitializedOptions=!0,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})):this.props.getOptionsAsync&&this._options.length<=1&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const a=new Set(this._options.map(l=>JSON.stringify(l.value))),o=n.filter(l=>!a.has(JSON.stringify(l.value)));if(this._options.push(...o),this.isLoading=!1,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})),t}getJson(t=!0){return JSON.stringify(t?{}:{value:this.value},null,2)}selectApiOption(t,e,i){var l,r,h,d;const s=t.target,n=s.querySelector(".select-api-radio")||((l=s.closest(".select-api-option"))==null?void 0:l.querySelector(".select-api-radio"));n&&(n.checked=!0),this.selectedOptionIndex=e;const a=this._options[e].value;this.value=a;const o=i.querySelector(".select-value");if(o)o.textContent=this._options[e].name;else{const u=i.firstChild;u&&u.tagName==="SPAN"&&(u.textContent=this._options[e].name)}this.isOpen=!1,(r=this.optionsListEl)==null||r.classList.remove("open"),(h=this.svgContainer)==null||h.classList.remove("open"),(d=this.onChange)==null||d.call(this,a),this.detectChangeCallback&&this.detectChangeCallback(a)}updateOptionsList(){!this.optionsListEl||!this.buttonEl||(this.optionsListEl.innerHTML="",this._options.forEach((t,e)=>{var s;const i=this.createOption(t,e);i.onclick=n=>{this.buttonEl&&this.selectApiOption(n,e,this.buttonEl)},(s=this.optionsListEl)==null||s.appendChild(i)}))}updateButtonText(t,e=!1){if(!this.buttonEl)return;const i=this.buttonEl.querySelector(".select-value")||this.buttonEl.firstChild;if(i)if(e)i.textContent=t||"Error",this.buttonEl.classList.add("error"),this.buttonEl.setAttribute("disabled","true"),this.optionsListEl&&this.optionsListEl.classList.remove("open"),this.svgContainer&&(this.svgContainer.style.display="none");else if(this.isLoading)i.textContent=this.props.loadingText||"Loading options...",this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="");else{const s=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,n=s&&typeof s.name=="string"?s.name:"Select an option";i.textContent=t||n,this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="")}}setDetectChange(t){this.detectChangeCallback=t}setValue(t){this.value=t,this.selectedOptionIndex=this._options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t)),this.updateButtonText()}}class dt extends g{constructor(t){var e,i;super(t),this.inputType="text",this.value=t.default??((i=(e=t.options)==null?void 0:e[0])==null?void 0:i.value)??"",this.detectChangeCallback=t.detectChange}draw(){var a,o;const t=document.createElement("div");t.className="toggle-setting-container",this.props.icon&&t.classList.add("toggle-with-icon");const e=document.createElement("div");if(e.className="toggle-label",this.props.icon){const l=document.createElement("span");l.className="toggle-icon",l.innerHTML=this.props.icon,e.appendChild(l)}if(this.props.title){const l=document.createElement("span");l.textContent=this.props.title,e.appendChild(l)}t.appendChild(e);const i=document.createElement("label");i.className="toggle-switch";const s=document.createElement("input");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",()=>{var r,h;const l=((h=(r=this.props.options)==null?void 0:r.find(d=>d.status===s.checked))==null?void 0:h.value)??"";this.value=l,this.onChange&&this.onChange(this.value),this.detectChangeCallback&&this.detectChangeCallback(this.value)});const n=document.createElement("span");if(n.className="toggle-slider",this.props.activeColor||this.props.inactiveColor){const l=document.createElement("style"),r=this.props.activeColor||"#4CAF50",h=this.props.inactiveColor||"#ccc";l.textContent=`
175
+ `;class ht extends g{constructor(t={}){if(super(t),this.inputType="select",this._options=[],this.isOpen=!1,this.selectedOptionIndex=null,this.optionsListEl=null,this.svgContainer=null,this.buttonEl=null,this.isLoading=!1,this.container=null,this.hasInitializedOptions=!1,this.selectedOptionIndex=null,t.default!==void 0&&(this.value=t.default),this.initializeOptions(t),!t.getOptionsAsync&&this.value!==void 0){const e=this._options.findIndex(i=>JSON.stringify(i.value)===JSON.stringify(this.value));e!==-1&&(this.selectedOptionIndex=e)}t.onChange&&this.setOnChange(t.onChange),t.detectChange&&(this.detectChangeCallback=t.detectChange)}initializeOptions(t){this.hasInitializedOptions&&!t.getOptionsAsync||(this._options=[],t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync?this.isLoading=!0:this.hasInitializedOptions=!0)}createOption(t,e){const i=document.createElement("li");i.classList.add("select-api-option"),i.textContent=t.name,i.dataset.index=String(e);const s=document.createElement("input");return s.type="radio",s.classList.add("select-api-radio"),s.name="select-api-radio-group",i.appendChild(s),this.selectedOptionIndex===e&&(s.checked=!0),i}draw(){const t=document.createElement("div");t.classList.add("select-api-container"),this.container=t;const e=document.createElement("div");if(e.classList.add("select-api-button"),this.props.title){e.classList.add("has-label");const n=document.createElement("div");n.className="select-label",n.textContent=this.props.title,e.appendChild(n);const a=document.createElement("span");if(a.className="select-value",this.isLoading)a.textContent=this.props.loadingText||"Loading options...";else{const o=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,l=o&&typeof o.name=="string"?o.name:"Select an option";a.textContent=l}e.appendChild(a)}else{const n=document.createElement("span");if(this.isLoading)n.textContent=this.props.loadingText||"Loading options...";else{const a=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,o=a&&typeof a.name=="string"?a.name:"Select an option";n.textContent=o}e.appendChild(n)}e.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},t.appendChild(e),this.buttonEl=e;const i=document.createElement("ul");i.classList.add("select-api-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectApiOption(l,a,e),i.appendChild(o)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=ct,t.appendChild(s),s.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&!this.hasInitializedOptions?(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const a=new Set(this._options.map(l=>JSON.stringify(l.value))),o=n.filter(l=>!a.has(JSON.stringify(l.value)));if(this._options.push(...o),this.isLoading=!1,this.hasInitializedOptions=!0,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})):this.props.getOptionsAsync&&this._options.length<=1&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const a=new Set(this._options.map(l=>JSON.stringify(l.value))),o=n.filter(l=>!a.has(JSON.stringify(l.value)));if(this._options.push(...o),this.isLoading=!1,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})),t}getJson(t=!0){return JSON.stringify(t?{}:{value:this.value},null,2)}selectApiOption(t,e,i){var l,r,c,d;const s=t.target,n=s.querySelector(".select-api-radio")||((l=s.closest(".select-api-option"))==null?void 0:l.querySelector(".select-api-radio"));n&&(n.checked=!0),this.selectedOptionIndex=e;const a=this._options[e].value;this.value=a;const o=i.querySelector(".select-value");if(o)o.textContent=this._options[e].name;else{const u=i.firstChild;u&&u.tagName==="SPAN"&&(u.textContent=this._options[e].name)}this.isOpen=!1,(r=this.optionsListEl)==null||r.classList.remove("open"),(c=this.svgContainer)==null||c.classList.remove("open"),(d=this.onChange)==null||d.call(this,a),this.detectChangeCallback&&this.detectChangeCallback(a)}updateOptionsList(){!this.optionsListEl||!this.buttonEl||(this.optionsListEl.innerHTML="",this._options.forEach((t,e)=>{var s;const i=this.createOption(t,e);i.onclick=n=>{this.buttonEl&&this.selectApiOption(n,e,this.buttonEl)},(s=this.optionsListEl)==null||s.appendChild(i)}))}updateButtonText(t,e=!1){if(!this.buttonEl)return;const i=this.buttonEl.querySelector(".select-value")||this.buttonEl.firstChild;if(i)if(e)i.textContent=t||"Error",this.buttonEl.classList.add("error"),this.buttonEl.setAttribute("disabled","true"),this.optionsListEl&&this.optionsListEl.classList.remove("open"),this.svgContainer&&(this.svgContainer.style.display="none");else if(this.isLoading)i.textContent=this.props.loadingText||"Loading options...",this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="");else{const s=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,n=s&&typeof s.name=="string"?s.name:"Select an option";i.textContent=t||n,this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="")}}setDetectChange(t){this.detectChangeCallback=t}setValue(t){this.value=t,this.selectedOptionIndex=this._options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t)),this.updateButtonText()}}class dt extends g{constructor(t){var e,i;super(t),this.inputType="text",this.value=t.default??((i=(e=t.options)==null?void 0:e[0])==null?void 0:i.value)??"",this.detectChangeCallback=t.detectChange}draw(){var a,o;const t=document.createElement("div");t.className="toggle-setting-container",this.props.icon&&t.classList.add("toggle-with-icon");const e=document.createElement("div");if(e.className="toggle-label",this.props.icon){const l=document.createElement("span");l.className="toggle-icon",l.innerHTML=this.props.icon,e.appendChild(l)}if(this.props.title){const l=document.createElement("span");l.textContent=this.props.title,e.appendChild(l)}t.appendChild(e);const i=document.createElement("label");i.className="toggle-switch";const s=document.createElement("input");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",()=>{var r,c;const l=((c=(r=this.props.options)==null?void 0:r.find(d=>d.status===s.checked))==null?void 0:c.value)??"";this.value=l,this.onChange&&this.onChange(this.value),this.detectChangeCallback&&this.detectChangeCallback(this.value)});const n=document.createElement("span");if(n.className="toggle-slider",this.props.activeColor||this.props.inactiveColor){const l=document.createElement("style"),r=this.props.activeColor||"#4CAF50",c=this.props.inactiveColor||"#ccc";l.textContent=`
176
176
  .toggle-switch input:checked + .toggle-slider {
177
177
  background-color: ${r};
178
178
  }
179
179
  .toggle-switch .toggle-slider {
180
- background-color: ${h};
180
+ background-color: ${c};
181
181
  }
182
182
  `,document.head.appendChild(l)}return i.appendChild(s),i.appendChild(n),t.appendChild(i),t}setDetectChange(t){this.detectChangeCallback=t}}const ut=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
183
183
  <path d="M13.3334 5.99996H2.66675M13.3334 9.99996H2.66675M5.33341 12.6666V3.33329M10.6667 12.6666V3.33329" stroke="#667085" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
@@ -228,7 +228,7 @@
228
228
  font-weight: ${i};
229
229
  font-size: ${s}px;
230
230
  text-align: ${n};
231
- `}}class E extends g{constructor(t){super({...t,default:t.default!==void 0?t.default:"auto"}),this.inputType="number",this.value=t.default!==void 0?t.default:"auto"}draw(){const t=this.value==="auto"?"text":"number",e=o=>{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",()=>{const l=this.props.minValue??Number.MIN_SAFE_INTEGER,r=this.props.maxValue??Number.MAX_SAFE_INTEGER;let h=Number(o.value);h<l&&(h=l),h>r&&(h=r),o.value=String(h)}))},i=this.createInput({value:this.value,inputType:t,title:this.props.title,icon:this.props.icon,inputClassName:"number-setting-input "+(this.props.inputClassName||""),wrapperClassName:"number-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:e,placeholder:this.value==="auto"?"auto":""});if(!this.props.suffix||this.props.suffix==="none")return i;i.classList.add("suffix-wrapper");const s=i.querySelector("input.number-setting-input");s&&(s.style.paddingRight="35px");const n=document.createElement("span");n.className="suffix-label",n.textContent=this.props.suffix,i.appendChild(n);const a=i.querySelector("input");return a&&(a.oninput=o=>{const l=o.target.value.trim();if(l.toLowerCase()==="auto")this.value="auto";else{const r=Number(l);isNaN(r)||(this.value=r)}this.onChange&&this.onChange(this.value)}),i}}class It extends v{constructor(t){super({title:"Margins",collapsed:t==null?void 0:t.collapsed,settings:{marginTop:new E({title:"Top",icon:Nt,suffix:"px",default:(t==null?void 0:t.marginTop)??"auto"}),marginRight:new E({title:"Right",icon:Ot,suffix:"px",default:(t==null?void 0:t.marginRight)??0}),marginBottom:new E({title:"Bottom",icon:Ht,suffix:"px",default:(t==null?void 0:t.marginBottom)??0}),marginLeft:new E({title:"Left",icon:Tt,suffix:"px",default:(t==null?void 0:t.marginLeft)??0})}})}getCssCode(){const t=typeof this.settings.marginTop.value=="number"?`${this.settings.marginTop.value}px`:this.settings.marginTop.value,e=typeof this.settings.marginRight.value=="number"?`${this.settings.marginRight.value}px`:this.settings.marginRight.value,i=typeof this.settings.marginBottom.value=="number"?`${this.settings.marginBottom.value}px`:this.settings.marginBottom.value,s=typeof this.settings.marginLeft.value=="number"?`${this.settings.marginLeft.value}px`:this.settings.marginLeft.value;return`
231
+ `}}class E extends g{constructor(t){super({...t,default:t.default!==void 0?t.default:"auto"}),this.inputType="number",this.value=t.default!==void 0?t.default:"auto"}draw(){const t=this.value==="auto"?"text":"number",e=o=>{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",()=>{const l=this.props.minValue??Number.MIN_SAFE_INTEGER,r=this.props.maxValue??Number.MAX_SAFE_INTEGER;let c=Number(o.value);c<l&&(c=l),c>r&&(c=r),o.value=String(c)}))},i=this.createInput({value:this.value,inputType:t,title:this.props.title,icon:this.props.icon,inputClassName:"number-setting-input "+(this.props.inputClassName||""),wrapperClassName:"number-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:e,placeholder:this.value==="auto"?"auto":""});if(!this.props.suffix||this.props.suffix==="none")return i;i.classList.add("suffix-wrapper");const s=i.querySelector("input.number-setting-input");s&&(s.style.paddingRight="35px");const n=document.createElement("span");n.className="suffix-label",n.textContent=this.props.suffix,i.appendChild(n);const a=i.querySelector("input");return a&&(a.oninput=o=>{const l=o.target.value.trim();if(l.toLowerCase()==="auto")this.value="auto";else{const r=Number(l);isNaN(r)||(this.value=r)}this.onChange&&this.onChange(this.value)}),i}}class It extends v{constructor(t){super({title:"Margins",collapsed:t==null?void 0:t.collapsed,settings:{marginTop:new E({title:"Top",icon:Nt,suffix:"px",default:(t==null?void 0:t.marginTop)??"auto"}),marginRight:new E({title:"Right",icon:Ot,suffix:"px",default:(t==null?void 0:t.marginRight)??0}),marginBottom:new E({title:"Bottom",icon:Ht,suffix:"px",default:(t==null?void 0:t.marginBottom)??0}),marginLeft:new E({title:"Left",icon:Tt,suffix:"px",default:(t==null?void 0:t.marginLeft)??0})}})}getCssCode(){const t=typeof this.settings.marginTop.value=="number"?`${this.settings.marginTop.value}px`:this.settings.marginTop.value,e=typeof this.settings.marginRight.value=="number"?`${this.settings.marginRight.value}px`:this.settings.marginRight.value,i=typeof this.settings.marginBottom.value=="number"?`${this.settings.marginBottom.value}px`:this.settings.marginBottom.value,s=typeof this.settings.marginLeft.value=="number"?`${this.settings.marginLeft.value}px`:this.settings.marginLeft.value;return`
232
232
  margin-top: ${t};
233
233
  margin-right: ${e};
234
234
  margin-bottom: ${i};
@@ -248,4 +248,4 @@
248
248
  opacity: ${e/100};
249
249
  `:`
250
250
  background-color: ${i};
251
- `}}function Bt(c){return p(c)}function $t(c){return w(c)}exports.AlignSetting=B;exports.AnimationSetting=bt;exports.BackgroundSettingSet=At;exports.BorderSettingSet=Lt;exports.ButtonSetting=Q;exports.ColorSetting=m;exports.ColorWithOpacitySetting=C;exports.DimensionSetting=Y;exports.GapSetting=pt;exports.HeaderTypographySettingSet=Vt;exports.HeightSetting=at;exports.HtmlSetting=Z;exports.MarginBottomSetting=mt;exports.MarginSettingGroup=It;exports.MarginTopSetting=vt;exports.MultiLanguageSetting=Et;exports.NumberSetting=f;exports.OpacitySetting=A;exports.SelectApiSettings=ht;exports.SelectSetting=L;exports.Setting=g;exports.SettingGroup=v;exports.StringSetting=T;exports.TabSettingGroup=I;exports.TabsSettingGroup=I;exports.Toggle=dt;exports.UploadSetting=$;exports.WidthSetting=lt;exports.asSettingGroupWithSettings=J;exports.createSettingGroup=H;exports.createTabSettingGroup=_;exports.isSetting=$t;exports.isSettingChild=D;exports.isSettingGroup=Bt;exports.iterateSettings=x;
251
+ `}}exports.AlignSetting=B;exports.AnimationSetting=bt;exports.BackgroundSettingSet=At;exports.BorderSettingSet=Lt;exports.ButtonSetting=Q;exports.ColorSetting=m;exports.ColorWithOpacitySetting=C;exports.DimensionSetting=Y;exports.GapSetting=pt;exports.HeaderTypographySettingSet=Vt;exports.HeightSetting=at;exports.HtmlSetting=Z;exports.MarginBottomSetting=mt;exports.MarginSettingGroup=It;exports.MarginTopSetting=vt;exports.MultiLanguageSetting=Et;exports.NumberSetting=f;exports.OpacitySetting=A;exports.SelectApiSettings=ht;exports.SelectSetting=L;exports.Setting=g;exports.SettingGroup=v;exports.StringSetting=T;exports.TabSettingGroup=I;exports.TabsSettingGroup=I;exports.Toggle=dt;exports.UploadSetting=$;exports.WidthSetting=lt;exports.asSettingGroupWithSettings=J;exports.createSettingGroup=H;exports.createTabSettingGroup=_;exports.isSetting=w;exports.isSettingChild=D;exports.isSettingGroup=p;exports.iterateSettings=x;
@@ -1,22 +1,22 @@
1
1
  const T = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
2
- let N = (c = 21) => {
3
- let t = "", e = crypto.getRandomValues(new Uint8Array(c |= 0));
4
- for (; c--; )
5
- t += T[e[c] & 63];
2
+ let N = (h = 21) => {
3
+ let t = "", e = crypto.getRandomValues(new Uint8Array(h |= 0));
4
+ for (; h--; )
5
+ t += T[e[h] & 63];
6
6
  return t;
7
7
  };
8
- function A(c) {
9
- let t = 0, e = c.parentElement;
8
+ function A(h) {
9
+ let t = 0, e = h.parentElement;
10
10
  for (; e; )
11
- e.classList.contains("setting-group") && e !== c && t++, e = e.parentElement;
11
+ e.classList.contains("setting-group") && e !== h && t++, e = e.parentElement;
12
12
  return t;
13
13
  }
14
- function b(c, t) {
14
+ function b(h, t) {
15
15
  const e = Math.min(Math.max(t, 0), 5);
16
- c.setAttribute("data-nesting-level", e.toString()), e > 0 ? c.style.setProperty("--visual-indent", `${e * 2}px`) : (c.style.removeProperty("--visual-indent"), c.style.marginLeft = "");
16
+ h.setAttribute("data-nesting-level", e.toString()), e > 0 ? h.style.setProperty("--visual-indent", `${e * 2}px`) : (h.style.removeProperty("--visual-indent"), h.style.marginLeft = "");
17
17
  }
18
- function V(c, t = 0) {
19
- c.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach((i) => {
18
+ function V(h, t = 0) {
19
+ h.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach((i) => {
20
20
  const s = i, n = t + 1;
21
21
  b(s, n), V(s, n);
22
22
  });
@@ -112,20 +112,20 @@ class $ {
112
112
  }
113
113
  }
114
114
  const S = new $();
115
- function x(c) {
116
- if (c === null || typeof c != "object") return c;
117
- if (c instanceof Date) return new Date(c.getTime());
118
- if (c instanceof Array) return c.map((t) => x(t));
119
- if (typeof c == "object") {
115
+ function x(h) {
116
+ if (h === null || typeof h != "object") return h;
117
+ if (h instanceof Date) return new Date(h.getTime());
118
+ if (h instanceof Array) return h.map((t) => x(t));
119
+ if (typeof h == "object") {
120
120
  const t = {};
121
- for (const e in c)
122
- Object.prototype.hasOwnProperty.call(c, e) && (t[e] = x(c[e]));
121
+ for (const e in h)
122
+ Object.prototype.hasOwnProperty.call(h, e) && (t[e] = x(h[e]));
123
123
  return t;
124
124
  }
125
- return c;
125
+ return h;
126
126
  }
127
- function R(c) {
128
- switch (c) {
127
+ function R(h) {
128
+ switch (h) {
129
129
  case "number":
130
130
  return 0;
131
131
  case "text":
@@ -224,19 +224,19 @@ class g {
224
224
  return i.className = "input-icon " + (e || ""), i.innerHTML = t, i;
225
225
  }
226
226
  }
227
- function w(c) {
228
- return c instanceof g;
227
+ function w(h) {
228
+ return h instanceof g;
229
229
  }
230
- function p(c) {
231
- return c instanceof v;
230
+ function p(h) {
231
+ return h instanceof v;
232
232
  }
233
- function ft(c) {
234
- return w(c) || p(c);
233
+ function ft(h) {
234
+ return w(h) || p(h);
235
235
  }
236
- function k(c, t) {
237
- for (const e in c)
238
- if (Object.prototype.hasOwnProperty.call(c, e)) {
239
- const i = c[e];
236
+ function k(h, t) {
237
+ for (const e in h)
238
+ if (Object.prototype.hasOwnProperty.call(h, e)) {
239
+ const i = h[e];
240
240
  t(e, i);
241
241
  }
242
242
  }
@@ -291,7 +291,7 @@ const L = class L {
291
291
  );
292
292
  for (const o of a) {
293
293
  const l = o.id;
294
- if (l && l.includes(e.id)) {
294
+ if (l && "id" in e && typeof e.id == "string" && l.includes(e.id)) {
295
295
  o.remove();
296
296
  break;
297
297
  }
@@ -432,8 +432,8 @@ const L = class L {
432
432
  }
433
433
  const r = a.querySelector(".sg-add-button-bottom");
434
434
  r ? a.insertBefore(o, r) : a.appendChild(o), S.trackElement(o), b(o, this.nestingLevel + 1), V(o, this.nestingLevel + 1);
435
- const h = o.style.display;
436
- o.style.display = "none", o.offsetHeight, o.style.display = h, this.updateNestingStyles();
435
+ const c = o.style.display;
436
+ o.style.display = "none", o.offsetHeight, o.style.display = c, this.updateNestingStyles();
437
437
  }
438
438
  }
439
439
  const i = this.getValues();
@@ -450,9 +450,9 @@ const L = class L {
450
450
  const r = Array.from(
451
451
  t.querySelectorAll(".setting-group-title")
452
452
  );
453
- for (const h of r)
454
- if (h.closest(".setting-group") === t) {
455
- s = h;
453
+ for (const c of r)
454
+ if (c.closest(".setting-group") === t) {
455
+ s = c;
456
456
  break;
457
457
  }
458
458
  s || (s = r[0] ?? null);
@@ -485,8 +485,8 @@ const L = class L {
485
485
  }), a.addEventListener("mouseleave", () => {
486
486
  a.style.backgroundColor = "transparent";
487
487
  }), a.addEventListener("click", (r) => {
488
- r.stopPropagation(), r.preventDefault(), this.showDeleteConfirmation().then((h) => {
489
- h && (i && i.deleteItemCfg ? this.removeSetting(e) : this.removeSetting(e));
488
+ r.stopPropagation(), r.preventDefault(), this.showDeleteConfirmation().then((c) => {
489
+ c && (i && i.deleteItemCfg ? this.removeSetting(e) : this.removeSetting(e));
490
490
  });
491
491
  });
492
492
  const l = n.querySelector(".setting-group-arrow");
@@ -583,10 +583,10 @@ const L = class L {
583
583
  }), e.addEventListener("click", (d) => {
584
584
  d.target === e && (r(), t(!1));
585
585
  });
586
- const h = (d) => {
587
- d.key === "Escape" && (r(), t(!1), document.removeEventListener("keydown", h));
586
+ const c = (d) => {
587
+ d.key === "Escape" && (r(), t(!1), document.removeEventListener("keydown", c));
588
588
  };
589
- document.addEventListener("keydown", h), a.appendChild(o), a.appendChild(l), i.appendChild(s), i.appendChild(n), i.appendChild(a), e.appendChild(i), document.body.appendChild(e), requestAnimationFrame(() => {
589
+ document.addEventListener("keydown", c), a.appendChild(o), a.appendChild(l), i.appendChild(s), i.appendChild(n), i.appendChild(a), e.appendChild(i), document.body.appendChild(e), requestAnimationFrame(() => {
590
590
  e.style.opacity = "1", i.style.transform = "scale(1)";
591
591
  }), setTimeout(() => l.focus(), 100);
592
592
  });
@@ -698,38 +698,38 @@ const L = class L {
698
698
  (!this.isCollapsed).toString()
699
699
  );
700
700
  };
701
- if (e.onclick = l, e.onkeydown = (h) => {
702
- (h.key === "Enter" || h.key === " ") && (h.preventDefault(), l());
701
+ if (e.onclick = l, e.onkeydown = (c) => {
702
+ (c.key === "Enter" || c.key === " ") && (c.preventDefault(), l());
703
703
  }, Object.keys(this.settings).length > 0) {
704
- for (const h in this.settings)
705
- if (Object.prototype.hasOwnProperty.call(this.settings, h)) {
706
- const d = this.settings[h];
704
+ for (const c in this.settings)
705
+ if (Object.prototype.hasOwnProperty.call(this.settings, c)) {
706
+ const d = this.settings[c];
707
707
  p(d) && typeof d.setNestingLevel == "function" && d.setNestingLevel(this.nestingLevel + 1);
708
708
  const u = d.draw();
709
709
  p(d) && d.deleteItemCfg && this.addDeleteButtonToElement(
710
710
  u,
711
- h,
711
+ c,
712
712
  d
713
713
  ), o.appendChild(u);
714
714
  }
715
715
  } else {
716
- const h = document.createElement("div");
717
- h.className = "setting-group-empty", h.textContent = "No settings in this group", o.appendChild(h);
716
+ const c = document.createElement("div");
717
+ c.className = "setting-group-empty", c.textContent = "No settings in this group", o.appendChild(c);
718
718
  }
719
719
  if (this.addItemCfg) {
720
- const h = document.createElement("button");
721
- h.type = "button", h.className = "sg-add-button-bottom", h.style.marginTop = "8px";
720
+ const c = document.createElement("button");
721
+ c.type = "button", c.className = "sg-add-button-bottom", c.style.marginTop = "8px";
722
722
  const d = `
723
723
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none"
724
724
  xmlns="http://www.w3.org/2000/svg">
725
725
  <path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
726
726
  stroke-width="1.5" stroke-linecap="round"/>
727
727
  </svg>`;
728
- h.innerHTML = `${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, h.addEventListener("click", (u) => {
728
+ c.innerHTML = `${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, c.addEventListener("click", (u) => {
729
729
  u.stopPropagation(), u.preventDefault();
730
730
  const y = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), O = this.addItemCfg.createItem(y), H = `${this.addItemCfg.keyPrefix}${y}`;
731
731
  this.addSetting(H, O);
732
- }), o.appendChild(h);
732
+ }), o.appendChild(c);
733
733
  }
734
734
  return e.appendChild(i), e.appendChild(n), t.appendChild(e), t.appendChild(o), this.elementRef = t, S.trackElement(t), setTimeout(() => {
735
735
  this.updateNestingStyles();
@@ -775,8 +775,8 @@ const L = class L {
775
775
  };
776
776
  L.hiddenElements = /* @__PURE__ */ new Set();
777
777
  let v = L;
778
- function vt(c) {
779
- return new F(c);
778
+ function vt(h) {
779
+ return new F(h);
780
780
  }
781
781
  class F extends v {
782
782
  constructor(t) {
@@ -816,12 +816,12 @@ class F extends v {
816
816
  if (a.className = "tab-content", this.contentContainers = {}, Object.keys(this.settings).forEach((o, l) => {
817
817
  const r = document.createElement("button");
818
818
  r.className = "tab-button", r.type = "button", r.setAttribute("data-tab-id", o), r.textContent = o, r.addEventListener("click", () => this.switchToTab(o)), n.appendChild(r);
819
- const h = document.createElement("div");
820
- h.className = "tab-panel", this.contentContainers[o] = h;
819
+ const c = document.createElement("div");
820
+ c.className = "tab-panel", this.contentContainers[o] = c;
821
821
  const d = this.settings[o];
822
- d && (p(d) && typeof d.setNestingLevel == "function" && d.setNestingLevel(this.getNestingLevel() + 1), h.appendChild(
822
+ d && (p(d) && typeof d.setNestingLevel == "function" && d.setNestingLevel(this.getNestingLevel() + 1), c.appendChild(
823
823
  d.draw()
824
- )), a.appendChild(h), l === 0 && !this.activeTabId && (this.activeTabId = o);
824
+ )), a.appendChild(c), l === 0 && !this.activeTabId && (this.activeTabId = o);
825
825
  }), e.appendChild(i), e.appendChild(n), e.appendChild(a), !this.activeTabId) {
826
826
  const o = Object.keys(this.settings)[0];
827
827
  this.activeTabId = o || "";
@@ -829,13 +829,13 @@ class F extends v {
829
829
  return this.updateTabUI(), t;
830
830
  }
831
831
  }
832
- function z(c) {
833
- return new v(c);
832
+ function z(h) {
833
+ return new v(h);
834
834
  }
835
- function Ct(c) {
836
- return c;
835
+ function Ct(h) {
836
+ return h;
837
837
  }
838
- class G extends g {
838
+ class P extends g {
839
839
  constructor(t = {}) {
840
840
  super(t), this.inputType = "text", t.onChange && this.setOnChange(t.onChange);
841
841
  }
@@ -855,12 +855,12 @@ class G extends g {
855
855
  });
856
856
  }
857
857
  }
858
- const P = "<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>";
859
- class m extends G {
858
+ const G = "<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>";
859
+ class m extends P {
860
860
  constructor(t) {
861
861
  super({
862
862
  ...t,
863
- icon: t.icon || P,
863
+ icon: t.icon || G,
864
864
  title: t.title || "Color",
865
865
  default: t.default ? m.normalizeColorValue(t.default) : "#000000"
866
866
  }), this.inputType = "color", this.element = null, this.colorInputEl = null, this.textInputEl = null, this.detectChange = t.detectChange;
@@ -872,11 +872,11 @@ class m extends G {
872
872
  return t = t.replace("#", ""), t.length === 3 && (t = t.split("").map((e) => e + e).join("")), t.length !== 6 ? (console.warn(`Invalid hex value "${t}", using default "#000000"`), "#000000") : /^[0-9A-Fa-f]{6}$/.test(t) ? `#${t.toLowerCase()}` : (console.warn(`Invalid hex value "${t}", using default "#000000"`), "#000000");
873
873
  }
874
874
  static rgbToHexStatic(t) {
875
- const e = t.split(",").map((h) => parseInt(h.trim()));
875
+ const e = t.split(",").map((c) => parseInt(c.trim()));
876
876
  if (e.length !== 3 || e.some(isNaN))
877
877
  return console.warn(`Invalid RGB value "${t}", using default "#000000"`), "#000000";
878
- const [i, s, n] = e, a = Math.max(0, Math.min(255, i)), o = Math.max(0, Math.min(255, s)), l = Math.max(0, Math.min(255, n)), r = (h) => {
879
- const d = h.toString(16);
878
+ const [i, s, n] = e, a = Math.max(0, Math.min(255, i)), o = Math.max(0, Math.min(255, s)), l = Math.max(0, Math.min(255, n)), r = (c) => {
879
+ const d = c.toString(16);
880
880
  return d.length === 1 ? "0" + d : d;
881
881
  };
882
882
  return `#${r(a)}${r(o)}${r(l)}`;
@@ -927,20 +927,20 @@ class m extends G {
927
927
  n.style.backgroundColor = a;
928
928
  const o = document.createElement("input");
929
929
  return o.type = "text", o.className = "color-text-input", o.value = this.value || "", o.placeholder = "#000000", o.setAttribute("pattern", "#[0-9A-Fa-f]{6}"), o.setAttribute("title", "Enter a hex color value (e.g., #ff0000)"), o.setAttribute("aria-label", "Hex color value"), o.setAttribute("maxlength", "7"), this.textInputEl = o, this.textInputEl.addEventListener("input", (l) => {
930
- var h, d;
930
+ var c, d;
931
931
  let r = l.target.value.trim();
932
932
  if (this.textInputEl && i(this.textInputEl)) {
933
933
  const u = m.normalizeColorValue(r);
934
- this.value = u, (h = this.onChange) == null || h.call(this, u), (d = this.detectChange) == null || d.call(this, u), this.colorInputEl && (this.colorInputEl.value = u), n.style.backgroundColor = u;
934
+ this.value = u, (c = this.onChange) == null || c.call(this, u), (d = this.detectChange) == null || d.call(this, u), this.colorInputEl && (this.colorInputEl.value = u), n.style.backgroundColor = u;
935
935
  }
936
936
  }), this.colorInputEl.addEventListener("input", (l) => {
937
937
  var d, u;
938
- const r = l.target.value, h = m.normalizeColorValue(r);
939
- this.value = h, (d = this.onChange) == null || d.call(this, h), (u = this.detectChange) == null || u.call(this, h), this.textInputEl && (this.textInputEl.value = h), n.style.backgroundColor = h, e.classList.remove("error");
938
+ const r = l.target.value, c = m.normalizeColorValue(r);
939
+ this.value = c, (d = this.onChange) == null || d.call(this, c), (u = this.detectChange) == null || u.call(this, c), this.textInputEl && (this.textInputEl.value = c), n.style.backgroundColor = c, e.classList.remove("error");
940
940
  }), this.colorInputEl.addEventListener("change", (l) => {
941
941
  var d, u;
942
- const r = l.target.value, h = m.normalizeColorValue(r);
943
- this.value = h, (d = this.onChange) == null || d.call(this, h), (u = this.detectChange) == null || u.call(this, h), this.textInputEl && (this.textInputEl.value = h), n.style.backgroundColor = h;
942
+ const r = l.target.value, c = m.normalizeColorValue(r);
943
+ this.value = c, (d = this.onChange) == null || d.call(this, c), (u = this.detectChange) == null || u.call(this, c), this.textInputEl && (this.textInputEl.value = c), n.style.backgroundColor = c;
944
944
  }), e.appendChild(s), e.appendChild(n), e.appendChild(o), t.appendChild(e), this.element = t, t;
945
945
  }
946
946
  getElement() {
@@ -1268,8 +1268,8 @@ class I extends g {
1268
1268
  selectOption(t, e, i) {
1269
1269
  var n, a, o;
1270
1270
  const s = this._options[e];
1271
- 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.cleanupDropdownPosition(), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((r, h) => {
1272
- h === e ? r.classList.add("selected") : r.classList.remove("selected");
1271
+ 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.cleanupDropdownPosition(), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((r, c) => {
1272
+ c === e ? r.classList.add("selected") : r.classList.remove("selected");
1273
1273
  }));
1274
1274
  }
1275
1275
  /**
@@ -1374,8 +1374,8 @@ class Et extends g {
1374
1374
  /^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i
1375
1375
  );
1376
1376
  if (n) {
1377
- let o = +n[1], l = +n[2], r = +n[3], h = +n[4];
1378
- h >= 1 ? (o = Math.round(o * 0.9), l = Math.round(l * 0.9), r = Math.round(r * 0.9)) : h = Math.min(1, h + 0.12), s = `rgba(${o},${l},${r},${h})`;
1377
+ let o = +n[1], l = +n[2], r = +n[3], c = +n[4];
1378
+ c >= 1 ? (o = Math.round(o * 0.9), l = Math.round(l * 0.9), r = Math.round(r * 0.9)) : c = Math.min(1, c + 0.12), s = `rgba(${o},${l},${r},${c})`;
1379
1379
  }
1380
1380
  t.addEventListener("mouseenter", () => {
1381
1381
  console.log("hoverBg", s), t.style.setProperty("background-color", s, "important");
@@ -1805,7 +1805,7 @@ class yt extends g {
1805
1805
  return JSON.stringify(t ? {} : { value: this.value }, null, 2);
1806
1806
  }
1807
1807
  selectApiOption(t, e, i) {
1808
- var l, r, h, d;
1808
+ var l, r, c, d;
1809
1809
  const s = t.target, n = s.querySelector(".select-api-radio") || ((l = s.closest(".select-api-option")) == null ? void 0 : l.querySelector(".select-api-radio"));
1810
1810
  n && (n.checked = !0), this.selectedOptionIndex = e;
1811
1811
  const a = this._options[e].value;
@@ -1817,7 +1817,7 @@ class yt extends g {
1817
1817
  const u = i.firstChild;
1818
1818
  u && u.tagName === "SPAN" && (u.textContent = this._options[e].name);
1819
1819
  }
1820
- this.isOpen = !1, (r = this.optionsListEl) == null || r.classList.remove("open"), (h = this.svgContainer) == null || h.classList.remove("open"), (d = this.onChange) == null || d.call(this, a), this.detectChangeCallback && this.detectChangeCallback(a);
1820
+ this.isOpen = !1, (r = this.optionsListEl) == null || r.classList.remove("open"), (c = this.svgContainer) == null || c.classList.remove("open"), (d = this.onChange) == null || d.call(this, a), this.detectChangeCallback && this.detectChangeCallback(a);
1821
1821
  }
1822
1822
  updateOptionsList() {
1823
1823
  !this.optionsListEl || !this.buttonEl || (this.optionsListEl.innerHTML = "", this._options.forEach((t, e) => {
@@ -1873,19 +1873,19 @@ class kt extends g {
1873
1873
  i.className = "toggle-switch";
1874
1874
  const s = document.createElement("input");
1875
1875
  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", () => {
1876
- var r, h;
1877
- const l = ((h = (r = this.props.options) == null ? void 0 : r.find((d) => d.status === s.checked)) == null ? void 0 : h.value) ?? "";
1876
+ var r, c;
1877
+ const l = ((c = (r = this.props.options) == null ? void 0 : r.find((d) => d.status === s.checked)) == null ? void 0 : c.value) ?? "";
1878
1878
  this.value = l, this.onChange && this.onChange(this.value), this.detectChangeCallback && this.detectChangeCallback(this.value);
1879
1879
  });
1880
1880
  const n = document.createElement("span");
1881
1881
  if (n.className = "toggle-slider", this.props.activeColor || this.props.inactiveColor) {
1882
- const l = document.createElement("style"), r = this.props.activeColor || "#4CAF50", h = this.props.inactiveColor || "#ccc";
1882
+ const l = document.createElement("style"), r = this.props.activeColor || "#4CAF50", c = this.props.inactiveColor || "#ccc";
1883
1883
  l.textContent = `
1884
1884
  .toggle-switch input:checked + .toggle-slider {
1885
1885
  background-color: ${r};
1886
1886
  }
1887
1887
  .toggle-switch .toggle-slider {
1888
- background-color: ${h};
1888
+ background-color: ${c};
1889
1889
  }
1890
1890
  `, document.head.appendChild(l);
1891
1891
  }
@@ -2269,8 +2269,8 @@ class E extends g {
2269
2269
  const t = this.value === "auto" ? "text" : "number", e = (o) => {
2270
2270
  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", () => {
2271
2271
  const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, r = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
2272
- let h = Number(o.value);
2273
- h < l && (h = l), h > r && (h = r), o.value = String(h);
2272
+ let c = Number(o.value);
2273
+ c < l && (c = l), c > r && (c = r), o.value = String(c);
2274
2274
  }));
2275
2275
  }, i = this.createInput({
2276
2276
  value: this.value,
@@ -2395,12 +2395,6 @@ class At extends v {
2395
2395
  `;
2396
2396
  }
2397
2397
  }
2398
- function Bt(c) {
2399
- return p(c);
2400
- }
2401
- function $t(c) {
2402
- return w(c);
2403
- }
2404
2398
  export {
2405
2399
  J as AlignSetting,
2406
2400
  Nt as AnimationSetting,
@@ -2424,7 +2418,7 @@ export {
2424
2418
  I as SelectSetting,
2425
2419
  g as Setting,
2426
2420
  v as SettingGroup,
2427
- G as StringSetting,
2421
+ P as StringSetting,
2428
2422
  F as TabSettingGroup,
2429
2423
  F as TabsSettingGroup,
2430
2424
  kt as Toggle,
@@ -2433,8 +2427,8 @@ export {
2433
2427
  Ct as asSettingGroupWithSettings,
2434
2428
  z as createSettingGroup,
2435
2429
  vt as createTabSettingGroup,
2436
- $t as isSetting,
2430
+ w as isSetting,
2437
2431
  ft as isSettingChild,
2438
- Bt as isSettingGroup,
2432
+ p as isSettingGroup,
2439
2433
  k as iterateSettings
2440
2434
  };
package/dist/index.d.ts CHANGED
@@ -28,3 +28,4 @@ export * from './groups/headerTypographySettingsSet';
28
28
  export * from './groups/margin-setting-group/marginSettingGroup';
29
29
  export * from './groups/background-setting-set/backgroundSettingsSet';
30
30
  export * from './utils/settingsTypes';
31
+ export * from './types/index';
@@ -1,9 +1,10 @@
1
1
  import { Setting, SettingProps, InputTypes, Primitive } from '../../base/settings';
2
+ import { SettingsMap } from '../../types';
2
3
  export interface SelectApiOption {
3
4
  name: string;
4
5
  value: string | object;
5
6
  }
6
- export interface SelectApiSettingProps<T = any> extends SettingProps<T> {
7
+ export interface SelectApiSettingProps<T = SettingsMap> extends SettingProps<T> {
7
8
  options?: SelectApiOption[];
8
9
  getOptions?: () => SelectApiOption[];
9
10
  getOptionsAsync?: () => Promise<SelectApiOption[]>;
@@ -12,7 +13,7 @@ export interface SelectApiSettingProps<T = any> extends SettingProps<T> {
12
13
  onChange?: (value: T) => void;
13
14
  detectChange?: (value: T | undefined) => void;
14
15
  }
15
- export declare class SelectApiSettings<T = any> extends Setting<T, SelectApiSettingProps<T>> {
16
+ export declare class SelectApiSettings<T = SettingsMap> extends Setting<T, SelectApiSettingProps<T>> {
16
17
  inputType: T extends Primitive ? InputTypes : Record<keyof T, InputTypes>;
17
18
  private _options;
18
19
  private isOpen;
@@ -1,16 +1,17 @@
1
1
  import { Setting, SettingProps, InputTypes, Primitive } from '../../base/settings';
2
+ import { SettingsMap } from '../../types';
2
3
  export interface SelectOption {
3
4
  name: string;
4
5
  value: string | object;
5
6
  }
6
- export interface SelectSettingProps<T = any> extends SettingProps<T> {
7
+ export interface SelectSettingProps<T = SettingsMap> extends SettingProps<T> {
7
8
  options?: SelectOption[];
8
9
  getOptions?: () => SelectOption[];
9
10
  getOptionsAsync?: () => Promise<SelectOption[]>;
10
11
  loadingText?: string;
11
12
  placeholder?: string;
12
13
  }
13
- export declare class SelectSetting<T = any> extends Setting<T, SelectSettingProps<T>> {
14
+ export declare class SelectSetting<T = SettingsMap> extends Setting<T, SelectSettingProps<T>> {
14
15
  inputType: T extends Primitive ? InputTypes : Record<keyof T, InputTypes>;
15
16
  private _options;
16
17
  private isOpen;
@@ -14,10 +14,10 @@ import { HeaderTypographySettingSet } from '../groups/headerTypographySettingsSe
14
14
  import { AlignSetting, AlignValue } from '../settings/align-settings/alignSettings';
15
15
  export type SettingValue = string | number | boolean | null | undefined;
16
16
  export type ComplexSettingValue = SettingValue | Record<string, SettingValue> | Array<SettingValue> | Date;
17
- export type AnySettingValue = SettingValue | ComplexSettingValue;
18
- export type SettingInstance<T extends AnySettingValue = AnySettingValue> = Setting<T, SettingProps<T>>;
19
- export type SettingChild<T extends AnySettingValue = AnySettingValue> = SettingInstance<T> | SettingGroup<any>;
20
- export type SettingsMap = Record<string, Setting<any, any> | SettingGroup<any>>;
17
+ export type SettingsProps = SettingValue | ComplexSettingValue;
18
+ export type SettingInstance<T extends SettingsProps = SettingsProps> = Setting<T, SettingProps<T>>;
19
+ export type SettingChild<T extends SettingsProps = SettingsProps> = SettingInstance<T> | SettingGroup<Record<string, SettingChild>>;
20
+ export type SettingsMap = Record<string, SettingChild | object>;
21
21
  export type SettingGroupInstance<TSettings extends SettingsMap = SettingsMap> = SettingGroup<TSettings>;
22
22
  type HasAlignSetting<T> = T extends SettingGroup<infer S> ? "align" extends keyof S ? true : false : false;
23
23
  type HeaderTypographyValues<T> = T extends SettingGroup<infer S> ? {
@@ -36,7 +36,7 @@ type HeaderTypographyValues<T> = T extends SettingGroup<infer S> ? {
36
36
  readonly fontSize: number;
37
37
  readonly align?: AlignValue;
38
38
  };
39
- export type ExtractSettingValue<T> = T extends Setting<infer V, any> ? V : T extends NumberSetting ? number : T extends StringSetting ? string : T extends ColorWithOpacitySetting ? string : T extends Toggle ? string : T extends UploadSetting ? string : T extends MarginTopSetting ? number : T extends SelectApiSettings<infer U> ? U : T extends SelectSetting<infer U> ? U : T extends MultiLanguageSetting ? MultiLanguageValue : T extends AlignSetting ? AlignValue : T extends BorderSettingSet ? {
39
+ export type ExtractSettingValue<T> = T extends Setting<infer V, infer P> ? V : T extends NumberSetting ? number : T extends StringSetting ? string : T extends ColorWithOpacitySetting ? string : T extends Toggle ? string : T extends UploadSetting ? string : T extends MarginTopSetting ? number : T extends SelectApiSettings<infer U> ? U : T extends SelectSetting<infer U> ? U : T extends MultiLanguageSetting ? MultiLanguageValue : T extends AlignSetting ? AlignValue : T extends BorderSettingSet ? {
40
40
  readonly color: string;
41
41
  readonly radius: number;
42
42
  readonly size: number;
@@ -44,7 +44,7 @@ export type ExtractSettingValue<T> = T extends Setting<infer V, any> ? V : T ext
44
44
  getValues(): infer R;
45
45
  } ? R : never;
46
46
  export type ExtractSettingValues<TSettings extends SettingsMap> = {
47
- readonly [K in keyof TSettings]: TSettings[K] extends Setting<infer V, any> ? V : TSettings[K] extends NumberSetting ? number : TSettings[K] extends StringSetting ? string : TSettings[K] extends ColorWithOpacitySetting ? string : TSettings[K] extends Toggle ? string : TSettings[K] extends UploadSetting ? string : TSettings[K] extends MarginTopSetting ? number : TSettings[K] extends SelectApiSettings<infer U> ? U : TSettings[K] extends SelectSetting<infer U> ? U : TSettings[K] extends MultiLanguageSetting ? MultiLanguageValue : TSettings[K] extends AlignSetting ? AlignValue : TSettings[K] extends BorderSettingSet ? {
47
+ readonly [K in keyof TSettings]: TSettings[K] extends Setting<infer V, infer P> ? V : TSettings[K] extends NumberSetting ? number : TSettings[K] extends StringSetting ? string : TSettings[K] extends ColorWithOpacitySetting ? string : TSettings[K] extends Toggle ? string : TSettings[K] extends UploadSetting ? string : TSettings[K] extends MarginTopSetting ? number : TSettings[K] extends SelectApiSettings<infer U> ? U : TSettings[K] extends SelectSetting<infer U> ? U : TSettings[K] extends MultiLanguageSetting ? MultiLanguageValue : TSettings[K] extends AlignSetting ? AlignValue : TSettings[K] extends BorderSettingSet ? {
48
48
  readonly color: string;
49
49
  readonly radius: number;
50
50
  readonly size: number;
@@ -55,7 +55,7 @@ export type ExtractSettingValues<TSettings extends SettingsMap> = {
55
55
  } ? R : unknown;
56
56
  };
57
57
  export type ExtractSettingValuesOptional<TSettings extends SettingsMap> = {
58
- [K in keyof TSettings]?: TSettings[K] extends Setting<infer V, any> ? V : TSettings[K] extends SettingGroup<infer S> ? ExtractSettingValuesOptional<S> : unknown;
58
+ [K in keyof TSettings]?: TSettings[K] extends Setting<infer V, infer P> ? V : TSettings[K] extends SettingGroup<infer S> ? ExtractSettingValuesOptional<S> : unknown;
59
59
  };
60
60
  export type DeepPartial<T> = {
61
61
  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
@@ -64,7 +64,7 @@ export type SettingChangeCallback<T> = (value: T) => void;
64
64
  export type SettingBlurCallback = () => void;
65
65
  export type SerializedSettingValues = Record<string, unknown>;
66
66
  export type MobileSettingValues<TSettings extends SettingsMap> = {
67
- [K in keyof TSettings]?: TSettings[K] extends Setting<infer V, any> ? V : TSettings[K] extends SettingGroup<infer S> ? MobileSettingValues<S> : unknown;
67
+ [K in keyof TSettings]?: TSettings[K] extends Setting<infer V, infer P> ? V : TSettings[K] extends SettingGroup<infer S> ? MobileSettingValues<S> : unknown;
68
68
  };
69
69
  export type SettingChanges<TSettings extends SettingsMap> = ExtractSettingValuesOptional<TSettings>;
70
70
  export declare function isSetting(value: unknown): value is SettingInstance;
@@ -88,4 +88,9 @@ export type ExtractSettingsFromFunction<T> = T extends (...args: never[]) => {
88
88
  export type GetSettings<T> = T extends {
89
89
  settings: SettingGroup<infer S>;
90
90
  } ? ExtractSettingValues<S> : T extends SettingGroup<infer S> ? ExtractSettingValues<S> : never;
91
+ export type ExtractSettingsFromComponent<T> = T extends {
92
+ settings: SettingGroup<infer S>;
93
+ } ? ExtractSettingValues<S> : T extends {
94
+ settings: infer S;
95
+ } ? S extends SettingGroup<infer U> ? ExtractSettingValues<U> : never : never;
91
96
  export type { Setting, SettingGroup };
@@ -1,4 +1,4 @@
1
- import { ExtractSettingValues as NewExtractSettingValues, DeepPartial as NewDeepPartial, SettingsMap, SettingChild } from '../types/index';
1
+ import { ExtractSettingValues as NewExtractSettingValues, DeepPartial as NewDeepPartial, SettingsMap } from '../types/index';
2
2
  export * from '../types/index';
3
3
  export type SettingsToProps<T> = T extends {
4
4
  getValues(): infer R;
@@ -6,8 +6,7 @@ export type SettingsToProps<T> = T extends {
6
6
  export type InferSettingsProps<T> = T extends {
7
7
  getValues(): infer R;
8
8
  } ? R : never;
9
- /** @deprecated Use DeepPartial from "../../types" instead */
9
+ export type ExtractSettingsFromComponent<T> = T extends {
10
+ settings: infer S;
11
+ } ? S extends SettingsMap ? NewExtractSettingValues<S> : never : never;
10
12
  export type SettingsToPropsOptional<T> = NewDeepPartial<NewExtractSettingValues<T extends SettingsMap ? T : never>>;
11
- export declare function isSettingGroup(value: unknown): value is SettingChild;
12
- /** @deprecated Use isSetting from "../../types" instead */
13
- export declare function isSetting(value: unknown): value is SettingChild;
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.236",
4
+ "version": "0.0.239",
5
5
  "type": "module",
6
6
  "main": "dist/builder-settings-types.cjs.js",
7
7
  "module": "dist/builder-settings-types.es.js",