builder-settings-types 0.0.263 → 0.0.264
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 ut="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let lt=(p=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(p|=0));for(;p--;)t+=ut[e[p]&63];return t};function gt(p){let t=0,e=p.parentElement;for(;e;)e.classList.contains("setting-group")&&e!==p&&t++,e=e.parentElement;return t}function Z(p,t){const e=Math.min(Math.max(t,0),5);p.setAttribute("data-nesting-level",e.toString()),e>0?p.style.setProperty("--visual-indent",`${e*2}px`):(p.style.removeProperty("--visual-indent"),p.style.marginLeft="")}function et(p,t=0){p.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(i=>{const s=i,n=t+1;Z(s,n),et(s,n)})}const mt={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class ft{constructor(t={}){this.observedElements=new Set,this.config={...mt,...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=gt(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 ot=new ft;function X(p){if(p===null||typeof p!="object")return p;if(p instanceof Date)return new Date(p.getTime());if(p instanceof Array)return p.map(t=>X(t));if(typeof p=="object"){const t={};for(const e in p)Object.prototype.hasOwnProperty.call(p,e)&&(t[e]=X(p[e]));return t}return p}function vt(p){switch(p){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 k{constructor(t={}){this.props=t,this.dataPropsPath="",this.id=t.id||lt(),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,k.DefaultUploadUrl=t}static SetDefaultLanguage(t){globalThis.DefaultLanguage=t,k.DefaultLanguage=t}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}setDataPropsPath(t){this.dataPropsPath=t}getDataPropsPath(){return this.dataPropsPath}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=X(this.props),i=new t(e);return i.value=X(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const a=document.createElement("div");if(a.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);a.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);a.appendChild(l)}e.appendChild(a)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||vt(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"",this.dataPropsPath&&s.setAttribute("data-test-id",this.dataPropsPath);const n=a=>{const l=a.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},o=a=>{a.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",o),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}}function z(p){return p instanceof k}function N(p){return p instanceof R}function it(p){return z(p)||N(p)}function q(p,t){for(const e in p)if(Object.prototype.hasOwnProperty.call(p,e)){const i=p[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.dataPropsPath="",this.id=t.id||lt(),this.title=t.title,this.settings=t.settings,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.nestingLevel=0,this.includeGetJson=t.includeGetJson??!0,this.addItemCfg=t.addItem,this.deleteItemCfg=t.deleteItem,this.dataProps=t.dataProps,this.dataPropsPath=t.dataProps||"",Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath()}propagateNestingLevel(){const t=this.nestingLevel+1;q(this.settings,(e,i)=>{N(i)&&(i.nestingLevel=t,i.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(t){this.nestingLevel=t,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(t){this.dataPropsPath=t,this.propagateDataPropsPath()}propagateDataPropsPath(){q(this.settings,(t,e)=>{const i=String(t),s=this.dataPropsPath?`${this.dataPropsPath}_${i}`:i;(N(e)||z(e)&&typeof e.setDataPropsPath=="function")&&e.setDataPropsPath(s)})}updateNestingStyles(){this.elementRef&&(Z(this.elementRef,this.nestingLevel),et(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([t,e])=>{try{if(N(e)){const i=e.getValues();e.setValue(i)}else if(typeof e.setValue=="function"){const i=e.value;i!==void 0&&e.setValue(i)}}catch(i){console.warn(`Error refreshing UI for setting ${t}:`,i)}})}removeSetting(t){var s;const e=this.settings[t];if(!e)return;if(delete this.settings[t],this.elementRef){const n=this.elementRef.querySelector(".setting-group-content");if(n){const o=Array.from(n.querySelectorAll(".setting-group, .setting"));for(const a of o){const l=a.id;if(l&&"id"in e&&typeof e.id=="string"&&l.includes(e.id)){a.remove();break}}}}typeof e.cleanup=="function"&&e.cleanup(),this.updateNestingStyles();const i=this.getValues();this.initialValues=i,(s=this.onChange)==null||s.call(this,i)}updateVisibility(){this.elementRef}clone(){const t={};q(this.settings,(s,n)=>{const o=String(s);typeof n.clone=="function"?t[o]=n.clone():(console.warn(`Setting with key '${o}' does not have a clone method. Copying reference.`),t[o]=n)});const e={title:this.title,settings:t,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps},i=rt(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&&(N(s)||z(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(N(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(N(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(),q(this.settings,(i,s)=>{var n;if(N(s))s.setOnChange(()=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(z(s)){const o=()=>e();this.changeHandlers.add(o),s.setOnChange(o)}else{const o=()=>e();this.changeHandlers.add(o),(n=s.setOnChange)==null||n.call(s,o)}}),this}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear()}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{let n=this.settings[i];if(!n&&this.addItemCfg&&i.startsWith(this.addItemCfg.keyPrefix)){const o=i.slice(this.addItemCfg.keyPrefix.length),a=Number(o);if(Number.isFinite(a)){const l=this.addItemCfg.createItem(a);it(l)&&(this.addSetting(i,l),n=l)}}n&&(N(n)||z(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()};N(t)?t.setOnChange(()=>e()):z(t)?t.setOnChange(()=>e()):(i=t.setOnChange)==null||i.call(t,()=>e())}addSetting(t,e){var s,n;if(this.settings[t]=e,this.wireChild(e),this.elementRef){const o=this.elementRef.querySelector(".setting-group-content");if(o){N(e)&&typeof e.setNestingLevel=="function"&&e.setNestingLevel(this.nestingLevel+1);const a=e.draw(),l=this.deleteItemCfg??this.addItemCfg;if(l){const h=l.keyPrefix??((s=this.addItemCfg)==null?void 0:s.keyPrefix);h&&t.startsWith(h)&&this.addDeleteButtonToElement(a,t)}const r=o.querySelector(".sg-add-button-bottom");r?o.insertBefore(a,r):o.appendChild(a),ot.trackElement(a),Z(a,this.nestingLevel+1),et(a,this.nestingLevel+1);const c=a.style.display;a.style.display="none",a.offsetHeight,a.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 o=document.createElement("button");o.type="button",o.className="sg-delete-button",i?i.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,o.title="Delete",o.style.cssText=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ut="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let lt=(p=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(p|=0));for(;p--;)t+=ut[e[p]&63];return t};function gt(p){let t=0,e=p.parentElement;for(;e;)e.classList.contains("setting-group")&&e!==p&&t++,e=e.parentElement;return t}function Z(p,t){const e=Math.min(Math.max(t,0),5);p.setAttribute("data-nesting-level",e.toString()),e>0?p.style.setProperty("--visual-indent",`${e*2}px`):(p.style.removeProperty("--visual-indent"),p.style.marginLeft="")}function et(p,t=0){p.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(i=>{const s=i,n=t+1;Z(s,n),et(s,n)})}const mt={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class ft{constructor(t={}){this.observedElements=new Set,this.config={...mt,...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=gt(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 ot=new ft;function X(p){if(p===null||typeof p!="object")return p;if(p instanceof Date)return new Date(p.getTime());if(p instanceof Array)return p.map(t=>X(t));if(typeof p=="object"){const t={};for(const e in p)Object.prototype.hasOwnProperty.call(p,e)&&(t[e]=X(p[e]));return t}return p}function vt(p){switch(p){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 S{constructor(t={}){this.props=t,this.dataPropsPath="",this.id=t.id||lt(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||"",this.includeGetJson=t.includeGetJson!==void 0?t.includeGetJson:!0}static SetUploadUrl(t){globalThis.DefaultUploadUrl=t,S.DefaultUploadUrl=t}static SetDefaultLanguage(t){globalThis.DefaultLanguage=t,S.DefaultLanguage=t}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}setDataPropsPath(t){this.dataPropsPath=t}getDataPropsPath(){return this.dataPropsPath}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=X(this.props),i=new t(e);return i.value=X(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const a=document.createElement("div");if(a.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);a.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);a.appendChild(l)}e.appendChild(a)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||vt(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"",this.dataPropsPath&&s.setAttribute("data-test-id",this.dataPropsPath);const n=a=>{const l=a.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},o=a=>{a.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",o),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}}function j(p){return p instanceof S}function N(p){return p instanceof W}function it(p){return j(p)||N(p)}function q(p,t){for(const e in p)if(Object.prototype.hasOwnProperty.call(p,e)){const i=p[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.dataPropsPath="",this.id=t.id||lt(),this.title=t.title,this.settings=t.settings,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.nestingLevel=0,this.includeGetJson=t.includeGetJson??!0,this.addItemCfg=t.addItem,this.deleteItemCfg=t.deleteItem,this.dataProps=t.dataProps,this.dataPropsPath=t.dataProps||"",Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath()}propagateNestingLevel(){const t=this.nestingLevel+1;q(this.settings,(e,i)=>{N(i)&&(i.nestingLevel=t,i.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(t){this.nestingLevel=t,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(t){this.dataPropsPath=t,this.propagateDataPropsPath()}propagateDataPropsPath(){q(this.settings,(t,e)=>{const i=String(t),s=this.dataPropsPath?`${this.dataPropsPath}_${i}`:i;(N(e)||j(e)&&typeof e.setDataPropsPath=="function")&&e.setDataPropsPath(s)})}updateNestingStyles(){this.elementRef&&(Z(this.elementRef,this.nestingLevel),et(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([t,e])=>{try{if(N(e)){const i=e.getValues();e.setValue(i)}else if(typeof e.setValue=="function"){const i=e.value;i!==void 0&&e.setValue(i)}}catch(i){console.warn(`Error refreshing UI for setting ${t}:`,i)}})}removeSetting(t){var s;const e=this.settings[t];if(!e)return;if(delete this.settings[t],this.elementRef){const n=this.elementRef.querySelector(".setting-group-content");if(n){const o=Array.from(n.querySelectorAll(".setting-group, .setting"));for(const a of o){const l=a.id;if(l&&"id"in e&&typeof e.id=="string"&&l.includes(e.id)){a.remove();break}}}}typeof e.cleanup=="function"&&e.cleanup(),this.updateNestingStyles();const i=this.getValues();this.initialValues=i,(s=this.onChange)==null||s.call(this,i)}updateVisibility(){this.elementRef}clone(){const t={};q(this.settings,(s,n)=>{const o=String(s);typeof n.clone=="function"?t[o]=n.clone():(console.warn(`Setting with key '${o}' does not have a clone method. Copying reference.`),t[o]=n)});const e={title:this.title,settings:t,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps},i=rt(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&&(N(s)||j(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(N(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(N(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(),q(this.settings,(i,s)=>{var n;if(N(s))s.setOnChange(()=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(j(s)){const o=()=>e();this.changeHandlers.add(o),s.setOnChange(o)}else{const o=()=>e();this.changeHandlers.add(o),(n=s.setOnChange)==null||n.call(s,o)}}),this}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear()}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{let n=this.settings[i];if(!n&&this.addItemCfg&&i.startsWith(this.addItemCfg.keyPrefix)){const o=i.slice(this.addItemCfg.keyPrefix.length),a=Number(o);if(Number.isFinite(a)){const l=this.addItemCfg.createItem(a);it(l)&&(this.addSetting(i,l),n=l)}}n&&(N(n)||j(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()};N(t)?t.setOnChange(()=>e()):j(t)?t.setOnChange(()=>e()):(i=t.setOnChange)==null||i.call(t,()=>e())}addSetting(t,e){var s,n;if(this.settings[t]=e,this.wireChild(e),this.elementRef){const o=this.elementRef.querySelector(".setting-group-content");if(o){N(e)&&typeof e.setNestingLevel=="function"&&e.setNestingLevel(this.nestingLevel+1);const a=e.draw(),l=this.deleteItemCfg??this.addItemCfg;if(l){const h=l.keyPrefix??((s=this.addItemCfg)==null?void 0:s.keyPrefix);h&&t.startsWith(h)&&this.addDeleteButtonToElement(a,t)}const r=o.querySelector(".sg-add-button-bottom");r?o.insertBefore(a,r):o.appendChild(a),ot.trackElement(a),Z(a,this.nestingLevel+1),et(a,this.nestingLevel+1);const c=a.style.display;a.style.display="none",a.offsetHeight,a.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 o=document.createElement("button");o.type="button",o.className="sg-delete-button",i?i.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,o.title="Delete",o.style.cssText=`
|
|
2
2
|
background: none;
|
|
3
3
|
border: none;
|
|
4
4
|
cursor: pointer;
|
|
@@ -79,12 +79,12 @@
|
|
|
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>`;c.innerHTML=`${h}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,c.addEventListener("click",d=>{d.stopPropagation(),d.preventDefault();const
|
|
82
|
+
</svg>`;c.innerHTML=`${h}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,c.addEventListener("click",d=>{d.stopPropagation(),d.preventDefault();const u=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),g=this.addItemCfg.createItem(u);if(it(g)){const C=`${this.addItemCfg.keyPrefix}${u}`;this.addSetting(C,g)}}),a.appendChild(c)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(a),this.elementRef=t,ot.trackElement(t),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(t){try{const e=JSON.parse(t);let i=e;const s=Object.keys(this.settings),n=Object.keys(e);if(!s.some(a=>n.includes(a))&&n.length===1){const a=n[0];i=e[a]}this.setValue(i)}catch(e){throw console.error("Invalid JSON provided to setJson:",e),new Error("Invalid JSON format")}}};K.hiddenElements=new Set;let W=K;function Ct(p){return new st(p)}class st extends W{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 o=document.createElement("div");if(o.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((a,l)=>{const r=document.createElement("button");r.className="tab-button",r.type="button",r.setAttribute("data-tab-id",a),r.textContent=a,r.addEventListener("click",()=>this.switchToTab(a)),n.appendChild(r);const c=document.createElement("div");c.className="tab-panel",this.contentContainers[a]=c;const h=this.settings[a];h&&(N(h)&&typeof h.setNestingLevel=="function"&&h.setNestingLevel(this.getNestingLevel()+1),c.appendChild(h.draw())),o.appendChild(c),l===0&&!this.activeTabId&&(this.activeTabId=a)}),e.appendChild(i),e.appendChild(n),e.appendChild(o),!this.activeTabId){const a=Object.keys(this.settings)[0];this.activeTabId=a||""}return this.updateTabUI(),t}}function rt(p){return new W(p)}function yt(p){return p}class ct extends S{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 Et="<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 A extends ct{constructor(t){super({...t,icon:t.icon||Et,title:t.title||"Color",default:t.default?A.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("#")?A.normalizeHexValue(t):t.includes(",")?A.rgbToHexStatic(t):A.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,o=Math.max(0,Math.min(255,i)),a=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n)),r=c=>{const h=c.toString(16);return h.length===1?"0"+h:h};return`#${r(o)}${r(a)}${r(l)}`}setValue(t){if(t===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof t=="string"){const e=A.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 h=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r);return h?e.classList.remove("error"):e.classList.add("error"),h},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.getDataPropsPath()&&s.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=s;const n=document.createElement("div");n.className="color-preview";const o=this.value||"#000000";n.style.backgroundColor=o;const a=document.createElement("input");return a.type="text",a.className="color-text-input",a.value=this.value||"",a.placeholder="#000000",a.setAttribute("pattern","#[0-9A-Fa-f]{6}"),a.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),a.setAttribute("aria-label","Hex color value"),a.setAttribute("maxlength","7"),this.getDataPropsPath()&&a.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=a,this.textInputEl.addEventListener("input",l=>{var c,h;let r=l.target.value.trim();if(this.textInputEl&&i(this.textInputEl)){const d=A.normalizeColorValue(r);this.value=d,(c=this.onChange)==null||c.call(this,d),(h=this.detectChange)==null||h.call(this,d),this.colorInputEl&&(this.colorInputEl.value=d),n.style.backgroundColor=d}}),this.colorInputEl.addEventListener("input",l=>{var h,d;const r=l.target.value,c=A.normalizeColorValue(r);this.value=c,(h=this.onChange)==null||h.call(this,c),(d=this.detectChange)==null||d.call(this,c),this.textInputEl&&(this.textInputEl.value=c),n.style.backgroundColor=c,e.classList.remove("error")}),this.colorInputEl.addEventListener("change",l=>{var h,d;const r=l.target.value,c=A.normalizeColorValue(r);this.value=c,(h=this.onChange)==null||h.call(this,c),(d=this.detectChange)==null||d.call(this,c),this.textInputEl&&(this.textInputEl.value=c),n.style.backgroundColor=c}),e.appendChild(s),e.appendChild(n),e.appendChild(a),t.appendChild(e),this.element=t,t}getElement(){return this.element}getNormalizedValue(){return this.value?A.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 bt=`
|
|
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"/>
|
|
86
86
|
<path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
|
|
87
|
-
</svg>`;class W extends k{constructor(t={}){super({...t,icon:t.icon||bt,title:t.title||"Color & Opacity",default:t.default||"#000000FF"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.opacityInputEl=null,this.colorPreviewEl=null,this.detectChange=t.detectChange,this.value&&(this.value=W.normalizeHexWithOpacity(this.value))}static normalizeHexWithOpacity(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length===6&&(t=t+"FF"),t.length===8&&/^[0-9A-Fa-f]{8}$/.test(t)?`#${t.toUpperCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000FF"`),"#000000FF")}getRgbColor(){return this.value?this.value.substring(0,7):"#000000"}getOpacityPercent(){if(!this.value)return 100;const t=this.value.substring(7,9),e=parseInt(t,16)/255;return Math.round(e*100)}static combineColorOpacity(t,e){const i=t.replace("#","").substring(0,6),n=Math.round(e/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i}${n}`}setValue(t){t===void 0||t===""?this.value="#000000FF":this.value=W.normalizeHexWithOpacity(t),this.updateInputElements(),this.updateColorPreview(),this.onChange&&this.onChange(this.value),this.detectChange&&this.detectChange(this.value)}updateInputElements(){this.value&&(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.textInputEl&&(this.textInputEl.value=this.value),this.opacityInputEl&&(this.opacityInputEl.value=this.getOpacityPercent().toString()))}updateColorPreview(){if(!this.colorPreviewEl||!this.value)return;const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);this.colorPreviewEl.style.backgroundColor=`rgba(${s}, ${n}, ${o}, ${e})`}handleColorChange(t){const e=this.getOpacityPercent(),i=W.combineColorOpacity(t,e);this.setValue(i)}handleTextInput(t){const e=/^#[0-9A-Fa-f]{8}$/.test(t.trim()),i=/^#[0-9A-Fa-f]{6}$/.test(t.trim());return e||i?(this.setValue(t),!0):!1}handleOpacityChange(t){const e=this.getRgbColor(),i=Math.max(0,Math.min(100,t)),s=W.combineColorOpacity(e,i);this.setValue(s)}draw(){const t=document.createElement("div");if(t.className="color-with-opacity-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const o=document.createElement("div");if(o.className="icon-container",this.props.icon){const a=document.createElement("span");a.className="input-icon",a.innerHTML=this.props.icon,o.appendChild(a)}if(this.props.title){const a=document.createElement("span");a.className="input-label",a.textContent=this.props.title,o.appendChild(a)}t.appendChild(o)}const e=document.createElement("div");e.className="color-with-opacity-input-wrapper",this.colorInputEl=document.createElement("input"),this.colorInputEl.type="color",this.colorInputEl.className="color-with-opacity-picker",this.getDataPropsPath()&&this.colorInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_color`),this.colorPreviewEl=document.createElement("div"),this.colorPreviewEl.className="color-with-opacity-preview",this.textInputEl=document.createElement("input"),this.textInputEl.type="text",this.textInputEl.className="color-with-opacity-text-input",this.textInputEl.placeholder="#000000FF",this.getDataPropsPath()&&this.textInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.updateInputElements(),this.updateColorPreview(),this.colorInputEl.addEventListener("input",o=>{const a=o.target;this.handleColorChange(a.value),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),this.textInputEl.addEventListener("input",o=>{const a=o.target;this.handleTextInput(a.value)?(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.updateColorPreview(),e.classList.remove("error")):a.value.trim()===""?e.classList.remove("error"):e.classList.add("error")}),this.textInputEl.addEventListener("blur",o=>{const a=o.target;a.value.trim()===""&&(a.value=this.value||"#000000FF",e.classList.remove("error"))}),this.colorPreviewEl.addEventListener("click",()=>{var o;(o=this.colorInputEl)==null||o.click()}),e.appendChild(this.colorInputEl),e.appendChild(this.colorPreviewEl),e.appendChild(this.textInputEl);const i=document.createElement("div");i.className="color-with-opacity-opacity-wrapper",this.opacityInputEl=document.createElement("input"),this.opacityInputEl.type="number",this.opacityInputEl.className="color-with-opacity-opacity-input",this.opacityInputEl.value=this.getOpacityPercent().toString(),this.opacityInputEl.min="0",this.opacityInputEl.max="100",this.opacityInputEl.step="1",this.opacityInputEl.placeholder="100",this.getDataPropsPath()&&this.opacityInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_opacity`);const s=document.createElement("span");s.className="color-with-opacity-opacity-suffix",s.textContent="%",this.opacityInputEl.addEventListener("input",o=>{const a=o.target,l=parseFloat(a.value);isNaN(l)||(this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview())}),this.opacityInputEl.addEventListener("blur",o=>{const a=o.target;let l=parseFloat(a.value);isNaN(l)&&(l=this.getOpacityPercent()),l=Math.max(0,Math.min(100,l)),a.value=l.toString(),this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),i.appendChild(this.opacityInputEl),i.appendChild(s);const n=document.createElement("div");return n.className="color-with-opacity-controls-wrapper",n.appendChild(e),n.appendChild(i),t.appendChild(n),this.element=t,this.updateInputElements(),this.updateColorPreview(),t}getElement(){return this.element}getValue(){return this.value}getRgbaValue(){if(!this.value)return"rgba(0, 0, 0, 1)";const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);return`rgba(${s}, ${n}, ${o}, ${e})`}getColorAndOpacity(){return{color:this.getRgbColor(),opacity:this.getOpacityPercent()}}}class wt extends k{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}setValue(t){this.value=t,this.textareaEl&&(this.textareaEl.value=t),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}draw(){const t=document.createElement("div");if(t.className="html-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const o=this.createIcon(this.props.icon);n.appendChild(o)}if(this.props.title){const o=this.createLabel(this.props.title);n.appendChild(o)}t.appendChild(n)}const e=document.createElement("textarea");this.textareaEl=e,e.value=this.value||"",e.placeholder=this.props.placeholder||"Paste your HTML here...",e.className="html-setting-textarea "+(this.props.textareaClassName||""),e.rows=this.props.rows||6,this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className);const i=n=>{const a=n.target.value;this.value=a,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},s=n=>{this.onBlur&&this.value!==void 0&&this.onBlur(this.value)};return e.addEventListener("input",i),e.addEventListener("change",i),e.addEventListener("blur",s),t.appendChild(e),t}}class B extends k{constructor(t){super(t),this.inputType="number",this.inputElement=null,this.mobileValue=t.mobile,this.validateProps(),this.value=this.validateValue(this.value)}draw(){const t=document.createElement("div");if(t.className="number-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const s=document.createElement("div");if(s.className="icon-container",this.props.icon){const n=document.createElement("span");n.className="input-icon",n.innerHTML=this.props.icon,s.appendChild(n)}if(this.props.title){const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,s.appendChild(n)}t.appendChild(s)}const e=document.createElement("div");e.className="number-setting-input-container";const i=document.createElement("input");if(i.type="number",i.className="number-setting-input "+(this.props.inputClassName||""),i.value=String(this.value??""),i.placeholder=this.props.placeholder||"",this.getDataPropsPath()&&i.setAttribute("data-test-id",this.getDataPropsPath()),this.props.minValue!==void 0&&(i.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(i.max=String(this.props.maxValue)),this.props.step!==void 0&&(i.step=String(this.props.step)),i.addEventListener("input",()=>{const s=this.props.minValue??Number.MIN_SAFE_INTEGER,n=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(i.value);o<s&&(o=s),o>n&&(o=n),String(o)!==i.value&&(i.value=String(o)),this.setValue(o)}),i.addEventListener("blur",()=>{var n,o;const s=this.validateValue(Number(i.value));s!==Number(i.value)&&(i.value=String(s),this.setValue(s)),(o=(n=this.props).onBlur)==null||o.call(n)}),e.appendChild(i),this.props.suffix&&this.props.suffix!=="none"){const s=document.createElement("span");s.className="suffix-label",s.textContent=this.props.suffix,e.appendChild(s)}return t.appendChild(e),this.inputElement=i,t}setValue(t){const e=this.validateValue(t);super.setValue(e),this.inputElement&&this.inputElement.value!==String(e)&&(this.inputElement.value=String(e??""))}validateValue(t){(t==null||isNaN(t))&&(t=this.props.default??0);const e=this.props.minValue??Number.MIN_SAFE_INTEGER,i=this.props.maxValue??Number.MAX_SAFE_INTEGER;let s=Number(t);return s<e&&(s=e),s>i&&(s=i),s}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}validateProps(){this.props.minValue!==void 0&&(this.props.default??0)<this.props.minValue&&console.warn(`Default value ${this.props.default} is less than minValue ${this.props.minValue}`),this.props.maxValue!==void 0&&(this.props.default??0)>this.props.maxValue&&console.warn(`Default value ${this.props.default} is greater than maxValue ${this.props.maxValue}`)}}const xt=`
|
|
87
|
+
</svg>`;class U extends S{constructor(t={}){super({...t,icon:t.icon||bt,title:t.title||"Color & Opacity",default:t.default||"#000000FF"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.opacityInputEl=null,this.colorPreviewEl=null,this.detectChange=t.detectChange,this.value&&(this.value=U.normalizeHexWithOpacity(this.value))}static normalizeHexWithOpacity(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length===6&&(t=t+"FF"),t.length===8&&/^[0-9A-Fa-f]{8}$/.test(t)?`#${t.toUpperCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000FF"`),"#000000FF")}getRgbColor(){return this.value?this.value.substring(0,7):"#000000"}getOpacityPercent(){if(!this.value)return 100;const t=this.value.substring(7,9),e=parseInt(t,16)/255;return Math.round(e*100)}static combineColorOpacity(t,e){const i=t.replace("#","").substring(0,6),n=Math.round(e/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i}${n}`}setValue(t){t===void 0||t===""?this.value="#000000FF":this.value=U.normalizeHexWithOpacity(t),this.updateInputElements(),this.updateColorPreview(),this.onChange&&this.onChange(this.value),this.detectChange&&this.detectChange(this.value)}updateInputElements(){this.value&&(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.textInputEl&&(this.textInputEl.value=this.value),this.opacityInputEl&&(this.opacityInputEl.value=this.getOpacityPercent().toString()))}updateColorPreview(){if(!this.colorPreviewEl||!this.value)return;const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);this.colorPreviewEl.style.backgroundColor=`rgba(${s}, ${n}, ${o}, ${e})`}handleColorChange(t){const e=this.getOpacityPercent(),i=U.combineColorOpacity(t,e);this.setValue(i)}handleTextInput(t){const e=/^#[0-9A-Fa-f]{8}$/.test(t.trim()),i=/^#[0-9A-Fa-f]{6}$/.test(t.trim());return e||i?(this.setValue(t),!0):!1}handleOpacityChange(t){const e=this.getRgbColor(),i=Math.max(0,Math.min(100,t)),s=U.combineColorOpacity(e,i);this.setValue(s)}draw(){const t=document.createElement("div");if(t.className="color-with-opacity-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const o=document.createElement("div");if(o.className="icon-container",this.props.icon){const a=document.createElement("span");a.className="input-icon",a.innerHTML=this.props.icon,o.appendChild(a)}if(this.props.title){const a=document.createElement("span");a.className="input-label",a.textContent=this.props.title,o.appendChild(a)}t.appendChild(o)}const e=document.createElement("div");e.className="color-with-opacity-input-wrapper",this.colorInputEl=document.createElement("input"),this.colorInputEl.type="color",this.colorInputEl.className="color-with-opacity-picker",this.getDataPropsPath()&&this.colorInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_color`),this.colorPreviewEl=document.createElement("div"),this.colorPreviewEl.className="color-with-opacity-preview",this.textInputEl=document.createElement("input"),this.textInputEl.type="text",this.textInputEl.className="color-with-opacity-text-input",this.textInputEl.placeholder="#000000FF",this.getDataPropsPath()&&this.textInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.updateInputElements(),this.updateColorPreview(),this.colorInputEl.addEventListener("input",o=>{const a=o.target;this.handleColorChange(a.value),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),this.textInputEl.addEventListener("input",o=>{const a=o.target;this.handleTextInput(a.value)?(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.updateColorPreview(),e.classList.remove("error")):a.value.trim()===""?e.classList.remove("error"):e.classList.add("error")}),this.textInputEl.addEventListener("blur",o=>{const a=o.target;a.value.trim()===""&&(a.value=this.value||"#000000FF",e.classList.remove("error"))}),this.colorPreviewEl.addEventListener("click",()=>{var o;(o=this.colorInputEl)==null||o.click()}),e.appendChild(this.colorInputEl),e.appendChild(this.colorPreviewEl),e.appendChild(this.textInputEl);const i=document.createElement("div");i.className="color-with-opacity-opacity-wrapper",this.opacityInputEl=document.createElement("input"),this.opacityInputEl.type="number",this.opacityInputEl.className="color-with-opacity-opacity-input",this.opacityInputEl.value=this.getOpacityPercent().toString(),this.opacityInputEl.min="0",this.opacityInputEl.max="100",this.opacityInputEl.step="1",this.opacityInputEl.placeholder="100",this.getDataPropsPath()&&this.opacityInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_opacity`);const s=document.createElement("span");s.className="color-with-opacity-opacity-suffix",s.textContent="%",this.opacityInputEl.addEventListener("input",o=>{const a=o.target,l=parseFloat(a.value);isNaN(l)||(this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview())}),this.opacityInputEl.addEventListener("blur",o=>{const a=o.target;let l=parseFloat(a.value);isNaN(l)&&(l=this.getOpacityPercent()),l=Math.max(0,Math.min(100,l)),a.value=l.toString(),this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),i.appendChild(this.opacityInputEl),i.appendChild(s);const n=document.createElement("div");return n.className="color-with-opacity-controls-wrapper",n.appendChild(e),n.appendChild(i),t.appendChild(n),this.element=t,this.updateInputElements(),this.updateColorPreview(),t}getElement(){return this.element}getValue(){return this.value}getRgbaValue(){if(!this.value)return"rgba(0, 0, 0, 1)";const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);return`rgba(${s}, ${n}, ${o}, ${e})`}getColorAndOpacity(){return{color:this.getRgbColor(),opacity:this.getOpacityPercent()}}}class wt extends S{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}setValue(t){this.value=t,this.textareaEl&&(this.textareaEl.value=t),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}draw(){const t=document.createElement("div");if(t.className="html-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const o=this.createIcon(this.props.icon);n.appendChild(o)}if(this.props.title){const o=this.createLabel(this.props.title);n.appendChild(o)}t.appendChild(n)}const e=document.createElement("textarea");this.textareaEl=e,e.value=this.value||"",e.placeholder=this.props.placeholder||"Paste your HTML here...",e.className="html-setting-textarea "+(this.props.textareaClassName||""),e.rows=this.props.rows||6,this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className);const i=n=>{const a=n.target.value;this.value=a,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},s=n=>{this.onBlur&&this.value!==void 0&&this.onBlur(this.value)};return e.addEventListener("input",i),e.addEventListener("change",i),e.addEventListener("blur",s),t.appendChild(e),t}}class B extends S{constructor(t){super(t),this.inputType="number",this.inputElement=null,this.mobileValue=t.mobile,this.validateProps(),this.value=this.validateValue(this.value)}draw(){const t=document.createElement("div");if(t.className="number-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const s=document.createElement("div");if(s.className="icon-container",this.props.icon){const n=document.createElement("span");n.className="input-icon",n.innerHTML=this.props.icon,s.appendChild(n)}if(this.props.title){const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,s.appendChild(n)}t.appendChild(s)}const e=document.createElement("div");e.className="number-setting-input-container";const i=document.createElement("input");if(i.type="number",i.className="number-setting-input "+(this.props.inputClassName||""),i.value=String(this.value??""),i.placeholder=this.props.placeholder||"",this.getDataPropsPath()&&i.setAttribute("data-test-id",this.getDataPropsPath()),this.props.minValue!==void 0&&(i.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(i.max=String(this.props.maxValue)),this.props.step!==void 0&&(i.step=String(this.props.step)),i.addEventListener("input",()=>{const s=this.props.minValue??Number.MIN_SAFE_INTEGER,n=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(i.value);o<s&&(o=s),o>n&&(o=n),String(o)!==i.value&&(i.value=String(o)),this.setValue(o)}),i.addEventListener("blur",()=>{var n,o;const s=this.validateValue(Number(i.value));s!==Number(i.value)&&(i.value=String(s),this.setValue(s)),(o=(n=this.props).onBlur)==null||o.call(n)}),e.appendChild(i),this.props.suffix&&this.props.suffix!=="none"){const s=document.createElement("span");s.className="suffix-label",s.textContent=this.props.suffix,e.appendChild(s)}return t.appendChild(e),this.inputElement=i,t}setValue(t){const e=this.validateValue(t);super.setValue(e),this.inputElement&&this.inputElement.value!==String(e)&&(this.inputElement.value=String(e??""))}validateValue(t){(t==null||isNaN(t))&&(t=this.props.default??0);const e=this.props.minValue??Number.MIN_SAFE_INTEGER,i=this.props.maxValue??Number.MAX_SAFE_INTEGER;let s=Number(t);return s<e&&(s=e),s>i&&(s=i),s}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}validateProps(){this.props.minValue!==void 0&&(this.props.default??0)<this.props.minValue&&console.warn(`Default value ${this.props.default} is less than minValue ${this.props.minValue}`),this.props.maxValue!==void 0&&(this.props.default??0)>this.props.maxValue&&console.warn(`Default value ${this.props.default} is greater than maxValue ${this.props.maxValue}`)}}const xt=`
|
|
88
88
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
89
89
|
<path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
90
90
|
<path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -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 Y extends
|
|
95
|
+
`;class Y extends S{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 o=this.createIcon(this.props.icon);n.appendChild(o)}if(this.props.title){const o=this.createLabel(this.props.title);n.appendChild(o)}t.appendChild(n)}else{const n=document.createElement("div");t.appendChild(n)}const e=document.createElement("div");e.classList.add("select-button"),this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),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,o;this.isLoading||(this.isOpen=!this.isOpen,this.isOpen?this.checkDropdownPosition():this.cleanupDropdownPosition(),(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(o=this.svgContainer)==null||o.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,o)=>{const a=this.createOption(n,o);a.onclick=l=>this.selectOption(l,o,e),i.appendChild(a)}),document.body.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=Lt,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 o,a;this.isOpen&&!t.contains(n.target)&&(this.isOpen=!1,(o=this.optionsListEl)==null||o.classList.remove("open"),(a=this.svgContainer)==null||a.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,o;const s=this._options[e];s&&(this.setValue(s.value),this.selectedOptionIndex=e,this.isOpen=!1,i.textContent=s.name,(n=this.optionsListEl)==null||n.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"),this.cleanupDropdownPosition(),this.optionsListEl&&this.optionsListEl.querySelectorAll(".select-option").forEach((l,r)=>{r===e?l.classList.add("selected"):l.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 dt extends S{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 o=document.createElement("button");o.className="align-option-button",o.innerHTML=n.icon,this.getDataPropsPath()&&o.setAttribute("data-test-id",`${this.getDataPropsPath()}_${n.name}`),this.value===n.name&&o.classList.add("selected"),o.addEventListener("click",()=>{var a;i.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),o.classList.add("selected"),this.value=n.name,(a=this.onChange)==null||a.call(this,this.value)}),i.appendChild(o)}),t.appendChild(i),t}}class kt extends
|
|
116
|
+
`}].forEach(n=>{const o=document.createElement("button");o.className="align-option-button",o.innerHTML=n.icon,this.getDataPropsPath()&&o.setAttribute("data-test-id",`${this.getDataPropsPath()}_${n.name}`),this.value===n.name&&o.classList.add("selected"),o.addEventListener("click",()=>{var a;i.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),o.classList.add("selected"),this.value=n.name,(a=this.onChange)==null||a.call(this,this.value)}),i.appendChild(o)}),t.appendChild(i),t}}class kt extends S{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)",this.getDataPropsPath()&&t.setAttribute("data-test-id",this.getDataPropsPath());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 a=+n[1],l=+n[2],r=+n[3],c=+n[4];c>=1?(a=Math.round(a*.9),l=Math.round(l*.9),r=Math.round(r*.9)):c=Math.min(1,c+.12),s=`rgba(${a},${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 a,l;return(l=(a=this.props).onClick)==null?void 0:l.call(a)});const o=document.createElement("div");return o.className="button-setting-wrapper "+(this.props.wrapperClassName||""),o.appendChild(t),o}}class St extends S{constructor(t={}){super(t),this.inputType={width:"number",height:"number"},this.aspectRatio=1,this.isUpdating=!1;const e=t.width||0,i=t.height||0;this.value||(this.value={width:e,height:i}),this.minWidth=t.minWidth??0,this.maxWidth=t.maxWidth,this.minHeight=t.minHeight??0,this.maxHeight=t.maxHeight,this.locked=t.locked??!1,this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.widthSetting=new B({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:Mt}),this.heightSetting=new B({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:It}),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>`:`
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 12 12" fill="none">
|
|
137
137
|
<path d="M8 3V2.6C8 2.03995 8 1.75992 7.89101 1.54601C7.79513 1.35785 7.64215 1.20487 7.45399 1.10899C7.24008 1 6.96005 1 6.4 1H5.6C5.03995 1 4.75992 1 4.54601 1.10899C4.35785 1.20487 4.20487 1.35785 4.10899 1.54601C4 1.75992 4 2.03995 4 2.6V3M5 5.75V8.25M7 5.75V8.25M1.5 3H10.5M9.5 3V8.6C9.5 9.44008 9.5 9.86012 9.33651 10.181C9.1927 10.4632 8.96323 10.6927 8.68099 10.8365C8.36012 11 7.94008 11 7.1 11H4.9C4.05992 11 3.63988 11 3.31901 10.8365C3.03677 10.6927 2.8073 10.4632 2.66349 10.181C2.5 9.86012 2.5 9.44008 2.5 8.6V3" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
138
138
|
</svg>
|
|
139
|
-
`,
|
|
139
|
+
`,Tt=`
|
|
140
140
|
<svg xmlns="http://www.w3.org/2000/svg" width="29" height="29" viewBox="0 0 29 29" fill="none">
|
|
141
141
|
<!-- Top dot -->
|
|
142
142
|
<circle cx="14.5" cy="3" r="1.5" fill="#02CC59" opacity="1"/>
|
|
@@ -155,16 +155,16 @@
|
|
|
155
155
|
<!-- Top-left dot -->
|
|
156
156
|
<circle cx="6.7" cy="6.7" r="1.5" fill="#02CC59" opacity="0.3"/>
|
|
157
157
|
</svg>
|
|
158
|
-
`;class nt extends
|
|
158
|
+
`;class nt extends S{constructor(t={}){super(t),this.inputType="button",this.previewWrapper=null,this.previewEl=null,this.emptyStateEl=null,this.errorContainer=null,this.messageListener=null,this.loadingSpinner=null,this.props.delete===void 0&&(this.props.delete=!0),this.props.maxFileSizeMB===void 0&&(this.props.maxFileSizeMB=5),!this.value&&t.defaultUrl&&t.defaultUrl!==""&&(this.value=t.defaultUrl),this.setupMessageListener()}setupMessageListener(){this.messageListener=t=>{var e;if(t.data&&t.data.type==="FILE_MANAGER_IMAGE_SELECTED"&&t.data.settingId===this.id){const i=t.data.imageUrl;i&&typeof i=="string"&&(this.value=i,this.updatePreviewState(i),(e=this.onChange)==null||e.call(this,i),this.hideError())}},window.addEventListener("message",this.messageListener)}cleanupMessageListener(){this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null)}setValue(t){super.setValue(t),this.previewWrapper&&this.previewEl&&this.updatePreviewState(t)}destroy(){this.cleanupMessageListener()}showError(t){this.errorContainer&&(this.errorContainer.textContent=t,this.errorContainer.style.display="block",setTimeout(()=>{this.errorContainer&&(this.errorContainer.style.display="none")},5e3))}hideError(){this.errorContainer&&(this.errorContainer.style.display="none")}showLoading(){!this.previewWrapper||!this.loadingSpinner||(this.previewWrapper.classList.add("loading"),this.previewWrapper.style.display="flex",this.loadingSpinner.style.display="block",this.previewEl&&(this.previewEl.style.display="none"))}hideLoading(){!this.previewWrapper||!this.loadingSpinner||(this.previewWrapper.classList.remove("loading"),this.loadingSpinner.style.display="none")}validateFileSize(t){const e=(this.props.maxFileSizeMB||5)*1024*1024;if(t.size>e){const i=this.props.maxFileSizeMB||5,s=(t.size/(1024*1024)).toFixed(1);return this.showError(`File size (${s}MB) exceeds maximum limit of ${i}MB`),!1}return!0}updatePreviewState(t=null){if(!this.previewWrapper||!this.previewEl)return;const e=this.previewWrapper.parentElement,i=e==null?void 0:e.querySelector(".upload-button"),s=e==null?void 0:e.querySelector(".preview-placeholder");if(t&&t!==""){this.showLoading(),s&&s instanceof HTMLElement&&(s.style.display="none"),e&&e.classList.remove("no-image"),i&&(i.innerHTML=`
|
|
159
159
|
<span class="upload-icon">${tt}</span>
|
|
160
160
|
<span class="upload-label">Replace</span>
|
|
161
161
|
`);const n=()=>{this.hideLoading(),this.previewWrapper.classList.add("has-image"),this.previewEl.style.display="block",this.previewEl.removeEventListener("load",n),this.previewEl.removeEventListener("error",o)},o=()=>{this.hideLoading(),this.showError("Failed to load image. Please try again."),this.previewWrapper.classList.remove("has-image"),this.previewEl.style.display="none",this.previewWrapper.style.display="none",s&&s instanceof HTMLElement&&(s.style.display="block"),e&&e.classList.add("no-image"),this.previewEl.removeEventListener("load",n),this.previewEl.removeEventListener("error",o)};this.previewEl.addEventListener("load",n),this.previewEl.addEventListener("error",o),this.previewEl.src=t}else this.hideLoading(),this.previewWrapper.classList.remove("has-image"),this.previewEl.src="",this.previewEl.style.display="none",this.previewWrapper.style.display="none",s&&s instanceof HTMLElement&&(s.style.display="block"),e&&e.classList.add("no-image"),i&&(i.innerHTML=`
|
|
162
162
|
<span class="upload-icon">${tt}</span>
|
|
163
163
|
<span class="upload-label">Upload</span>
|
|
164
|
-
`)}draw(){const t=document.createElement("div");t.className="upload-setting-wrapper",t.setAttribute("data-setting-id",this.id),t.addEventListener("focusout",a=>{var l;a.relatedTarget&&t.contains(a.relatedTarget)||(l=this.onBlur)==null||l.call(this,this.value??"")},!0);const e=!!(this.props.title||this.props.icon);if(e||t.classList.add("no-label"),e){const a=document.createElement("div");if(a.className="icon-title-container",this.props.icon){const l=this.createIcon(this.props.icon);a.appendChild(l)}if(this.props.title){const l=this.createLabel(this.props.title);a.appendChild(l)}t.appendChild(a)}this.errorContainer=document.createElement("div"),this.errorContainer.className="error-message",this.errorContainer.style.display="none",t.appendChild(this.errorContainer);const i=document.createElement("div");i.className="preview-button-container";const s=this.value&&this.value!=="";s||i.classList.add("no-image");const n=document.createElement("div");if(n.className="preview-placeholder",n.innerHTML=Nt,this.previewWrapper=document.createElement("div"),this.previewWrapper.className="preview-wrapper",this.loadingSpinner=document.createElement("div"),this.loadingSpinner.className="loading-spinner",this.loadingSpinner.innerHTML=
|
|
164
|
+
`)}draw(){const t=document.createElement("div");t.className="upload-setting-wrapper",t.setAttribute("data-setting-id",this.id),t.addEventListener("focusout",a=>{var l;a.relatedTarget&&t.contains(a.relatedTarget)||(l=this.onBlur)==null||l.call(this,this.value??"")},!0);const e=!!(this.props.title||this.props.icon);if(e||t.classList.add("no-label"),e){const a=document.createElement("div");if(a.className="icon-title-container",this.props.icon){const l=this.createIcon(this.props.icon);a.appendChild(l)}if(this.props.title){const l=this.createLabel(this.props.title);a.appendChild(l)}t.appendChild(a)}this.errorContainer=document.createElement("div"),this.errorContainer.className="error-message",this.errorContainer.style.display="none",t.appendChild(this.errorContainer);const i=document.createElement("div");i.className="preview-button-container";const s=this.value&&this.value!=="";s||i.classList.add("no-image");const n=document.createElement("div");if(n.className="preview-placeholder",n.innerHTML=Nt,this.previewWrapper=document.createElement("div"),this.previewWrapper.className="preview-wrapper",this.loadingSpinner=document.createElement("div"),this.loadingSpinner.className="loading-spinner",this.loadingSpinner.innerHTML=Tt,this.loadingSpinner.style.display="none",this.previewWrapper.appendChild(this.loadingSpinner),this.previewEl=document.createElement("img"),this.previewEl.className="upload-preview",this.props.delete){const a=document.createElement("button");a.className="delete-button",a.type="button",a.title="Delete image",a.innerHTML=Vt,this.previewWrapper.appendChild(a),a.onclick=l=>{var r;l.stopPropagation(),this.value="",this.updatePreviewState(null),(r=this.onChange)==null||r.call(this,""),this.hideError()}}this.previewWrapper.appendChild(this.previewEl);const o=document.createElement("button");return o.className="upload-button",this.getDataPropsPath()&&o.setAttribute("data-test-id",this.getDataPropsPath()),o.innerHTML=`
|
|
165
165
|
<span class="upload-icon">${tt}</span>
|
|
166
166
|
<span class="upload-label">Upload</span>
|
|
167
|
-
`,i.appendChild(n),i.appendChild(this.previewWrapper),i.appendChild(o),t.appendChild(i),s?this.updatePreviewState(this.value):this.updatePreviewState(null),o.onclick=()=>{window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:this.id},"*")},t}}class
|
|
167
|
+
`,i.appendChild(n),i.appendChild(this.previewWrapper),i.appendChild(o),t.appendChild(i),s?this.updatePreviewState(this.value):this.updatePreviewState(null),o.onclick=()=>{window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:this.id},"*")},t}}class Ht extends B{constructor(t={}){super({...t,title:t.title||"Height",suffix:t.suffix||"px",minValue:t.minValue??0,icon:t.icon||Pt,default:t.default??100}),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const Pt=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
168
168
|
<path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
169
169
|
</svg>`;class Ot extends B{constructor(t={}){super({...t,title:t.title||"Width",suffix:t.suffix||"px",minValue:t.minValue??0,icon:t.icon||$t,default:t.default??100}),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const $t=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
170
170
|
<path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -172,21 +172,21 @@
|
|
|
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 Bt extends
|
|
175
|
+
`;class Bt extends S{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.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),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 o=document.createElement("span");if(o.className="select-value",this.isLoading)o.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,l=a&&typeof a.name=="string"?a.name:"Select an option";o.textContent=l}e.appendChild(o)}else{const n=document.createElement("span");if(this.isLoading)n.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,a=o&&typeof o.name=="string"?o.name:"Select an option";n.textContent=a}e.appendChild(n)}e.onclick=()=>{var n,o;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(o=this.svgContainer)==null||o.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,o)=>{const a=this.createOption(n,o);a.onclick=l=>this.selectApiOption(l,o,e),i.appendChild(a)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=At,t.appendChild(s),s.onclick=()=>{var n,o;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(o=this.svgContainer)==null||o.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 o=new Set(this._options.map(l=>JSON.stringify(l.value))),a=n.filter(l=>!o.has(JSON.stringify(l.value)));if(this._options.push(...a),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 o=new Set(this._options.map(l=>JSON.stringify(l.value))),a=n.filter(l=>!o.has(JSON.stringify(l.value)));if(this._options.push(...a),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,h;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 o=this._options[e].value;this.value=o;const a=i.querySelector(".select-value");if(a)a.textContent=this._options[e].name;else{const d=i.firstChild;d&&d.tagName==="SPAN"&&(d.textContent=this._options[e].name)}this.isOpen=!1,(r=this.optionsListEl)==null||r.classList.remove("open"),(c=this.svgContainer)==null||c.classList.remove("open"),(h=this.onChange)==null||h.call(this,o),this.detectChangeCallback&&this.detectChangeCallback(o)}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 S{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 o,a;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=((a=(o=this.props.options)==null?void 0:o.find(l=>l.value===this.value))==null?void 0:a.status)??!1,this.getDataPropsPath()&&s.setAttribute("data-test-id",this.getDataPropsPath()),s.addEventListener("change",()=>{var r,c;const l=((c=(r=this.props.options)==null?void 0:r.find(h=>h.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
180
|
background-color: ${c};
|
|
181
181
|
}
|
|
182
|
-
`,document.head.appendChild(l)}if(i.appendChild(s),i.appendChild(n),t.appendChild(i),this.props.description){t.classList.add("toggle-has-description");const l=document.createElement("p");l.className="toggle-description",l.textContent=this.props.description,t.appendChild(l)}return t}setDetectChange(t){this.detectChangeCallback=t}}const
|
|
182
|
+
`,document.head.appendChild(l)}if(i.appendChild(s),i.appendChild(n),t.appendChild(i),this.props.description){t.classList.add("toggle-has-description");const l=document.createElement("p");l.className="toggle-description",l.textContent=this.props.description,t.appendChild(l)}return t}setDetectChange(t){this.detectChangeCallback=t}}const Ft=`<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"/>
|
|
184
|
-
</svg>`;class
|
|
184
|
+
</svg>`;class Gt extends S{constructor(t={}){t.rowGap=t.rowGap??!0,t.columnGap=t.columnGap??!0,t.title=t.title??"Gap",t.icon=t.icon??Ft,t.suffix=t.suffix??"px",t.minValue=t.minValue??0,super(t),this.inputType="number",this.inputValues={},this.mobileValue=t.mobile,this.value=this.validateValue(t.default??0),t.rowGap&&(this.inputValues.row=this.value),t.columnGap&&(this.inputValues.column=this.value)}draw(){const t=document.createElement("div");t.className=`setting-container ${this.props.className||""}`,t.id=this.id;const e=document.createElement("div");e.className="setting-label-input-wrapper";const i=document.createElement("label");i.className="setting-label",i.setAttribute("for",this.id+"-input");const s=document.createElement("span");if(s.textContent=this.props.title??"Gap",i.appendChild(s),this.props.icon){const a=document.createElement("span");a.className="setting-icon",a.innerHTML=this.props.icon,i.insertBefore(a,s)}const n=document.createElement("div");n.className=`setting-input-wrapper ${this.props.wrapperClassName||""}`,n.classList.add("gap-setting-wrapper");const o=document.createElement("div");return o.className="gap-inputs-container",this.props.rowGap&&o.appendChild(this.createGapInput("row","Row")),this.props.columnGap&&o.appendChild(this.createGapInput("column","Col")),n.appendChild(o),e.appendChild(i),e.appendChild(n),t.appendChild(e),t}createGapInput(t,e){const i=document.createElement("div");i.className="gap-input-wrapper";const s=document.createElement("input");if(s.type="number",s.className=`gap-input gap-${t}-input ${this.props.inputClassName||""}`,s.id=`${this.id}-${t}-input`,s.min=String(this.props.minValue??0),this.props.maxValue!==void 0&&(s.max=String(this.props.maxValue)),s.step=String(this.props.step??1),s.value=String(this.inputValues[t]??this.value),s.title=e,this.getDataPropsPath()&&s.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),s.addEventListener("input",n=>{const o=n.target;let a=parseFloat(o.value);a=this.validateValue(a),String(a)!==o.value&&(o.value=String(a)),this.inputValues[t]=a,this.setValue(a)}),s.addEventListener("blur",n=>{var l,r;const o=n.target;let a=parseFloat(o.value);a=this.validateValue(a),String(a)!==o.value&&(o.value=String(a),this.inputValues[t]=a,this.setValue(a)),(r=(l=this.props).onBlur)==null||r.call(l)}),i.appendChild(s),this.props.suffix&&this.props.suffix!=="none"){const n=document.createElement("span");n.className="gap-suffix",n.textContent=this.props.suffix,i.appendChild(n),s.style.paddingRight="30px"}return i}validateValue(t){(t==null||isNaN(t))&&(t=this.props.default??0);const e=this.props.minValue??Number.MIN_SAFE_INTEGER,i=this.props.maxValue??Number.MAX_SAFE_INTEGER;let s=Number(t);return s<e&&(s=e),s>i&&(s=i),s}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const Rt=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
185
185
|
<path d="M2.25 11.75H15.75M5.85 2.75H12.15C13.4101 2.75 14.0402 2.75 14.5215 2.99524C14.9448 3.21095 15.289 3.55516 15.5048 3.97852C15.75 4.45982 15.75 5.08988 15.75 6.35V12.65C15.75 13.9101 15.75 14.5402 15.5048 15.0215C15.289 15.4448 14.9448 15.789 14.5215 16.0048C14.0402 16.25 13.4101 16.25 12.15 16.25H5.85C4.58988 16.25 3.95982 16.25 3.47852 16.0048C3.05516 15.789 2.71095 15.4448 2.49524 15.0215C2.25 14.5402 2.25 13.9101 2.25 12.65V6.35C2.25 5.08988 2.25 4.45982 2.49524 3.97852C2.71095 3.55516 3.05516 3.21095 3.47852 2.99524C3.95982 2.75 4.58988 2.75 5.85 2.75Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
186
|
-
</svg>`;class Wt extends B{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||
|
|
186
|
+
</svg>`;class Wt extends B{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||Rt,title:t.title||"Margin Bottom",default:t.default??20,wrapperClassName:"margin-bottom-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}const zt=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
187
187
|
<path d="M15.75 7.25H2.25m9.9 9h-6.3c-1.26 0-1.89 0-2.371-.245a2.25 2.25 0 0 1-.984-.983c-.245-.482-.245-1.112-.245-2.372v-6.3c0-1.26 0-1.89.245-2.371a2.25 2.25 0 0 1 .984-.984c.48-.245 1.11-.245 2.371-.245h6.3c1.26 0 1.89 0 2.371.245.424.216.768.56.984.984.245.48.245 1.11.245 2.371v6.3c0 1.26 0 1.89-.245 2.371-.216.424-.56.768-.984.984-.48.245-1.11.245-2.371.245"
|
|
188
188
|
stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
189
|
-
</svg>`;class Ut extends B{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||zt,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class jt extends
|
|
189
|
+
</svg>`;class Ut extends B{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||zt,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class jt extends S{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,t.default?this.value={...t.default}:this.value||(this.value={}),this.defaultLanguage=t.languages.includes(S.DefaultLanguage)?S.DefaultLanguage:t.languages[0];const e=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(i=>{var s,n;i in(this.value||{})||(this.value||(this.value={}),i===this.defaultLanguage&&e?this.value[i]=((s=t.default)==null?void 0:s[i])||e:this.value[i]=((n=t.default)==null?void 0:n[i])||"")})}capitalizeFirstLetter(t){return String(t).charAt(0).toUpperCase()+String(t).slice(1)}measureTextWidth(t,e){this.textMeasureCanvas||(this.textMeasureCanvas=document.createElement("canvas"));const i=this.textMeasureCanvas.getContext("2d");if(!i)return t.length*10;const s=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`.trim();return i.font=s,i.measureText(t).width}adaptPlaceholderToSingleLine(t,e){const i=window.getComputedStyle(t),s=parseFloat(i.paddingLeft)||0,n=parseFloat(i.paddingRight)||0,o=parseFloat(i.borderLeftWidth)||0,a=parseFloat(i.borderRightWidth)||0,l=Math.max(0,t.clientWidth-s-n-o-a);if(l<=0){t.placeholder=e;return}if(this.measureTextWidth(e,i)<=l){t.placeholder=e;return}const c="...";let h=0,d=e.length,u=0;for(;h<=d;){const C=Math.floor((h+d)/2),m=e.slice(0,C).trimEnd()+c;this.measureTextWidth(m,i)<=l?(u=C,h=C+1):d=C-1}const g=e.slice(0,u).trimEnd()+c;t.placeholder=g}autosizeTextarea(t,e=3){t.style.height="auto";const i=window.getComputedStyle(t),s=parseFloat(i.lineHeight)||20,n=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),a=s*e+n+o,l=Math.min(t.scrollHeight||44,a);t.style.height=`${l}px`,t.scrollHeight>a?t.style.overflowY="auto":t.style.overflowY="hidden"}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");if(s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`),i.appendChild(s),this.props.multiImg){const n=new nt({defaultUrl:e||"",title:"",id:`${this.id}_upload_${t}`});n.setOnChange(a=>{this.updateLanguageValue(t,a),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)}),this.uploadSettings.set(t,n);const o=n.draw();o.classList.add("simple-language-upload"),i.appendChild(o)}else{const n=document.createElement("textarea");n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"",n.rows=1,n.style.overflowY="hidden";let o=this.props.placeholder||"Enter text in {language}...";o.includes("{language}")&&(o=o.replace("{language}",t.toUpperCase())),n.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(n,o),this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",l=>{const r=l.target;this.updateLanguageValue(t,r.value),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(r.value),this.autosizeTextarea(r,3);const c=n.getAttribute("data-full-placeholder")||"";c&&this.adaptPlaceholderToSingleLine(n,c)}),i.appendChild(n),(l=>(typeof queueMicrotask=="function"?queueMicrotask:r=>setTimeout(r,0))(l))(()=>{this.autosizeTextarea(n,3);const l=n.getAttribute("data-full-placeholder")||"";l&&this.adaptPlaceholderToSingleLine(n,l)})}return i}updateLanguageValue(t,e){this.value||(this.value={});const i={...this.value,[t]:e};this.setValue(i)}updateOtherLanguagePlaceholders(t){this.container&&this.props.languages.forEach(e=>{var s,n;if(e===this.defaultLanguage)return;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);if(i&&(!i.value||i.value.trim()==="")){const o=t||((n=this.props.placeholder)==null?void 0:n.replace("{language}",e.toUpperCase()))||`Enter text in ${e.toUpperCase()}...`;i.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(i,o)}})}draw(){const t=document.createElement("div");if(t.classList.add("simple-multi-language-wrapper"),this.props.title){const s=document.createElement("div");s.classList.add("simple-multi-language-title"),s.textContent=this.props.title,t.appendChild(s)}const e=document.createElement("div");e.classList.add("simple-multi-language-content"),this.props.languages.forEach(s=>{var a;const n=((a=this.value)==null?void 0:a[s])||"",o=this.createTextareaRow(s,n);e.appendChild(o)}),t.appendChild(e),this.container=t;const i=()=>{if(!this.container)return;this.container.querySelectorAll(".simple-language-textarea").forEach(n=>{const o=n.getAttribute("data-full-placeholder")||"";o&&this.adaptPlaceholderToSingleLine(n,o)})};return window.addEventListener("resize",i),t}setValue(t){super.setValue(t),this.container&&this.props.languages.forEach(e=>{var i;if(this.props.multiImg){const s=this.uploadSettings.get(e);s&&s.setValue((t==null?void 0:t[e])||"")}else{const s=(i=this.container)==null?void 0:i.querySelector(`#textarea-${e}`);if(s){s.value=(t==null?void 0:t[e])||"",this.autosizeTextarea(s,3);const n=s.getAttribute("data-full-placeholder")||"";n&&this.adaptPlaceholderToSingleLine(s,n)}}})}}class _t extends S{constructor(t={}){super(t),this.inputType="select";const e=[{name:"None",value:"none"},{name:"Fade",value:"fade 1.5s ease-in-out infinite"},{name:"Slide",value:"slide 1.5s ease-in-out infinite"},{name:"Zoom",value:"zoom 1.5s ease-in-out infinite"},{name:"Bounce",value:"bounce 1.5s ease-in-out infinite"},{name:"Pulse",value:"pulse 1.5s ease-in-out infinite"}];this.selectSetting=new Y({title:this.title||"Animation",options:e,default:this.props.default||"none"}),this.selectSetting.onChange=i=>{var s;this.value=i,(s=this.onChange)==null||s.call(this,i)}}draw(){return this.selectSetting.draw()}destroy(){this.selectSetting.destroy(),super.destroy()}}const pt=`<svg
|
|
190
190
|
width="13"
|
|
191
191
|
height="13"
|
|
192
192
|
viewBox="0 0 13 13"
|
|
@@ -199,23 +199,23 @@
|
|
|
199
199
|
d="M6.12347 4.96653L1.41158 0.254304C1.25449 0.102568 1.04409 0.0186071 0.825694 0.0205049C0.607302 0.0224037 0.398393 0.110007 0.24396 0.26445C0.0895282 0.418893 0.0019303 0.627818 3.24698e-05 0.846225C-0.00186536 1.06463 0.0820894 1.27505 0.233815 1.43215L4.9457 6.14438L0.233814 10.8566C0.0820886 11.0137 -0.00186625 11.2241 3.15434e-05 11.4425C0.00192934 11.6609 0.0895272 11.8699 0.243959 12.0243C0.398392 12.1787 0.607301 12.2663 0.825693 12.2682C1.04408 12.2701 1.25449 12.1862 1.41158 12.0344L6.12347 7.32222L10.8354 12.0344C10.9932 12.1824 11.2023 12.2632 11.4186 12.2597C11.6349 12.2562 11.8414 12.1687 11.9943 12.0156C12.1472 11.8626 12.2346 11.6561 12.2379 11.4398C12.2413 11.2234 12.1604 11.0143 12.0123 10.8566L7.30123 6.14438L12.0131 1.43215C12.0927 1.35531 12.1561 1.2634 12.1998 1.16177C12.2434 1.06014 12.2664 0.950833 12.2674 0.84023C12.2683 0.729626 12.2473 0.61994 12.2054 0.517568C12.1635 0.415196 12.1017 0.322191 12.0234 0.243979C11.9452 0.165768 11.8522 0.103916 11.7499 0.0620327C11.6475 0.0201492 11.5378 -0.000927989 11.4272 3.33052e-05C11.3166 0.000993646 11.2073 0.0239743 11.1057 0.0676297C11.0041 0.111286 10.9122 0.174745 10.8354 0.254305L6.12347 4.96653Z"
|
|
200
200
|
fill="#919EAB"
|
|
201
201
|
/>
|
|
202
|
-
</svg>`;function at(p){try{const t=p.match(/linear-gradient\(
|
|
202
|
+
</svg>`;function at(p){try{const t=p.match(/linear-gradient\s*\(/);if(t){const e=t.index+t[0].length;let i=1,s=e;for(let n=e;n<p.length&&i>0;n++)p[n]==="("?i++:p[n]===")"&&i--,s=n;if(i===0){const n=p.substring(e,s).trim();let o=90;const a=n.match(/(\d+)deg/);a?o=parseInt(a[1]):n.includes("to right")?o=90:n.includes("to left")?o=270:n.includes("to top")?o=0:n.includes("to bottom")?o=180:n.includes("to top right")?o=45:n.includes("to top left")?o=315:n.includes("to bottom right")?o=135:n.includes("to bottom left")&&(o=225);const l=[];let r="",c=0;for(let u=0;u<n.length;u++){const g=n[u];g==="("&&c++,g===")"&&c--,g===","&&c===0?(l.push(r.trim()),r=""):r+=g}r.trim()&&l.push(r.trim());const h=[];let d=[];for(let u=0;u<l.length;u++){const g=l[u];g.includes("deg")||g.includes("to ")||d.push(g)}for(let u=0;u<d.length;u++){const g=d[u];let C="",m=0,y=100;const f=g.match(/rgba?\(([^)]+)\)(?:\s*(\d+(?:\.\d+)?)%)?/);if(f){const E=f[1].split(",").map(b=>b.trim()),V=parseInt(E[0]),D=parseInt(E[1]),F=parseInt(E[2]),L=E[3]?parseFloat(E[3]):1;C=`#${V.toString(16).padStart(2,"0")}${D.toString(16).padStart(2,"0")}${F.toString(16).padStart(2,"0")}`,y=Math.round(L*100),f[2]?m=parseFloat(f[2]):m=d.length===1?0:Math.round(u/(d.length-1)*100)}else{const E=g.match(/#([a-fA-F0-9]{3,8})(?:\s*(\d+(?:\.\d+)?)%)?/);E&&(C=`#${E[1]}`,E[2]?m=parseFloat(E[2]):m=d.length===1?0:Math.round(u/(d.length-1)*100))}C&&h.push({color:C,position:m,opacity:y})}if(h.length===0){const u=n.match(/(#[a-fA-F0-9]{3,8}|rgba?\([^)]+\))/g);u&&u.forEach((g,C)=>{let m="",y=100;if(g.startsWith("#"))m=g;else{const f=g.match(/rgba?\(([^)]+)\)/);if(f){const E=f[1].split(",").map(b=>b.trim()),V=parseInt(E[0]),D=parseInt(E[1]),F=parseInt(E[2]),L=E[3]?parseFloat(E[3]):1;m=`#${V.toString(16).padStart(2,"0")}${D.toString(16).padStart(2,"0")}${F.toString(16).padStart(2,"0")}`,y=Math.round(L*100)}}if(m){const f=u.length===1?0:Math.round(C/(u.length-1)*100);h.push({color:m,position:f,opacity:y})}})}return console.log("Color stops found:",h),{type:"linear",angle:o,stops:h}}}return null}catch(t){return console.warn("Failed to parse CSS gradient:",p,t),null}}class qt{constructor(t){this.isOpen=!1,this.currentColor="#ff0000",this.currentOpacity=100,this.isUpdatingHue=!1,this.handleOutsideClick=e=>{const i=document.querySelector(".gradient-popover");i&&i.contains(e.target)||this.element.contains(e.target)||(e.stopPropagation(),this.close())},this.onColorChange=t,this.element=this.createColorPicker()}createColorPicker(){const t=document.createElement("div");t.className="custom-color-picker",t.style.display="none";const e=document.createElement("div");e.className="color-picker-header",e.style.cursor="move";const i=document.createElement("span");i.textContent="Color";const s=document.createElement("button");s.className="color-picker-close",s.innerHTML=pt,s.addEventListener("click",()=>this.close()),e.appendChild(i),e.appendChild(s),this.makeDraggable(e,t);const n=document.createElement("div");n.className="color-picker-area",this.colorArea=n;const o=document.createElement("div");o.className="color-picker-marker",this.colorMarker=o,n.appendChild(o);const a=document.createElement("div");a.className="color-picker-hue-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=`<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
203
203
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.1972 3.29156C18.936 3.03034 18.6259 2.82313 18.2847 2.68176C17.9434 2.54039 17.5777 2.46763 17.2083 2.46763C16.8389 2.46763 16.4731 2.54039 16.1319 2.68176C15.7906 2.82313 15.4805 3.03034 15.2194 3.29156L13.7822 4.72875C13.2585 4.4772 12.6697 4.39449 12.097 4.49207C11.5243 4.58964 10.9961 4.86267 10.5853 5.27343L9.91687 5.94281C9.74268 6.11693 9.6045 6.32366 9.51023 6.5512C9.41595 6.77873 9.36743 7.02261 9.36743 7.2689C9.36743 7.5152 9.41595 7.75907 9.51023 7.98661C9.6045 8.21414 9.74268 8.42088 9.91687 8.595L3.83625 14.6747C3.57512 14.936 3.36803 15.2462 3.2268 15.5875C3.08556 15.9288 3.01296 16.2947 3.01312 16.6641V18.3516C3.01312 18.6499 3.13165 18.9361 3.34263 19.1471C3.55361 19.358 3.83975 19.4766 4.13812 19.4766H5.82562C6.57129 19.4759 7.28618 19.1792 7.81312 18.6516L13.8937 12.5728C14.0679 12.747 14.2746 12.8852 14.5021 12.9795C14.7297 13.0737 14.9735 13.1223 15.2198 13.1223C15.4661 13.1223 15.71 13.0737 15.9375 12.9795C16.1651 12.8852 16.3718 12.747 16.5459 12.5728L17.2153 11.9025C17.6261 11.4917 17.8991 10.9635 17.9967 10.3908C18.0942 9.81811 18.0115 9.22926 17.76 8.70562L19.1972 7.26937C19.4584 7.0082 19.6656 6.69813 19.807 6.35687C19.9484 6.01561 20.0211 5.64985 20.0211 5.28047C20.0211 4.91108 19.9484 4.54532 19.807 4.20406C19.6656 3.8628 19.4584 3.55273 19.1972 3.29156ZM5.16281 16.0012L11.2425 9.92062L12.5681 11.2462L6.48844 17.3269C6.31266 17.5027 6.07424 17.6015 5.82562 17.6016H4.88812V16.6641C4.88818 16.4154 4.98698 16.177 5.16281 16.0012Z" fill="#353C47"/>
|
|
204
|
-
</svg>`;const r=document.createElement("div");r.className="color-picker-hue",this.hueSlider=r;const c=document.createElement("div");c.className="color-picker-hue-marker",this.hueMarker=c,r.appendChild(c),a.appendChild(l),a.appendChild(r);const h=document.createElement("div");h.className="color-picker-opacity",this.opacitySlider=h;const d=document.createElement("div");d.className="color-picker-opacity-marker",this.opacityMarker=d,h.appendChild(d);const m=document.createElement("div");m.className="color-picker-format-section";const u=document.createElement("select");u.className="color-picker-format-select",this.formatSelect=u;const g=document.createElement("option");g.value="hex",g.textContent="HEX";const f=document.createElement("option");f.value="rgb",f.textContent="RGB";const y=document.createElement("option");y.value="hsl",y.textContent="HSL",u.appendChild(g),u.appendChild(f),u.appendChild(y);const v=document.createElement("input");v.type="text",v.className="color-picker-color-input",v.value=this.currentColor,this.hexInput=v;const w=document.createElement("div");w.className="color-picker-input-container";const V=document.createElement("button");return V.className="color-picker-copy-inside",V.textContent="Copy",V.addEventListener("click",()=>this.copyToClipboard()),w.appendChild(v),w.appendChild(V),m.appendChild(u),m.appendChild(w),t.appendChild(e),t.appendChild(n),t.appendChild(a),t.appendChild(h),t.appendChild(m),this.setupEyedropper(l),this.setupEventListeners(),t.addEventListener("click",U=>{U.stopPropagation()}),t}setupEventListeners(){this.colorArea.addEventListener("mousedown",t=>this.startColorDrag(t)),this.colorArea.addEventListener("click",t=>{t.stopPropagation(),this.updateColorFromArea(t)}),this.hueSlider.addEventListener("mousedown",t=>this.startHueDrag(t)),this.hueSlider.addEventListener("click",t=>{t.stopPropagation(),this.updateHueFromSlider(t)}),this.formatSelect.addEventListener("change",()=>this.updateColorInput()),this.hexInput.addEventListener("input",t=>this.updateColorFromInput(t)),this.hexInput.addEventListener("blur",t=>this.validateColorInput(t)),this.opacitySlider.addEventListener("mousedown",t=>this.startOpacityDrag(t)),this.opacitySlider.addEventListener("click",t=>{t.stopPropagation(),this.updateOpacityFromSlider(t)})}startColorDrag(t){t.preventDefault(),t.stopPropagation(),this.updateColorFromArea(t);const e=s=>this.updateColorFromArea(s),i=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",e),document.addEventListener("mouseup",i)}startHueDrag(t){t.preventDefault(),t.stopPropagation(),this.updateHueFromSlider(t);const e=s=>this.updateHueFromSlider(s),i=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",e),document.addEventListener("mouseup",i)}updateColorFromArea(t){const e=this.colorArea.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),s=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${s*100}%`,this.updateColorFromSV(i,1-s)}updateHueFromSlider(t){this.isUpdatingHue=!0;const e=this.hueSlider.getBoundingClientRect();let i=(t.clientX-e.left)/e.width;i=Math.max(.002,Math.min(.996,i)),console.log("Hue slider click:",{x:i,hueValue:i*360,percent:i*100}),this.hueMarker.style.left=`${i*100}%`;const s=i*360;this.updateHue(s),this.isUpdatingHue=!1}updateColorFromSV(t,e){const i=this.getCurrentHue(),s=this.hsvToHex(i,t,e);this.setColor(s)}updateHue(t){const e=t;t=Math.max(.5,Math.min(358.5,t)),console.log("UpdateHue:",{originalHue:e,clampedHue:t}),this.colorArea.getBoundingClientRect();const i=parseFloat(this.colorMarker.style.left||"50%")/100,s=parseFloat(this.colorMarker.style.top||"50%")/100;this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${t}, 100%, 50%))`;const n=i,o=1-s,a=this.hsvToHex(t,n,o);this.setColor(a)}getCurrentHue(){const t=parseFloat(this.hueMarker.style.left||"0%")/100,e=t*360;return console.log("GetCurrentHue:",{huePosition:t,hueValue:e}),Math.max(.5,Math.min(358.5,e))}updateColorInput(){const t=this.formatSelect.value,{h:e,s:i,v:s}=this.hexToHsv(this.currentColor);switch(t){case"hex":this.hexInput.value=this.currentColor;break;case"rgb":const{r:n,g:o,b:a}=this.hexToRgb(this.currentColor);this.hexInput.value=`rgb(${n}, ${o}, ${a})`;break;case"hsl":const{hue:l,sat:r,lightness:c}=this.hsvToHsl(e,i,s);this.hexInput.value=`hsl(${Math.round(l)}, ${Math.round(r*100)}%, ${Math.round(c*100)}%)`;break}}updateColorFromInput(t){const e=t.target.value,i=this.formatSelect.value;let s="";if(i==="hex"&&/^#[0-9A-Fa-f]{6}$/.test(e))s=e;else if(i==="rgb"){const n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const o=parseInt(n[1]),a=parseInt(n[2]),l=parseInt(n[3]);o<=255&&a<=255&&l<=255&&(s=`#${o.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`)}}else if(i==="hsl"){const n=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const o=parseInt(n[1]),a=parseInt(n[2])/100,l=parseInt(n[3])/100;if(o<=360&&a<=1&&l<=1){const r=l+a*Math.min(l,1-l),c=r===0?0:2*(1-l/r);s=this.hsvToHex(o,c,r)}}}s&&this.setColor(s)}validateColorInput(t){this.updateColorInput()}startOpacityDrag(t){t.preventDefault(),t.stopPropagation(),this.updateOpacityFromSlider(t);const e=s=>this.updateOpacityFromSlider(s),i=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",e),document.addEventListener("mouseup",i)}updateOpacityFromSlider(t){const e=this.opacitySlider.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.opacityMarker.style.left=`${i*100}%`,this.currentOpacity=Math.round(i*100),this.onColorChange&&this.onColorChange(this.currentColor,this.currentOpacity)}updateOpacityBackground(){const{r:t,g:e,b:i}=this.hexToRgb(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`)}isValidHex(t){return/^#[0-9A-Fa-f]{6}$/.test(t)}hsvToHex(t,e,i){t=Math.max(0,Math.min(359.9,t)),e=Math.max(0,Math.min(1,e)),i=Math.max(0,Math.min(1,i)),console.log("CustomColorPicker HsvToHex:",{h:t,s:e,v:i});const s=i*e,n=s*(1-Math.abs(t/60%2-1)),o=i-s;let a=0,l=0,r=0;return t<60?(a=s,l=n,r=0):t<120?(a=n,l=s,r=0):t<180?(a=0,l=s,r=n):t<240?(a=0,l=n,r=s):t<300?(a=n,l=0,r=s):(a=s,l=0,r=n),a=Math.round((a+o)*255),l=Math.round((l+o)*255),r=Math.round((r+o)*255),`#${a.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}setColor(t){this.currentColor=t,this.updatePickerFromColor(t),this.updateColorInput(),this.updateOpacityBackground(),this.onColorChange&&this.onColorChange(t,this.currentOpacity)}setupEyedropper(t){const e=async()=>{if("EyeDropper"in window)try{const n=(await new window.EyeDropper().open()).sRGBHex;this.currentColor=n,this.updateColorInput(),this.updateColorAreaFromHex(n),this.onColorChange&&this.onColorChange(n)}catch(i){console.log("User cancelled eyedropper or error occurred:",i)}else alert("EyeDropper API is not supported in this browser. Try using Chrome 95+ or Edge 95+.")};t.addEventListener("click",e)}updateColorAreaFromHex(t){this.hexInput.value=t}copyToClipboard(){navigator.clipboard.writeText(this.currentColor).catch(()=>{this.hexInput.select(),document.execCommand("copy")})}open(t,e,i){this.currentColor=t,this.currentOpacity=i??100,this.updateColorInput(),this.updatePickerFromColor(t),this.updateOpacityBackground(),this.opacityMarker.style.left=`${this.currentOpacity}%`,this.isOpen=!0,this.element.style.display="block";const s=e.getBoundingClientRect(),n=window.innerWidth,o=window.innerHeight;this.element.style.position="fixed",this.element.style.zIndex="10002";let a=s.right+8,l=s.top;a+408>n&&(a=s.left-408-8),a<8&&(a=Math.max(8,(n-408)/2)),l+500>o&&(l=Math.max(8,o-500-8)),this.element.style.left=`${a}px`,this.element.style.top=`${l}px`,this.element.parentElement||document.body.appendChild(this.element),this.updatePickerFromColor(t),setTimeout(()=>{document.addEventListener("click",this.handleOutsideClick,!0)},50)}updatePickerFromColor(t){const{h:e,s:i,v:s}=this.hexToHsv(t);this.isUpdatingHue||(this.hueMarker.style.left=`${e/360*100}%`),this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${e}, 100%, 50%))`}hexToHsv(t){const e=parseInt(t.slice(1,3),16)/255,i=parseInt(t.slice(3,5),16)/255,s=parseInt(t.slice(5,7),16)/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=n-o;let l=0;const r=n===0?0:a/n,c=n;return a!==0&&(n===e?l=(i-s)/a%6:n===i?l=(s-e)/a+2:l=(e-i)/a+4),{h:l*60,s:r,v:c}}hexToRgb(t){const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),s=parseInt(t.slice(5,7),16);return{r:e,g:i,b:s}}hsvToHsl(t,e,i){const s=i*(1-e/2),n=s===0||s===1?0:(i-s)/Math.min(s,1-s);return{hue:t,sat:n,lightness:s}}makeDraggable(t,e){let i=!1,s=0,n=0,o=0,a=0;const l=h=>{if(h.target.closest("button"))return;h.preventDefault(),h.stopPropagation(),i=!0,s=h.clientX,n=h.clientY;const d=e.getBoundingClientRect();o=d.left,a=d.top,e.classList.add("dragging"),document.addEventListener("mousemove",r),document.addEventListener("mouseup",c),document.body.style.userSelect="none"},r=h=>{if(!i)return;h.preventDefault(),h.stopPropagation();const d=h.clientX-s,m=h.clientY-n;let u=o+d,g=a+m;const f=window.innerWidth,y=window.innerHeight,v=e.offsetWidth,w=e.offsetHeight;u=Math.max(8,Math.min(f-v-8,u)),g=Math.max(8,Math.min(y-w-8,g)),e.style.left=`${u}px`,e.style.top=`${g}px`},c=h=>{i&&(i=!1,h.preventDefault(),h.stopPropagation(),e.classList.remove("dragging"),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",c),document.body.style.userSelect="")};t.addEventListener("mousedown",l)}close(){this.isOpen=!1,this.element.style.display="none",document.removeEventListener("click",this.handleOutsideClick,!0)}getElement(){return this.element}}class Jt extends k{constructor(t={}){let e;if(typeof t.default=="string")if(t.default.match(/^#[a-fA-F0-9]{3,8}$/)){let i=t.default,s=100;if(i.length===9){const n=parseInt(i.slice(-2),16);s=Math.round(n/255*100),i=i.slice(0,7)}e={type:"solid",angle:90,stops:[{color:i,position:0,opacity:s}]}}else e=at(t.default)||{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]};else e=t.default||{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]};super({...t,title:t.title||"Gradient",default:e}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewElement=null,this.textInputElement=null,this.popoverElement=null,this.placeholderTrigger=null,this.isPopoverOpen=!1,this.isUserEditing=!1,this.handleBackgroundClick=i=>{var r;if(!this.popoverElement||!this.isPopoverOpen)return;const s=i.target,n=this.popoverElement.contains(s),o=(r=this.element)==null?void 0:r.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(c=>c.contains(s));!n&&!o&&!l&&this.closePopover()},this.detectChange=t.detectChange,this.forText=t.forText||!1}getSafeValue(){return!this.value||!this.isValidGradientValue(this.value)?(console.warn("Invalid value detected, returning default:",this.value),{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]}):this.value}setValue(t){let e;if(!t)console.warn("Undefined value in setValue, using default"),e={type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]};else if(typeof t=="string")if(t.match(/^#[a-fA-F0-9]{3,8}$/)){let i=t,s=100;if(i.length===9){const n=parseInt(i.slice(-2),16);s=Math.round(n/255*100),i=i.slice(0,7)}e={type:"solid",angle:90,stops:[{color:i,position:0,opacity:s}]}}else{const i=at(t);i?e=i:(console.warn("Failed to parse string value, using default:",t),e={type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}else if(typeof t=="object"&&t.background){console.warn("Received CSS style object, extracting background value:",t);const i=t.background;if(typeof i=="string"){this.setValue(i);return}else e={type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]}}else this.isValidGradientValue(t)?(e=t,e.stops&&e.stops.forEach(i=>{i.opacity===void 0&&(i.opacity=100)})):(console.warn("Invalid gradient value in setValue, using default:",t),e={type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]});super.setValue(e),this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent()}updateUI(){if(this.previewElement&&this.value)if(this.value.type==="solid"){const t=this.value.stops&&this.value.stops.length>0?this.value.stops[0]:null;if(t){const e=t.opacity!==void 0?t.opacity:100;this.previewElement.style.background=this.addOpacityToColor(t.color,e)}}else this.previewElement.style.background=this.generateCSS(this.getSafeValue());this.textInputElement&&this.value&&!this.isUserEditing&&(this.textInputElement.value=this.generateDisplayText(this.value))}generateDisplayText(t){if(!t)return"";if(t.type==="solid"){const i=t.stops&&t.stops.length>0?t.stops[0]:null;return i?i.color.replace("#","").toUpperCase():"Color"}t.stops&&t.stops.length;const e=t.type==="linear"?"Linear":"Radial";return t.type==="linear"?`${e} ${t.angle}°`:`${e} Gradient`}draw(){const t=document.createElement("div");if(t.className="gradient-setting-wrapper",this.props.title){const s=document.createElement("div");s.className="icon-container";const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,s.appendChild(n),t.appendChild(s)}const e=document.createElement("div");e.className="gradient-input-wrapper",this.previewElement=document.createElement("div"),this.previewElement.className="gradient-mini-preview",this.previewElement.style.background=this.value?this.generateCSS(this.getSafeValue()):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.textInputElement=document.createElement("input"),this.textInputElement.type="text",this.textInputElement.className="gradient-text-input",this.textInputElement.placeholder="Enter gradient CSS or paste color...",this.textInputElement.value=this.value?this.generateDisplayText(this.value):"",this.textInputElement.readOnly=!1,this.previewElement.addEventListener("click",()=>this.openPopover()),this.textInputElement.addEventListener("focus",()=>{this.isUserEditing=!0,this.value&&(this.textInputElement.value=this.generateCSS(this.getSafeValue()))}),this.textInputElement.addEventListener("blur",()=>{this.isUserEditing=!1,this.value&&(this.textInputElement.value=this.generateDisplayText(this.value)),this.placeholderTrigger&&(this.placeholderTrigger.style.display=this.textInputElement.value?"none":"flex")}),this.textInputElement.addEventListener("paste",s=>this.handlePaste(s)),this.textInputElement.addEventListener("input",s=>this.handleInput(s)),this.textInputElement.addEventListener("keydown",s=>{s.key==="Enter"&&(this.handleInput(s),this.textInputElement.blur()),s.key==="Escape"&&(this.value&&(this.textInputElement.value=this.generateCSS(this.getSafeValue())),this.textInputElement.blur())});const i=document.createElement("div");return i.className="gradient-input-placeholder-trigger",i.textContent=this.textInputElement.placeholder||"",i.style.display=this.textInputElement.value?"none":"flex",i.addEventListener("click",s=>{s.stopPropagation(),this.openPopover()}),e.appendChild(this.previewElement),e.appendChild(this.textInputElement),e.appendChild(i),this.placeholderTrigger=i,t.appendChild(e),this.createPopover(),this.element=t,t}isValidGradientValue(t){return!t||typeof t!="object"||!t.type||!["linear","radial","solid"].includes(t.type)||t.type!=="solid"&&typeof t.angle!="number"||!Array.isArray(t.stops)||t.stops.length===0?!1:t.stops.every(e=>e&&typeof e.color=="string"&&typeof e.position=="number")}generateCSS(t){if(!t||!this.isValidGradientValue(t))return console.warn("Invalid gradient value passed to generateCSS:",t),console.trace("Stack trace for invalid gradient value"),"linear-gradient(90deg, #a84b4b 0%, #786666 100%)";if(t.type==="solid"){const i=t.stops&&t.stops.length>0?t.stops[0]:null;if(!i)return"#000000";const s=i.opacity!==void 0?i.opacity:100,n=Math.round(s/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i.color.replace("#","")}${n}`}if(!t.stops||!Array.isArray(t.stops)||t.stops.length===0)return console.warn("Invalid gradient stops in generateCSS:",t),"linear-gradient(90deg, #a84b4b 0%, #786666 100%)";const e=t.stops.map(i=>{const s=i.opacity!==void 0?i.opacity:100;return`${this.addOpacityToColor(i.color,s)} ${i.position}%`}).join(", ");return t.type==="radial"?`radial-gradient(circle, ${e})`:`linear-gradient(${t.angle}deg, ${e})`}addOpacityToColor(t,e){const i=e/100;if(t.startsWith("#")){const s=t.slice(1),n=parseInt(s.substr(0,2),16),o=parseInt(s.substr(2,2),16),a=parseInt(s.substr(4,2),16);return`rgba(${n}, ${o}, ${a}, ${i})`}if(t.startsWith("rgb("))return t.replace("rgb(","rgba(").replace(")",`, ${i})`);if(t.startsWith("rgba("))return t.replace(/,\s*[\d.]+\)$/,`, ${i})`);if(t.startsWith("hsl(")){const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1]),o=parseInt(s[2])/100,a=parseInt(s[3])/100,{r:l,g:r,b:c}=this.hslToRgb(n,o,a);return`rgba(${l}, ${r}, ${c}, ${i})`}}if(t.startsWith("hsla(")){const s=t.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(s){const n=parseInt(s[1]),o=parseInt(s[2])/100,a=parseInt(s[3])/100,{r:l,g:r,b:c}=this.hslToRgb(n,o,a);return`rgba(${l}, ${r}, ${c}, ${i})`}}try{const s=t.replace("#","");if(/^[0-9A-Fa-f]{6}$/.test(s)){const n=parseInt(s.substr(0,2),16),o=parseInt(s.substr(2,2),16),a=parseInt(s.substr(4,2),16);return`rgba(${n}, ${o}, ${a}, ${i})`}}catch{}return t}hexToRgb(t){const e=t.replace("#",""),i=e.length===3?e.split("").map(a=>a+a).join(""):e,s=parseInt(i.slice(0,2),16),n=parseInt(i.slice(2,4),16),o=parseInt(i.slice(4,6),16);return{r:s,g:n,b:o}}createPopover(){if(this.popoverElement)return;this.popoverElement=document.createElement("div"),this.popoverElement.className="gradient-popover",this.popoverElement.style.display="none";const t=document.createElement("div");t.className="gradient-popover-header";const e=document.createElement("span");e.textContent="Fill";const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=pt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(e),t.appendChild(i);const s=document.createElement("div");s.className="gradient-editor";const n=this.createTypeTabs();s.appendChild(n);const o=document.createElement("div");o.className="gradient-editor-content",this.updatePopoverContent(o),s.appendChild(o),this.popoverElement.appendChild(t),this.popoverElement.appendChild(s),document.body.appendChild(this.popoverElement)}createTypeTabs(){var s,n;const t=document.createElement("div");t.className="gradient-type-tabs";const e=document.createElement("button");e.type="button",e.className=`gradient-type-tab ${((s=this.value)==null?void 0:s.type)==="solid"?"active":""}`,e.textContent="Solid",e.addEventListener("click",()=>this.switchType("solid"));const i=document.createElement("button");return i.type="button",i.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)!=="solid"?"active":""}`,i.textContent="Gradient",i.addEventListener("click",()=>{var a,l;const o=((a=this.value)==null?void 0:a.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(o)}),t.appendChild(e),t.appendChild(i),t}switchType(t){var n,o,a;if(!this.value)return;this.value.type=t,t!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]);const e=(n=this.popoverElement)==null?void 0:n.querySelectorAll(".gradient-type-tab");e==null||e.forEach((l,r)=>{l.classList.remove("active"),(r===0&&t==="solid"||r===1&&t!=="solid")&&l.classList.add("active")});const i=(o=this.popoverElement)==null?void 0:o.querySelectorAll(".gradient-subtype-tab");i==null||i.forEach((l,r)=>{l.classList.remove("active"),(r===0&&t==="linear"||r===1&&t==="radial")&&l.classList.add("active")});const s=(a=this.popoverElement)==null?void 0:a.querySelector(".gradient-editor-content");s&&this.updatePopoverContent(s),this.updateUI(),this.triggerChange()}updatePopoverContent(t){t.innerHTML="",this.value&&(this.value.type==="solid"?this.createSolidEditor(t):this.createGradientEditor(t))}createSolidEditor(t){var o,a,l,r,c,h;const e=document.createElement("div");e.className="gradient-solid-picker embedded-color-picker";const i=((l=(a=(o=this.value)==null?void 0:o.stops)==null?void 0:a[0])==null?void 0:l.color)||"#000000",s=((h=(c=(r=this.value)==null?void 0:r.stops)==null?void 0:c[0])==null?void 0:h.opacity)||100,n=this.createEmbeddedColorPickerWithOpacity(i,s,(d,m)=>{this.value&&(!this.value.stops||this.value.stops.length===0?this.value.stops=[{color:d,position:0,opacity:m}]:(this.value.stops[0].color=d,this.value.stops[0].opacity=m),this.updateUI(),this.triggerChange())});e.appendChild(n),t.appendChild(e)}createEmbeddedColorPickerWithOpacity(t,e,i){const s=document.createElement("div");s.className="embedded-color-picker-content";const n=document.createElement("div");n.className="color-picker-area embedded";const o=document.createElement("div");o.className="color-picker-marker",n.appendChild(o);const a=document.createElement("div");a.className="color-picker-hue-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=`<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
204
|
+
</svg>`;const r=document.createElement("div");r.className="color-picker-hue",this.hueSlider=r;const c=document.createElement("div");c.className="color-picker-hue-marker",this.hueMarker=c,r.appendChild(c),a.appendChild(l),a.appendChild(r);const h=document.createElement("div");h.className="color-picker-opacity",this.opacitySlider=h;const d=document.createElement("div");d.className="color-picker-opacity-marker",this.opacityMarker=d,h.appendChild(d);const u=document.createElement("div");u.className="color-picker-format-section";const g=document.createElement("select");g.className="color-picker-format-select",this.formatSelect=g;const C=document.createElement("option");C.value="hex",C.textContent="HEX";const m=document.createElement("option");m.value="rgb",m.textContent="RGB";const y=document.createElement("option");y.value="hsl",y.textContent="HSL",g.appendChild(C),g.appendChild(m),g.appendChild(y);const f=document.createElement("input");f.type="text",f.className="color-picker-color-input",f.value=this.currentColor,this.hexInput=f;const E=document.createElement("div");E.className="color-picker-input-container";const V=document.createElement("button");return V.className="color-picker-copy-inside",V.textContent="Copy",V.addEventListener("click",()=>this.copyToClipboard()),E.appendChild(f),E.appendChild(V),u.appendChild(g),u.appendChild(E),t.appendChild(e),t.appendChild(n),t.appendChild(a),t.appendChild(h),t.appendChild(u),this.setupEyedropper(l),this.setupEventListeners(),t.addEventListener("click",D=>{D.stopPropagation()}),t}setupEventListeners(){this.colorArea.addEventListener("mousedown",t=>this.startColorDrag(t)),this.colorArea.addEventListener("click",t=>{t.stopPropagation(),this.updateColorFromArea(t)}),this.hueSlider.addEventListener("mousedown",t=>this.startHueDrag(t)),this.hueSlider.addEventListener("click",t=>{t.stopPropagation(),this.updateHueFromSlider(t)}),this.formatSelect.addEventListener("change",()=>this.updateColorInput()),this.hexInput.addEventListener("input",t=>this.updateColorFromInput(t)),this.hexInput.addEventListener("blur",t=>this.validateColorInput(t)),this.opacitySlider.addEventListener("mousedown",t=>this.startOpacityDrag(t)),this.opacitySlider.addEventListener("click",t=>{t.stopPropagation(),this.updateOpacityFromSlider(t)})}startColorDrag(t){t.preventDefault(),t.stopPropagation(),this.updateColorFromArea(t);const e=s=>this.updateColorFromArea(s),i=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",e),document.addEventListener("mouseup",i)}startHueDrag(t){t.preventDefault(),t.stopPropagation(),this.updateHueFromSlider(t);const e=s=>this.updateHueFromSlider(s),i=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",e),document.addEventListener("mouseup",i)}updateColorFromArea(t){const e=this.colorArea.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),s=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${s*100}%`,this.updateColorFromSV(i,1-s)}updateHueFromSlider(t){this.isUpdatingHue=!0;const e=this.hueSlider.getBoundingClientRect();let i=(t.clientX-e.left)/e.width;i=Math.max(.002,Math.min(.996,i)),this.hueMarker.style.left=`${i*100}%`;const s=i*360;this.updateHue(s),this.isUpdatingHue=!1}updateColorFromSV(t,e){const i=this.getCurrentHue(),s=this.hsvToHex(i,t,e);this.setColor(s)}updateHue(t){t=Math.max(.5,Math.min(358.5,t)),this.colorArea.getBoundingClientRect();const e=parseFloat(this.colorMarker.style.left||"50%")/100,i=parseFloat(this.colorMarker.style.top||"50%")/100;this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${t}, 100%, 50%))`;const s=e,n=1-i,o=this.hsvToHex(t,s,n);this.setColor(o)}getCurrentHue(){const e=parseFloat(this.hueMarker.style.left||"0%")/100*360;return Math.max(.5,Math.min(358.5,e))}updateColorInput(){const t=this.formatSelect.value,{h:e,s:i,v:s}=this.hexToHsv(this.currentColor);switch(t){case"hex":this.hexInput.value=this.currentColor;break;case"rgb":const{r:n,g:o,b:a}=this.hexToRgb(this.currentColor);this.hexInput.value=`rgb(${n}, ${o}, ${a})`;break;case"hsl":const{hue:l,sat:r,lightness:c}=this.hsvToHsl(e,i,s);this.hexInput.value=`hsl(${Math.round(l)}, ${Math.round(r*100)}%, ${Math.round(c*100)}%)`;break}}updateColorFromInput(t){const e=t.target.value,i=this.formatSelect.value;let s="";if(i==="hex"&&/^#[0-9A-Fa-f]{6}$/.test(e))s=e;else if(i==="rgb"){const n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const o=parseInt(n[1]),a=parseInt(n[2]),l=parseInt(n[3]);o<=255&&a<=255&&l<=255&&(s=`#${o.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`)}}else if(i==="hsl"){const n=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const o=parseInt(n[1]),a=parseInt(n[2])/100,l=parseInt(n[3])/100;if(o<=360&&a<=1&&l<=1){const r=l+a*Math.min(l,1-l),c=r===0?0:2*(1-l/r);s=this.hsvToHex(o,c,r)}}}s&&this.setColor(s)}validateColorInput(t){this.updateColorInput()}startOpacityDrag(t){t.preventDefault(),t.stopPropagation(),this.updateOpacityFromSlider(t);const e=s=>this.updateOpacityFromSlider(s),i=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",e),document.addEventListener("mouseup",i)}updateOpacityFromSlider(t){const e=this.opacitySlider.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.opacityMarker.style.left=`${i*100}%`,this.currentOpacity=Math.round(i*100),this.onColorChange&&this.onColorChange(this.currentColor,this.currentOpacity)}updateOpacityBackground(){const{r:t,g:e,b:i}=this.hexToRgb(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`)}isValidHex(t){return/^#[0-9A-Fa-f]{6}$/.test(t)}hsvToHex(t,e,i){t=Math.max(0,Math.min(359.9,t)),e=Math.max(0,Math.min(1,e)),i=Math.max(0,Math.min(1,i));const s=i*e,n=s*(1-Math.abs(t/60%2-1)),o=i-s;let a=0,l=0,r=0;return t<60?(a=s,l=n,r=0):t<120?(a=n,l=s,r=0):t<180?(a=0,l=s,r=n):t<240?(a=0,l=n,r=s):t<300?(a=n,l=0,r=s):(a=s,l=0,r=n),a=Math.round((a+o)*255),l=Math.round((l+o)*255),r=Math.round((r+o)*255),`#${a.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}setColor(t){this.currentColor=t,this.updatePickerFromColor(t),this.updateColorInput(),this.updateOpacityBackground(),this.onColorChange&&this.onColorChange(t,this.currentOpacity)}setupEyedropper(t){const e=async()=>{if("EyeDropper"in window)try{const n=(await new window.EyeDropper().open()).sRGBHex;this.currentColor=n,this.updateColorInput(),this.updateColorAreaFromHex(n),this.onColorChange&&this.onColorChange(n)}catch(i){console.log("User cancelled eyedropper or error occurred:",i)}else alert("EyeDropper API is not supported in this browser. Try using Chrome 95+ or Edge 95+.")};t.addEventListener("click",e)}updateColorAreaFromHex(t){this.hexInput.value=t}copyToClipboard(){navigator.clipboard.writeText(this.currentColor).catch(()=>{this.hexInput.select(),document.execCommand("copy")})}open(t,e,i){this.currentColor=t,this.currentOpacity=i??100,this.updateColorInput(),this.updatePickerFromColor(t),this.updateOpacityBackground(),this.opacityMarker.style.left=`${this.currentOpacity}%`,this.isOpen=!0,this.element.style.display="block";const s=e.getBoundingClientRect(),n=window.innerWidth,o=window.innerHeight;this.element.style.position="fixed",this.element.style.zIndex="10002";let a=s.right+8,l=s.top;a+408>n&&(a=s.left-408-8),a<8&&(a=Math.max(8,(n-408)/2)),l+500>o&&(l=Math.max(8,o-500-8)),this.element.style.left=`${a}px`,this.element.style.top=`${l}px`,this.element.parentElement||document.body.appendChild(this.element),this.updatePickerFromColor(t),setTimeout(()=>{document.addEventListener("click",this.handleOutsideClick,!0)},50)}updatePickerFromColor(t){const{h:e,s:i,v:s}=this.hexToHsv(t);this.isUpdatingHue||(this.hueMarker.style.left=`${e/360*100}%`),this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${e}, 100%, 50%))`}hexToHsv(t){const e=parseInt(t.slice(1,3),16)/255,i=parseInt(t.slice(3,5),16)/255,s=parseInt(t.slice(5,7),16)/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=n-o;let l=0;const r=n===0?0:a/n,c=n;return a!==0&&(n===e?l=(i-s)/a%6:n===i?l=(s-e)/a+2:l=(e-i)/a+4),{h:l*60,s:r,v:c}}hexToRgb(t){const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),s=parseInt(t.slice(5,7),16);return{r:e,g:i,b:s}}hsvToHsl(t,e,i){const s=i*(1-e/2),n=s===0||s===1?0:(i-s)/Math.min(s,1-s);return{hue:t,sat:n,lightness:s}}makeDraggable(t,e){let i=!1,s=0,n=0,o=0,a=0;const l=h=>{if(h.target.closest("button"))return;h.preventDefault(),h.stopPropagation(),i=!0,s=h.clientX,n=h.clientY;const d=e.getBoundingClientRect();o=d.left,a=d.top,e.classList.add("dragging"),document.addEventListener("mousemove",r),document.addEventListener("mouseup",c),document.body.style.userSelect="none"},r=h=>{if(!i)return;h.preventDefault(),h.stopPropagation();const d=h.clientX-s,u=h.clientY-n;let g=o+d,C=a+u;const m=window.innerWidth,y=window.innerHeight,f=e.offsetWidth,E=e.offsetHeight;g=Math.max(8,Math.min(m-f-8,g)),C=Math.max(8,Math.min(y-E-8,C)),e.style.left=`${g}px`,e.style.top=`${C}px`},c=h=>{i&&(i=!1,h.preventDefault(),h.stopPropagation(),e.classList.remove("dragging"),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",c),document.body.style.userSelect="")};t.addEventListener("mousedown",l)}close(){this.isOpen=!1,this.element.style.display="none",document.removeEventListener("click",this.handleOutsideClick,!0)}getElement(){return this.element}}class Jt extends S{constructor(t={}){let e;if(typeof t.default=="string")if(t.default.match(/^#[a-fA-F0-9]{3,8}$/)){let i=t.default,s=100;if(i.length===9){const n=parseInt(i.slice(-2),16);s=Math.round(n/255*100),i=i.slice(0,7)}e={type:"solid",angle:90,stops:[{color:i,position:0,opacity:s}]}}else e=at(t.default)||{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]};else e=t.default||{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]};(!e.stops||e.stops.length===0)&&(e.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),super({...t,title:t.title||"Gradient",default:e}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewElement=null,this.textInputElement=null,this.popoverElement=null,this.placeholderTrigger=null,this.isPopoverOpen=!1,this.isUserEditing=!1,this.handleBackgroundClick=i=>{var r;if(!this.popoverElement||!this.isPopoverOpen)return;const s=i.target,n=this.popoverElement.contains(s),o=(r=this.element)==null?void 0:r.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(c=>c.contains(s));!n&&!o&&!l&&this.closePopover()},this.detectChange=t.detectChange,this.forText=t.forText||!1}getSafeValue(){return!this.value||!this.isValidGradientValue(this.value)?(console.warn("Invalid value detected, returning default:",this.value),this.getDefaultGradientValue()):this.value}setValue(t){let e;if(!t)console.warn("Undefined value in setValue, using default"),e=this.getDefaultGradientValue();else if(typeof t=="string")if(t.match(/^#[a-fA-F0-9]{3,8}$/)){let i=t,s=100;if(i.length===9){const n=parseInt(i.slice(-2),16);s=Math.round(n/255*100),i=i.slice(0,7)}e={type:"solid",angle:90,stops:[{color:i,position:0,opacity:s}]}}else{const i=at(t);i&&this.isValidGradientValue(i)?e=i:(console.warn("Failed to parse string value, using default:",t),e=this.getDefaultGradientValue())}else if(typeof t=="object"&&t.background){console.warn("Received CSS style object, extracting background value:",t);const i=t.background;if(typeof i=="string"){this.setValue(i);return}else e=this.getDefaultGradientValue()}else this.isValidGradientValue(t)?(e=t,e.stops&&e.stops.length>0?e.stops.forEach(i=>{i.opacity===void 0&&(i.opacity=100)}):e.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]):(console.warn("Invalid gradient value in setValue, using default:",t),e=this.getDefaultGradientValue());super.setValue(e),this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent()}getDefaultGradientValue(){return this.props&&this.props.default&&this.isValidGradientValue(this.props.default)?this.props.default:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]}}updateUI(){if(this.previewElement&&this.value)if(this.value.type==="solid"){const t=this.value.stops&&this.value.stops.length>0?this.value.stops[0]:null;if(t){const e=t.opacity!==void 0?t.opacity:100;this.previewElement.style.background=this.addOpacityToColor(t.color,e)}}else this.previewElement.style.background=this.generateCSS(this.getSafeValue());this.textInputElement&&this.value&&!this.isUserEditing&&(this.textInputElement.value=this.generateDisplayText(this.value))}generateDisplayText(t){if(!t)return"";if(t.type==="solid"){const i=t.stops&&t.stops.length>0?t.stops[0]:null;return i?i.color.replace("#","").toUpperCase():"Color"}t.stops&&t.stops.length;const e=t.type==="linear"?"Linear":"Radial";return t.type==="linear"?`${e} ${t.angle}°`:`${e} Gradient`}draw(){const t=document.createElement("div");if(t.className="gradient-setting-wrapper",this.props.title){const s=document.createElement("div");s.className="icon-container";const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,s.appendChild(n),t.appendChild(s)}const e=document.createElement("div");e.className="gradient-input-wrapper",this.previewElement=document.createElement("div"),this.previewElement.className="gradient-mini-preview",this.previewElement.style.background=this.value?this.generateCSS(this.getSafeValue()):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.textInputElement=document.createElement("input"),this.textInputElement.type="text",this.textInputElement.className="gradient-text-input",this.textInputElement.placeholder="Enter gradient CSS or paste color...",this.textInputElement.value=this.value?this.generateDisplayText(this.value):"",this.textInputElement.readOnly=!1,this.previewElement.addEventListener("click",()=>this.openPopover()),this.textInputElement.addEventListener("focus",()=>{this.isUserEditing=!0,this.value&&(this.textInputElement.value=this.generateCSS(this.getSafeValue()))}),this.textInputElement.addEventListener("blur",()=>{this.isUserEditing=!1,this.value&&(this.textInputElement.value=this.generateDisplayText(this.value)),this.placeholderTrigger&&(this.placeholderTrigger.style.display=this.textInputElement.value?"none":"flex")}),this.textInputElement.addEventListener("paste",s=>this.handlePaste(s)),this.textInputElement.addEventListener("input",s=>this.handleInput(s)),this.textInputElement.addEventListener("keydown",s=>{s.key==="Enter"&&(this.handleInput(s),this.textInputElement.blur()),s.key==="Escape"&&(this.value&&(this.textInputElement.value=this.generateCSS(this.getSafeValue())),this.textInputElement.blur())});const i=document.createElement("div");return i.className="gradient-input-placeholder-trigger",i.textContent=this.textInputElement.placeholder||"",i.style.display=this.textInputElement.value?"none":"flex",i.addEventListener("click",s=>{s.stopPropagation(),this.openPopover()}),e.appendChild(this.previewElement),e.appendChild(this.textInputElement),e.appendChild(i),this.placeholderTrigger=i,t.appendChild(e),this.createPopover(),this.element=t,t}isValidGradientValue(t){return!t||typeof t!="object"||!t.type||!["linear","radial","solid"].includes(t.type)||t.type!=="solid"&&typeof t.angle!="number"||!Array.isArray(t.stops)||t.stops.length===0?!1:t.stops.every(e=>e&&typeof e.color=="string"&&typeof e.position=="number")}generateCSS(t){if(!t||!this.isValidGradientValue(t))return console.warn("Invalid gradient value passed to generateCSS:",t),console.trace("Stack trace for invalid gradient value"),"linear-gradient(90deg, #a84b4b 0%, #786666 100%)";if(t.type==="solid"){const i=t.stops&&t.stops.length>0?t.stops[0]:null;if(!i)return"#000000";const s=i.opacity!==void 0?i.opacity:100,n=Math.round(s/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i.color.replace("#","")}${n}`}if(!t.stops||!Array.isArray(t.stops)||t.stops.length===0)return console.warn("Invalid gradient stops in generateCSS:",t),"linear-gradient(90deg, #a84b4b 0%, #786666 100%)";const e=t.stops.map(i=>{const s=i.opacity!==void 0?i.opacity:100;return`${this.addOpacityToColor(i.color,s)} ${i.position}%`}).join(", ");return t.type==="radial"?`radial-gradient(circle, ${e})`:`linear-gradient(${t.angle}deg, ${e})`}addOpacityToColor(t,e){const i=e/100;if(t.startsWith("#")){const s=t.slice(1),n=parseInt(s.substr(0,2),16),o=parseInt(s.substr(2,2),16),a=parseInt(s.substr(4,2),16);return`rgba(${n}, ${o}, ${a}, ${i})`}if(t.startsWith("rgb("))return t.replace("rgb(","rgba(").replace(")",`, ${i})`);if(t.startsWith("rgba("))return t.replace(/,\s*[\d.]+\)$/,`, ${i})`);if(t.startsWith("hsl(")){const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1]),o=parseInt(s[2])/100,a=parseInt(s[3])/100,{r:l,g:r,b:c}=this.hslToRgb(n,o,a);return`rgba(${l}, ${r}, ${c}, ${i})`}}if(t.startsWith("hsla(")){const s=t.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(s){const n=parseInt(s[1]),o=parseInt(s[2])/100,a=parseInt(s[3])/100,{r:l,g:r,b:c}=this.hslToRgb(n,o,a);return`rgba(${l}, ${r}, ${c}, ${i})`}}try{const s=t.replace("#","");if(/^[0-9A-Fa-f]{6}$/.test(s)){const n=parseInt(s.substr(0,2),16),o=parseInt(s.substr(2,2),16),a=parseInt(s.substr(4,2),16);return`rgba(${n}, ${o}, ${a}, ${i})`}}catch{}return t}hexToRgb(t){const e=t.replace("#",""),i=e.length===3?e.split("").map(a=>a+a).join(""):e,s=parseInt(i.slice(0,2),16),n=parseInt(i.slice(2,4),16),o=parseInt(i.slice(4,6),16);return{r:s,g:n,b:o}}createPopover(){if(this.popoverElement)return;this.popoverElement=document.createElement("div"),this.popoverElement.className="gradient-popover",this.popoverElement.style.display="none";const t=document.createElement("div");t.className="gradient-popover-header";const e=document.createElement("span");e.textContent="Fill";const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=pt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(e),t.appendChild(i);const s=document.createElement("div");s.className="gradient-editor";const n=this.createTypeTabs();s.appendChild(n);const o=document.createElement("div");o.className="gradient-editor-content",this.updatePopoverContent(o),s.appendChild(o),this.popoverElement.appendChild(t),this.popoverElement.appendChild(s),document.body.appendChild(this.popoverElement)}createTypeTabs(){var s,n;const t=document.createElement("div");t.className="gradient-type-tabs";const e=document.createElement("button");e.type="button",e.className=`gradient-type-tab ${((s=this.value)==null?void 0:s.type)==="solid"?"active":""}`,e.textContent="Solid",e.addEventListener("click",()=>this.switchType("solid"));const i=document.createElement("button");return i.type="button",i.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)!=="solid"?"active":""}`,i.textContent="Gradient",i.addEventListener("click",()=>{var a,l;const o=((a=this.value)==null?void 0:a.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(o)}),t.appendChild(e),t.appendChild(i),t}switchType(t){var n,o,a;if(!this.value)return;this.value.type=t,t!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]);const e=(n=this.popoverElement)==null?void 0:n.querySelectorAll(".gradient-type-tab");e==null||e.forEach((l,r)=>{l.classList.remove("active"),(r===0&&t==="solid"||r===1&&t!=="solid")&&l.classList.add("active")});const i=(o=this.popoverElement)==null?void 0:o.querySelectorAll(".gradient-subtype-tab");i==null||i.forEach((l,r)=>{l.classList.remove("active"),(r===0&&t==="linear"||r===1&&t==="radial")&&l.classList.add("active")});const s=(a=this.popoverElement)==null?void 0:a.querySelector(".gradient-editor-content");s&&this.updatePopoverContent(s),this.updateUI(),this.triggerChange()}updatePopoverContent(t){t.innerHTML="",this.value&&(this.value.type==="solid"?this.createSolidEditor(t):this.createGradientEditor(t))}createSolidEditor(t){var o,a,l,r,c,h;const e=document.createElement("div");e.className="gradient-solid-picker embedded-color-picker";const i=((l=(a=(o=this.value)==null?void 0:o.stops)==null?void 0:a[0])==null?void 0:l.color)||"#000000",s=((h=(c=(r=this.value)==null?void 0:r.stops)==null?void 0:c[0])==null?void 0:h.opacity)||100,n=this.createEmbeddedColorPickerWithOpacity(i,s,(d,u)=>{this.value&&(!this.value.stops||this.value.stops.length===0?this.value.stops=[{color:d,position:0,opacity:u}]:(this.value.stops[0].color=d,this.value.stops[0].opacity=u),this.updateUI(),this.triggerChange())});e.appendChild(n),t.appendChild(e)}createEmbeddedColorPickerWithOpacity(t,e,i){const s=document.createElement("div");s.className="embedded-color-picker-content";const n=document.createElement("div");n.className="color-picker-area embedded";const o=document.createElement("div");o.className="color-picker-marker",n.appendChild(o);const a=document.createElement("div");a.className="color-picker-hue-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=`<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
205
205
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.1972 3.29156C18.936 3.03034 18.6259 2.82313 18.2847 2.68176C17.9434 2.54039 17.5777 2.46763 17.2083 2.46763C16.8389 2.46763 16.4731 2.54039 16.1319 2.68176C15.7906 2.82313 15.4805 3.03034 15.2194 3.29156L13.7822 4.72875C13.2585 4.4772 12.6697 4.39449 12.097 4.49207C11.5243 4.58964 10.9961 4.86267 10.5853 5.27343L9.91687 5.94281C9.74268 6.11693 9.6045 6.32366 9.51023 6.5512C9.41595 6.77873 9.36743 7.02261 9.36743 7.2689C9.36743 7.5152 9.41595 7.75907 9.51023 7.98661C9.6045 8.21414 9.74268 8.42088 9.91687 8.595L3.83625 14.6747C3.57512 14.936 3.36803 15.2462 3.2268 15.5875C3.08556 15.9288 3.01296 16.2947 3.01312 16.6641V18.3516C3.01312 18.6499 3.13165 18.9361 3.34263 19.1471C3.55361 19.358 3.83975 19.4766 4.13812 19.4766H5.82562C6.57129 19.4759 7.28618 19.1792 7.81312 18.6516L13.8937 12.5728C14.0679 12.747 14.2746 12.8852 14.5021 12.9795C14.7297 13.0737 14.9735 13.1223 15.2198 13.1223C15.4661 13.1223 15.71 13.0737 15.9375 12.9795C16.1651 12.8852 16.3718 12.747 16.5459 12.5728L17.2153 11.9025C17.6261 11.4917 17.8991 10.9635 17.9967 10.3908C18.0942 9.81811 18.0115 9.22926 17.76 8.70562L19.1972 7.26937C19.4584 7.0082 19.6656 6.69813 19.807 6.35687C19.9484 6.01561 20.0211 5.64985 20.0211 5.28047C20.0211 4.91108 19.9484 4.54532 19.807 4.20406C19.6656 3.8628 19.4584 3.55273 19.1972 3.29156ZM5.16281 16.0012L11.2425 9.92062L12.5681 11.2462L6.48844 17.3269C6.31266 17.5027 6.07424 17.6015 5.82562 17.6016H4.88812V16.6641C4.88818 16.4154 4.98698 16.177 5.16281 16.0012Z" fill="#353C47"/>
|
|
206
|
-
</svg>`;const r=document.createElement("div");r.className="color-picker-hue embedded";const c=document.createElement("div");c.className="color-picker-hue-marker",r.appendChild(c),a.appendChild(l),a.appendChild(r);const h=document.createElement("div");h.className="color-picker-opacity embedded";const d=document.createElement("div");d.className="color-picker-opacity-marker",h.appendChild(d);const
|
|
206
|
+
</svg>`;const r=document.createElement("div");r.className="color-picker-hue embedded";const c=document.createElement("div");c.className="color-picker-hue-marker",r.appendChild(c),a.appendChild(l),a.appendChild(r);const h=document.createElement("div");h.className="color-picker-opacity embedded";const d=document.createElement("div");d.className="color-picker-opacity-marker",h.appendChild(d);const u=document.createElement("div");u.className="color-picker-format-section embedded";const g=document.createElement("select");g.className="color-picker-format-select";const C=document.createElement("option");C.value="hex",C.textContent="HEX";const m=document.createElement("option");m.value="rgb",m.textContent="RGB";const y=document.createElement("option");y.value="hsl",y.textContent="HSL",g.appendChild(C),g.appendChild(m),g.appendChild(y);const f=document.createElement("input");f.type="text",f.className="color-picker-color-input",f.value=t;const E=document.createElement("div");E.className="color-picker-input-container";const V=document.createElement("button");return V.className="color-picker-copy-inside",V.textContent="Copy",E.appendChild(f),E.appendChild(V),u.appendChild(g),u.appendChild(E),s.appendChild(n),s.appendChild(a),s.appendChild(h),s.appendChild(u),this.setupEmbeddedColorPicker(n,o,r,c,g,f,V,l,t,e,i),this.setupOpacitySlider(h,d,t,e,i),s}createEmbeddedColorPicker(t,e,i){const s=document.createElement("div");s.className="embedded-color-picker-content";const n=document.createElement("div");n.className="color-picker-area embedded";const o=document.createElement("div");o.className="color-picker-marker",n.appendChild(o);const a=document.createElement("div");a.className="color-picker-hue-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=`<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
207
207
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.1972 3.29156C18.936 3.03034 18.6259 2.82313 18.2847 2.68176C17.9434 2.54039 17.5777 2.46763 17.2083 2.46763C16.8389 2.46763 16.4731 2.54039 16.1319 2.68176C15.7906 2.82313 15.4805 3.03034 15.2194 3.29156L13.7822 4.72875C13.2585 4.4772 12.6697 4.39449 12.097 4.49207C11.5243 4.58964 10.9961 4.86267 10.5853 5.27343L9.91687 5.94281C9.74268 6.11693 9.6045 6.32366 9.51023 6.5512C9.41595 6.77873 9.36743 7.02261 9.36743 7.2689C9.36743 7.5152 9.41595 7.75907 9.51023 7.98661C9.6045 8.21414 9.74268 8.42088 9.91687 8.595L3.83625 14.6747C3.57512 14.936 3.36803 15.2462 3.2268 15.5875C3.08556 15.9288 3.01296 16.2947 3.01312 16.6641V18.3516C3.01312 18.6499 3.13165 18.9361 3.34263 19.1471C3.55361 19.358 3.83975 19.4766 4.13812 19.4766H5.82562C6.57129 19.4759 7.28618 19.1792 7.81312 18.6516L13.8937 12.5728C14.0679 12.747 14.2746 12.8852 14.5021 12.9795C14.7297 13.0737 14.9735 13.1223 15.2198 13.1223C15.4661 13.1223 15.71 13.0737 15.9375 12.9795C16.1651 12.8852 16.3718 12.747 16.5459 12.5728L17.2153 11.9025C17.6261 11.4917 17.8991 10.9635 17.9967 10.3908C18.0942 9.81811 18.0115 9.22926 17.76 8.70562L19.1972 7.26937C19.4584 7.0082 19.6656 6.69813 19.807 6.35687C19.9484 6.01561 20.0211 5.64985 20.0211 5.28047C20.0211 4.91108 19.9484 4.54532 19.807 4.20406C19.6656 3.8628 19.4584 3.55273 19.1972 3.29156ZM5.16281 16.0012L11.2425 9.92062L12.5681 11.2462L6.48844 17.3269C6.31266 17.5027 6.07424 17.6015 5.82562 17.6016H4.88812V16.6641C4.88818 16.4154 4.98698 16.177 5.16281 16.0012Z" fill="#353C47"/>
|
|
208
|
-
</svg>`;const r=document.createElement("div");r.className="color-picker-hue embedded";const c=document.createElement("div");c.className="color-picker-hue-marker",r.appendChild(c),a.appendChild(l),a.appendChild(r);const h=document.createElement("div");h.className="color-picker-format-section embedded";const d=document.createElement("select");d.className="color-picker-format-select";const
|
|
208
|
+
</svg>`;const r=document.createElement("div");r.className="color-picker-hue embedded";const c=document.createElement("div");c.className="color-picker-hue-marker",r.appendChild(c),a.appendChild(l),a.appendChild(r);const h=document.createElement("div");h.className="color-picker-format-section embedded";const d=document.createElement("select");d.className="color-picker-format-select";const u=document.createElement("option");u.value="hex",u.textContent="HEX";const g=document.createElement("option");g.value="rgb",g.textContent="RGB";const C=document.createElement("option");C.value="hsl",C.textContent="HSL",d.appendChild(u),d.appendChild(g),d.appendChild(C);const m=document.createElement("input");m.type="text",m.className="color-picker-color-input",m.value=t;const y=document.createElement("div");y.className="color-picker-input-container";const f=document.createElement("button");return f.className="color-picker-copy-inside",f.textContent="Copy",y.appendChild(m),y.appendChild(f),h.appendChild(d),h.appendChild(y),s.appendChild(n),s.appendChild(a),s.appendChild(h),this.setupEmbeddedColorPicker(n,o,r,c,d,m,f,l,t,e,i),s}setupEmbeddedColorPicker(t,e,i,s,n,o,a,l,r,c,h){let d=r;const{h:u,s:g,v:C}=this.hexToHsv(r);let m=c;s.style.left=`${u/360*100}%`,e.style.left=`${g*100}%`,e.style.top=`${(1-C)*100}%`,t.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${u}, 100%, 50%))`;const y=(v,w=m)=>{d=v,m=Math.round(w),f(),h(v,m)},f=()=>{const v=n.value,{h:w,s:x,v:k}=this.hexToHsv(d);switch(v){case"hex":o.value=d;break;case"rgb":const{r:T,g:$,b:z}=this.hexToRgb(d);o.value=`rgb(${T}, ${$}, ${z})`;break;case"hsl":const{hue:R,sat:_,lightness:Q}=this.hsvToHsl(w,x,k);o.value=`hsl(${Math.round(R)}, ${Math.round(_*100)}%, ${Math.round(Q*100)}%)`;break}},E=()=>parseFloat(s.style.left||"0%")/100*360,V=(v,w)=>{const x=E(),k=this.hsvToHex(x,v,w);y(k,m)},D=v=>{v=Math.max(.1,Math.min(358.9,v));const w=parseFloat(e.style.left||"50%")/100,x=parseFloat(e.style.top||"50%")/100;t.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${v}, 100%, 50%))`;const k=w,T=1-x,$=this.hsvToHex(v,k,T);y($,m)},F=v=>{v.stopPropagation();const w=t.getBoundingClientRect(),x=Math.max(0,Math.min(1,(v.clientX-w.left)/w.width)),k=Math.max(0,Math.min(1,(v.clientY-w.top)/w.height));e.style.left=`${x*100}%`,e.style.top=`${k*100}%`,V(x,1-k)},L=v=>{v.preventDefault(),v.stopPropagation(),F(v);const w=k=>F(k),x=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",x)},b=v=>{v.stopPropagation();const w=i.getBoundingClientRect();let x=(v.clientX-w.left)/w.width;x=Math.max(.001,Math.min(.998,x)),s.style.left=`${x*100}%`;const k=x*360;D(k)},M=v=>{v.preventDefault(),v.stopPropagation(),b(v);const w=k=>b(k),x=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",x)},P=v=>{const w=v.target.value,x=n.value;let k="";if(x==="hex"&&/^#[0-9A-Fa-f]{6}$/.test(w))k=w;else if(x==="rgb"){const T=w.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(T){const $=parseInt(T[1]),z=parseInt(T[2]),R=parseInt(T[3]);$<=255&&z<=255&&R<=255&&(k=`#${$.toString(16).padStart(2,"0")}${z.toString(16).padStart(2,"0")}${R.toString(16).padStart(2,"0")}`)}}else if(x==="hsl"){const T=w.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(T){const $=parseInt(T[1]),z=parseInt(T[2])/100,R=parseInt(T[3])/100;if($<=360&&z<=1&&R<=1){const _=R+z*Math.min(R,1-R),Q=_===0?0:2*(1-R/_);k=this.hsvToHex($,Q,_)}}}if(k){const{h:T,s:$,v:z}=this.hexToHsv(k);s.style.left=`${T/360*100}%`,e.style.left=`${$*100}%`,e.style.top=`${(1-z)*100}%`,t.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${T}, 100%, 50%))`,y(k,m)}},O=v=>{f()},H=()=>{f()},I=()=>{navigator.clipboard.writeText(o.value).catch(()=>{o.select(),document.execCommand("copy")})};f(),t.addEventListener("mousedown",L),t.addEventListener("click",F),i.addEventListener("mousedown",M),i.addEventListener("click",b),n.addEventListener("change",H),o.addEventListener("input",P),o.addEventListener("blur",O),a.addEventListener("click",I);const G=async()=>{if("EyeDropper"in window)try{const x=(await new window.EyeDropper().open()).sRGBHex,{h:k,s:T,v:$}=this.hexToHsv(x);s.style.left=`${k/360*100}%`,e.style.left=`${T*100}%`,e.style.top=`${(1-$)*100}%`,t.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${k}, 100%, 50%))`,y(x,m)}catch(v){console.log("User cancelled eyedropper or error occurred:",v)}else alert("EyeDropper API is not supported in this browser. Try using Chrome 95+ or Edge 95+.")};l.addEventListener("click",G)}hsvToHex(t,e,i){const s=i*e,n=s*(1-Math.abs(t/60%2-1)),o=i-s;let a=0,l=0,r=0;return t>=0&&t<60?(a=s,l=n,r=0):t>=60&&t<120?(a=n,l=s,r=0):t>=120&&t<180?(a=0,l=s,r=n):t>=180&&t<240?(a=0,l=n,r=s):t>=240&&t<300?(a=n,l=0,r=s):t>=300&&t<360&&(a=s,l=0,r=n),a=Math.round((a+o)*255),l=Math.round((l+o)*255),r=Math.round((r+o)*255),`#${a.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}setupOpacitySlider(t,e,i,s,n){const o=()=>{const{r:c,g:h,b:d}=this.hexToRgb(i);t.style.setProperty("--color-rgb",`${c}, ${h}, ${d}`)},a=()=>{e.style.left=`${s}%`};o(),a();let l=!1;const r=c=>{const h=t.getBoundingClientRect(),d=c.clientX-h.left,u=Math.max(0,Math.min(100,d/h.width*100)),g=Math.round(u);s=g,a(),n(i,g)};t.addEventListener("mousedown",c=>{l=!0,r(c)}),document.addEventListener("mousemove",c=>{l&&r(c)}),document.addEventListener("mouseup",()=>{l=!1})}hexToHsv(t){const e=parseInt(t.slice(1,3),16)/255,i=parseInt(t.slice(3,5),16)/255,s=parseInt(t.slice(5,7),16)/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=n-o;let l=0;const r=n===0?0:a/n,c=n;return a!==0&&(n===e?l=(i-s)/a%6:n===i?l=(s-e)/a+2:l=(e-i)/a+4),{h:l*60,s:r,v:c}}hsvToHsl(t,e,i){const s=i*(1-e/2),n=s===0||s===1?0:(i-s)/Math.min(s,1-s);return{hue:t,sat:n,lightness:s}}createGradientEditor(t){if(!this.value)return;const e=document.createElement("div");e.className="gradient-subtype-inline";const i=document.createElement("select");i.className="gradient-subtype-select";const s=document.createElement("option");s.value="linear",s.textContent="Linear";const n=document.createElement("option");n.value="radial",n.textContent="Radial",i.appendChild(s),i.appendChild(n),i.value=this.value.type==="radial"?"radial":"linear";const o=document.createElement("input");o.type="text",o.inputMode="numeric",o.className="gradient-degree-input";const a=this.value.angle!==void 0?this.value.angle:0;o.value=`${a}°`,o.setAttribute("data-min","0"),o.setAttribute("data-max","360"),o.style.width="75px",o.style.textAlign="center";const l=document.createElement("button");l.type="button",l.className="gradient-flip-btn",l.innerHTML=`
|
|
209
209
|
<svg width="15" height="17" viewBox="0 0 15 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
210
210
|
<path d="M14.1333 12.4667H0.8M0.8 12.4667L4.13333 9.13332M0.8 12.4667L4.13333 15.8M0.8 4.13332H14.1333M14.1333 4.13332L10.8 0.799988M14.1333 4.13332L10.8 7.46665" stroke="#919EAB" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
211
211
|
</svg>
|
|
212
|
-
`,l.title="Flip gradient",i.addEventListener("change",
|
|
212
|
+
`,l.title="Flip gradient",i.addEventListener("change",m=>{const y=m.target.value;this.switchType(y==="radial"?"radial":"linear")}),o.addEventListener("input",m=>{const y=m.target.value,f=parseInt(y);if(this.value&&!isNaN(f)){const E=Math.max(0,Math.min(360,f));this.value.angle=E,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}}),o.addEventListener("focus",m=>{const y=m.target;y.value=y.value.replace(/[^0-9-]/g,""),setTimeout(()=>y.select(),0)}),o.addEventListener("blur",m=>{var E;const y=m.target;let f=parseInt(y.value);isNaN(f)&&(f=((E=this.value)==null?void 0:E.angle)??0),f=Math.max(0,Math.min(360,f)),this.value&&(this.value.angle=f),y.value=`${f}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),l.addEventListener("click",()=>{this.value&&(this.value.stops=this.value.stops.map(m=>({...m,position:100-m.position})),this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),this.triggerChange())}),e.appendChild(i),e.appendChild(o),e.appendChild(l),t.appendChild(e),(()=>{var m;((m=this.value)==null?void 0:m.type)==="radial"?(o.disabled=!0,o.style.opacity="0.5"):(o.disabled=!1,o.style.opacity="1")})();const c=document.createElement("div");c.className="gradient-preview",this.updateGradientPreview(c);const h=document.createElement("div");h.className="gradient-handles",this.createGradientHandles(h,c),c.appendChild(h),t.appendChild(c);const d=document.createElement("div");d.className="gradient-stops-header";const u=document.createElement("span");u.textContent="Stops";const g=document.createElement("button");g.type="button",g.className="gradient-add-stop",g.textContent="+",d.appendChild(u),d.appendChild(g);const C=document.createElement("div");C.className="gradient-stops",t.appendChild(d),t.appendChild(C),this.updateStopsList(C),g.addEventListener("click",()=>{this.addGradientStop(),this.updateStopsList(C),this.updateGradientPreview(c),this.createGradientHandles(h,c),this.updateUI()})}updateGradientPreview(t){var i;const e=t||((i=this.popoverElement)==null?void 0:i.querySelector(".gradient-preview"));e&&this.value&&(e.style.background=this.generateCSS(this.getSafeValue()))}createGradientHandles(t,e){t.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((i,s)=>{const n=document.createElement("div");n.className="gstop-handle",n.style.left=`${i.position}%`;const o=document.createElement("div");o.className="gstop-chip",o.style.backgroundColor=i.color,n.appendChild(o),this.makeDraggable(n,e,s),t.appendChild(n)})}makeDraggable(t,e,i){let s=!1,n=0,o=0,a=null;const l=d=>"touches"in d&&d.touches.length>0?d.touches[0].clientX:d.clientX,r=d=>{var u,g,C;s=!0,n=l(d),o=((C=(g=(u=this.value)==null?void 0:u.stops)==null?void 0:g[i])==null?void 0:C.position)||0,t.classList.add("selected"),document.addEventListener("pointermove",c,{passive:!1}),document.addEventListener("pointerup",h),document.addEventListener("mousemove",c,{passive:!1}),document.addEventListener("mouseup",h),document.addEventListener("touchmove",c,{passive:!1}),document.addEventListener("touchend",h),d.preventDefault()},c=d=>{var y,f;if(!s||!((f=(y=this.value)==null?void 0:y.stops)!=null&&f[i]))return;const u=e.getBoundingClientRect(),C=(l(d)-n)/u.width*100;let m=o+C;m=Math.max(0,Math.min(100,m)),this.value.stops[i].position=Math.round(m),t.style.left=`${m}%`,a&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),a=null}),d.preventDefault()},h=()=>{s&&(s=!1,t.classList.remove("selected"),a&&(cancelAnimationFrame(a),a=null),this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),this.triggerChange(),document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",h),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",h),document.removeEventListener("touchmove",c),document.removeEventListener("touchend",h))};t.addEventListener("pointerdown",r),t.addEventListener("mousedown",r),t.addEventListener("touchstart",r,{passive:!1})}updateStopsList(t){var i;const e=t||((i=this.popoverElement)==null?void 0:i.querySelector(".gradient-stops"));!e||!this.value||this.value.type==="solid"||!this.value.stops||(e.innerHTML="",this.value.stops.forEach((s,n)=>{var D,F;const o=document.createElement("div");o.className="gstop-row";const a=document.createElement("div");a.className="gstop-position-group";const l=document.createElement("input");l.type="text",l.className="gstop-position-input",l.value=`${s.position}%`,l.style.width="60px",a.appendChild(l);const r=document.createElement("div");r.className="gstop-color-container";const c=document.createElement("div");c.className="gstop-color-preview",c.style.backgroundColor=s.color;const h=document.createElement("input");h.type="text",h.className="gstop-color-input",h.value=s.color.replace("#","").toUpperCase();const d=document.createElement("button");d.type="button",d.className="gstop-color-copy",d.innerHTML=`<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
213
213
|
<path d="M14.5896 19.3033L13.4111 20.4818C11.7839 22.109 9.14575 22.109 7.51856 20.4818C5.89138 18.8546 5.89138 16.2164 7.51856 14.5892L8.69708 13.4107M19.3037 14.5892L20.4822 13.4107C22.1094 11.7835 22.1094 9.14535 20.4822 7.51816C18.855 5.89098 16.2168 5.89098 14.5896 7.51816L13.4111 8.69668M11.0837 16.9166L16.917 11.0833" stroke="#919EAB" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
214
|
-
</svg>`,r.appendChild(c),r.appendChild(h),r.appendChild(d);const
|
|
214
|
+
</svg>`,r.appendChild(c),r.appendChild(h),r.appendChild(d);const u=document.createElement("button");u.type="button",u.className="gstop-del",u.innerHTML=`<svg width="14" height="2" viewBox="0 0 14 2" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
215
215
|
<path d="M0.8 0.800003H12.4667" stroke="#919EAB" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
216
|
-
</svg>`,
|
|
216
|
+
</svg>`,u.disabled=(((F=(D=this.value)==null?void 0:D.stops)==null?void 0:F.length)||0)<=2,l.addEventListener("input",L=>{var O;const b=L.target,M=b.value.replace(/[^\d]/g,""),P=parseInt(M);if(this.value&&!isNaN(P)){const H=Math.max(0,Math.min(100,P));this.value.stops[n].position=H,b.value=`${H}%`;const I=(O=this.popoverElement)==null?void 0:O.querySelector(".gradient-preview"),G=I==null?void 0:I.querySelector(".gradient-handles");I&&G&&this.createGradientHandles(G,I),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}}),l.addEventListener("focus",L=>{const b=L.target,M=b.value.replace("%","");b.value=M,b.select()}),l.addEventListener("blur",L=>{var O,H;const b=L.target,M=b.value.replace(/[^\d]/g,""),P=parseInt(M);if(isNaN(P))b.value=`${((H=(O=this.value)==null?void 0:O.stops[n])==null?void 0:H.position)||0}%`;else{const I=Math.max(0,Math.min(100,P));b.value=`${I}%`,this.value&&(this.value.stops[n].position=I,this.updateGradientPreview(),this.updateUI(),this.triggerChange())}});const g=new qt((L,b)=>{var M,P,O;if(h.value=L.replace("#","").toUpperCase(),c.style.backgroundColor=L,this.value){this.value.stops[n].color=L,b!==void 0&&(this.value.stops[n].opacity=b);const H=(M=o.parentElement)==null?void 0:M.querySelector(".gstop-opacity-slider");if(H){const v=this.hexToRgb(L);H.style.setProperty("--slider-color",`rgb(${v.r}, ${v.g}, ${v.b})`)}if(b!==void 0){const v=(P=o.parentElement)==null?void 0:P.querySelector(".gstop-opacity-value");v&&(v.textContent=`${b}%`),H&&(H.value=b.toString())}const I=(O=this.popoverElement)==null?void 0:O.querySelector(".gradient-preview"),G=I==null?void 0:I.querySelector(".gradient-handles");I&&G&&this.createGradientHandles(G,I),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}});h.addEventListener("click",L=>{L.stopPropagation(),g.open(s.color,h,s.opacity||100)}),h.addEventListener("input",L=>{var P,O;const b=L.target.value.trim(),M=b.startsWith("#")?b:`#${b}`;if(/^#[0-9A-Fa-f]{6}$/.test(M)&&(c.style.backgroundColor=M,this.value)){this.value.stops[n].color=M;const H=(P=o.parentElement)==null?void 0:P.querySelector(".gstop-opacity-slider");if(H){const v=this.hexToRgb(M);H.style.setProperty("--slider-color",`rgb(${v.r}, ${v.g}, ${v.b})`)}const I=(O=this.popoverElement)==null?void 0:O.querySelector(".gradient-preview"),G=I==null?void 0:I.querySelector(".gradient-handles");I&&G&&this.createGradientHandles(G,I),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}}),d.addEventListener("click",async L=>{L.stopPropagation();const b=`#${h.value}`;try{await navigator.clipboard.writeText(b);const M=d.innerHTML;d.innerHTML=`<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
217
217
|
<path d="M9.3335 14L12.2502 16.9167L18.6668 10.5" stroke="#00A76F" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
218
|
-
</svg>`,setTimeout(()=>{d.innerHTML=
|
|
218
|
+
</svg>`,setTimeout(()=>{d.innerHTML=M},1e3)}catch(M){console.warn("Failed to copy color to clipboard:",M)}}),u.addEventListener("click",()=>{var L;if(this.value&&this.value.stops.length>2){this.value.stops.splice(n,1);const b=(L=this.popoverElement)==null?void 0:L.querySelector(".gradient-preview"),M=b==null?void 0:b.querySelector(".gradient-handles");b&&M&&this.createGradientHandles(M,b),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}}),o.appendChild(a),o.appendChild(r),o.appendChild(u),e.appendChild(o);const C=document.createElement("div");C.className="gstop-opacity-row";const m=document.createElement("span");m.className="gstop-opacity-label",m.textContent="Opacity";const y=document.createElement("div");y.className="gstop-opacity-group";const f=document.createElement("input");f.type="range",f.className="gstop-opacity-slider",f.min="0",f.max="100",f.value=(s.opacity!==void 0?s.opacity:100).toString();const E=this.hexToRgb(s.color);f.style.setProperty("--slider-color",`rgb(${E.r}, ${E.g}, ${E.b})`);const V=document.createElement("span");V.className="gstop-opacity-value",V.textContent=`${s.opacity!==void 0?s.opacity:100}%`}))}addGradientStop(){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const t=this.value.stops.map(o=>o.position).sort((o,a)=>o-a);let e=50,i=0;for(let o=0;o<t.length-1;o++){const a=t[o+1]-t[o];a>i&&(i=a,e=t[o]+a/2)}const s=this.value.stops.reduce((o,a)=>Math.abs(a.position-e)<Math.abs(o.position-e)?a:o),n={position:Math.round(e),color:s.color,opacity:s.opacity!==void 0?s.opacity:100};this.value.stops.push(n),this.value.stops.sort((o,a)=>o.position-a.position)}openPopover(){if(!(!this.popoverElement||this.isPopoverOpen)){if(this.isPopoverOpen=!0,this.popoverElement.style.display="flex",this.refreshPopoverContent(),this.element){const t=this.element.getBoundingClientRect(),e=306,i=window.innerWidth,s=window.innerHeight,n=16;this.popoverElement.style.position="fixed",this.popoverElement.style.zIndex="10000";let o=t.right+8,a=t.top;const l=i-t.right,r=t.left,c=e+n;l<c&&r>l+100&&(o=t.left-e-8),a+400>s&&(a=Math.max(8,s-400-8)),this.popoverElement.style.left=`${o}px`,this.popoverElement.style.top=`${a}px`}setTimeout(()=>{document.addEventListener("click",this.handleBackgroundClick,!0)},0)}}refreshPopoverContent(){if(!this.popoverElement)return;this.popoverElement.querySelectorAll(".gradient-type-tab").forEach((i,s)=>{var n,o;i.classList.remove("active"),(s===0&&((n=this.value)==null?void 0:n.type)==="solid"||s===1&&((o=this.value)==null?void 0:o.type)!=="solid")&&i.classList.add("active")});const e=this.popoverElement.querySelector(".gradient-editor-content");e&&this.updatePopoverContent(e)}closePopover(){!this.popoverElement||!this.isPopoverOpen||(this.isPopoverOpen=!1,this.popoverElement.style.display="none",document.removeEventListener("click",this.handleBackgroundClick,!0))}handlePaste(t){var i;t.preventDefault();const e=((i=t.clipboardData)==null?void 0:i.getData("text"))||"";this.parseAndSetValue(e)}handleInput(t){const e=t.target;this.parseAndSetValue(e.value)}parseAndSetValue(t){const e=t.trim();if(e)try{const i=this.parseGradientCSS(e);i&&this.setValue(i)}catch(i){console.warn("Failed to parse gradient/color:",i)}}parseGradientCSS(t){const e=t.replace(/;$/,"").trim();if(this.isValidColor(e))return{type:"solid",angle:0,stops:[this.parseColorWithOpacity(e)]};const i=this.extractGradientParams(e,"linear-gradient");if(i)return this.parseLinearGradient(i);const s=this.extractGradientParams(e,"radial-gradient");return s?this.parseRadialGradient(s):null}extractGradientParams(t,e){const i=new RegExp(`${e}\\s*\\(`,"i"),s=t.match(i);if(!s)return null;const n=s.index+s[0].length;let o=1,a=n;for(let l=n;l<t.length&&o>0;l++)t[l]==="("?o++:t[l]===")"&&o--,a=l;return o===0?t.substring(n,a):null}isValidColor(t){const e=document.createElement("div");return e.style.color=t,e.style.color!==""}parseColorWithOpacity(t){const e=t.trim();if(/^#[0-9A-Fa-f]{8}$/.test(e)){const n=e.slice(1);parseInt(n.substr(0,2),16),parseInt(n.substr(2,2),16),parseInt(n.substr(4,2),16);const a=parseInt(n.substr(6,2),16)/255*100;return{color:`#${n.substr(0,6)}`,position:0,opacity:a}}const i=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);if(i){const n=parseInt(i[1]),o=parseInt(i[2]),a=parseInt(i[3]),l=i[4]?parseFloat(i[4]):1;return{color:`#${n.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`,position:0,opacity:Math.round(l*100)}}const s=e.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*([\d.]+))?\s*\)/);if(s){const n=parseFloat(s[1]),o=parseFloat(s[2])/100,a=parseFloat(s[3])/100,l=s[4]?parseFloat(s[4]):1,{r,g:c,b:h}=this.hslToRgb(n,o,a);return{color:`#${r.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}${h.toString(16).padStart(2,"0")}`,position:0,opacity:Math.round(l*100)}}return{color:e,position:0,opacity:100}}hslToRgb(t,e,i){const s=(1-Math.abs(2*i-1))*e,n=s*(1-Math.abs(t/60%2-1)),o=i-s/2;let a=0,l=0,r=0;return t>=0&&t<60?(a=s,l=n,r=0):t>=60&&t<120?(a=n,l=s,r=0):t>=120&&t<180?(a=0,l=s,r=n):t>=180&&t<240?(a=0,l=n,r=s):t>=240&&t<300?(a=n,l=0,r=s):t>=300&&t<360&&(a=s,l=0,r=n),{r:Math.round((a+o)*255),g:Math.round((l+o)*255),b:Math.round((r+o)*255)}}smartSplit(t){const e=[];let i="",s=0;for(let n=0;n<t.length;n++){const o=t[n];if(o==="(")s++;else if(o===")")s--;else if(o===","&&s===0){e.push(i.trim()),i="";continue}i+=o}return i.trim()&&e.push(i.trim()),e}parseLinearGradient(t){const e=this.smartSplit(t);let i=90,s=[];const n=e[0];if(n.includes("deg")){const a=n.match(/(-?\d+(?:\.\d+)?)deg/);a?(i=parseFloat(a[1]),s=e.slice(1)):s=e}else n.includes("to ")?(i={"to right":90,"to left":270,"to bottom":180,"to top":0,"to bottom right":135,"to bottom left":225,"to top right":45,"to top left":315}[n]||90,s=e.slice(1)):s=e;const o=this.parseColorStops(s);return o.length===0?null:{type:"linear",angle:i,stops:o}}parseRadialGradient(t){const e=this.smartSplit(t);let i=[];e[0]&&!this.isColorStop(e[0])?i=e.slice(1):i=e;const s=this.parseColorStops(i);return s.length===0?null:{type:"radial",angle:0,stops:s}}isColorStop(t){const e=t.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at"].includes(e)||["contain","cover"].includes(e)?!1:/^#[0-9a-f]{3,8}$/i.test(e)||/^rgb/i.test(t)||/^hsl/i.test(t)||this.isValidColorName(e)}isValidColorName(t){return["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(t.toLowerCase())}parseColorStops(t){const e=[];return t.forEach((i,s)=>{const n=i.trim();if(!n)return;let o="",a=0;const l=n.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);if(l){const c=l[1].trim(),h=parseFloat(l[2]);this.isValidColorFormat(c)?(o=c,a=h):(o=n,a=t.length===1?0:s/(t.length-1)*100)}else o=n,a=t.length===1?0:s/(t.length-1)*100;const r=this.parseColorWithOpacity(o);r.position=Math.round(a),e.push(r)}),e}isValidColorFormat(t){return[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(i=>i.test(t.trim()))||this.isValidColor(t)}triggerChange(){this.onChange&&this.value&&this.onChange(this.value),this.detectChange&&this.value&&this.detectChange(this.value)}getElement(){return this.element}getValue(){return this.value?this.generateCSS(this.getSafeValue()):""}getCSSValue(){return this.value?this.generateCSS(this.getSafeValue()):""}getTextCSSProperties(){if(!this.value)return{};const t=this.generateCSS(this.getSafeValue());return t.includes("gradient")?{background:t,"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{color:t}}getRawValue(){return this.value}}const Zt=`
|
|
219
219
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
220
220
|
<path d="M5.625 9.5H5.6325M12.375 9.5H12.3825M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M2.25 6.35L2.25 12.65C2.25 13.9101 2.25 14.5402 2.49524 15.0215C2.71095 15.4448 3.05516 15.789 3.47852 16.0048C3.95982 16.25 4.58988 16.25 5.85 16.25H12.15C13.4101 16.25 14.0402 16.25 14.5215 16.0048C14.9448 15.789 15.289 15.4448 15.5048 15.0215C15.75 14.5402 15.75 13.9101 15.75 12.65V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75L5.85 2.75C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
221
221
|
</svg>
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
224
224
|
<path d="M6 2.75H5.85C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35V6.5M6 16.25H5.85C4.58988 16.25 3.95982 16.25 3.47852 16.0048C3.05516 15.789 2.71095 15.4448 2.49524 15.0215C2.25 14.5402 2.25 13.9101 2.25 12.65V12.5M15.75 6.5V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75H12M15.75 12.5V12.65C15.75 13.9101 15.75 14.5402 15.5048 15.0215C15.289 15.4448 14.9448 15.789 14.5215 16.0048C14.0402 16.25 13.4101 16.25 12.15 16.25H12" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
225
225
|
</svg>
|
|
226
|
-
`;class Yt extends
|
|
226
|
+
`;class Yt extends W{constructor(t){super({title:"Border",collapsed:t==null?void 0:t.collapsed,settings:{size:new B({title:"Size",icon:Xt,default:(t==null?void 0:t.size)??0,suffix:"px"}),color:new U({default:(t==null?void 0:t.color)??"0, 0, 30"}),radius:new B({title:"Radius",icon:Zt,default:(t==null?void 0:t.radius)??12,suffix:"px"})}})}getCssCode(){const t=this.settings.color.value??"#000000",e=this.settings.radius.value??0,i=this.settings.size.value??0;return`
|
|
227
227
|
border-color: ${t};
|
|
228
228
|
border-width: ${i}px;
|
|
229
229
|
border-radius: ${e}px;
|
|
@@ -239,13 +239,13 @@
|
|
|
239
239
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
240
240
|
<path d="M6 5.75H12M9 5.75V13.25M5.85 16.25H12.15C13.4101 16.25 14.0402 16.25 14.5215 16.0048C14.9448 15.789 15.289 15.4448 15.5048 15.0215C15.75 14.5402 15.75 13.9101 15.75 12.65V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75H5.85C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35V12.65C2.25 13.9101 2.25 14.5402 2.49524 15.0215C2.71095 15.4448 3.05516 15.789 3.47852 16.0048C3.95982 16.25 4.58988 16.25 5.85 16.25Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
241
241
|
</svg>
|
|
242
|
-
`;class ee extends
|
|
242
|
+
`;class ee extends W{constructor(t={}){const{showAlign:e=t.showAlign??!0,...i}=t;super({title:i.title||"Typography",collapsed:i.collapsed,settings:(()=>{const s={color:new U({default:i.colorDefault??"0, 0, 30"}),fontFamily:new Y({title:"Font",icon:Kt,default:i.fontFamilyDefault??"Satoshi",options:i.fontFamilyOptions??[{name:"Alt",value:"Croco Sans Black Caps Alt"},{name:"Regular",value:"Croco Sans Caps Regular"},{name:"Caps",value:"Croco Sans Black Caps"},{name:"FaraGo",value:"'FiraGO', sans-serif"}],getOptions:i.fontFamilyGetOptions,getOptionsAsync:i.fontFamilyGetOptionsAsync}),fontWeight:new Y({title:"Weight",icon:Qt,default:i.fontWeightDefault??"400",options:i.fontWeightOptions??[{name:"Regular",value:"400"},{name:"Medium",value:"500"},{name:"Bold",value:"600"}],getOptions:i.fontWeightGetOptions,getOptionsAsync:i.fontWeightGetOptionsAsync}),fontSize:new B({title:"Size",icon:te,default:i.fontSizeDefault??12,suffix:"px",mobile:i.fontSizeMobileDefault})};return e?{...s,align:new dt({title:"Align",default:i.alignDefault??"center"})}:s})()})}getCssCode(){var o;const t=this.settings.color.value??"#000000",e=this.settings.fontFamily.value??"Satoshi",i=this.settings.fontWeight.value??"bold",s=this.settings.fontSize.value??12,n=((o=this.settings.align)==null?void 0:o.value)??"left";return`
|
|
243
243
|
color: ${t};
|
|
244
244
|
font-family: ${e};
|
|
245
245
|
font-weight: ${i};
|
|
246
246
|
font-size: ${s}px;
|
|
247
247
|
text-align: ${n};
|
|
248
|
-
`}}class J extends
|
|
248
|
+
`}}class J extends S{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=a=>{this.value!=="auto"&&(this.props.minValue!==void 0&&(a.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(a.max=String(this.props.maxValue)),this.props.className&&a.classList.add(this.props.className),a.addEventListener("input",()=>{const l=this.props.minValue??Number.MIN_SAFE_INTEGER,r=this.props.maxValue??Number.MAX_SAFE_INTEGER;let c=Number(a.value);c<l&&(c=l),c>r&&(c=r),a.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 o=i.querySelector("input");return o&&(o.oninput=a=>{const l=a.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 ie extends W{constructor(t){super({title:"Margins",collapsed:t==null?void 0:t.collapsed,settings:{marginTop:new J({title:"Top",icon:se,suffix:"px",default:(t==null?void 0:t.marginTop)??"auto"}),marginRight:new J({title:"Right",icon:ne,suffix:"px",default:(t==null?void 0:t.marginRight)??0}),marginBottom:new J({title:"Bottom",icon:oe,suffix:"px",default:(t==null?void 0:t.marginBottom)??0}),marginLeft:new J({title:"Left",icon:ae,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`
|
|
249
249
|
margin-top: ${t};
|
|
250
250
|
margin-right: ${e};
|
|
251
251
|
margin-bottom: ${i};
|
|
@@ -258,11 +258,11 @@
|
|
|
258
258
|
<path d="M2.25 2.75H2.2575M2.25 9.5H2.2575M2.25 12.875H2.2575M2.25 6.125H2.2575M5.625 2.75H5.6325M5.625 9.5H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
259
259
|
</svg>`,ae=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
260
260
|
<path d="M5.625 2.75H5.6325M5.625 9.5H5.6325M5.625 16.25H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M12.375 16.25H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 16.25H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 16.25H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
261
|
-
</svg>`;class le extends
|
|
261
|
+
</svg>`;class le extends W{constructor(t){super({title:"Background Image",collapsed:t==null?void 0:t.collapsed,settings:{backgroundImage:new nt({...t==null?void 0:t.uploadProps,default:(t==null?void 0:t.backgroundImage)??""}),opacity:new ht({default:(t==null?void 0:t.opacity)??100}),backgroundColor:new U({default:(t==null?void 0:t.backgroundColor)??"0, 0, 30"})}})}draw(){const t=super.draw(),e=t.querySelector(".setting-group-content");if(!e)return t;const i=Array.from(e.children),[s,n,o]=i;e.innerHTML="",e.appendChild(s),e.appendChild(n);const a=document.createElement("div");return a.className="bgset-or-label",a.textContent="OR",e.appendChild(a),e.appendChild(o),t}getCssCode(){const t=this.settings.backgroundImage.value||"",e=this.settings.opacity.value??100,i=this.settings.backgroundColor.value||"#000000";return t?`
|
|
262
262
|
background-image: url("${t}");
|
|
263
263
|
background-size: cover;
|
|
264
264
|
background-position: center;
|
|
265
265
|
opacity: ${e/100};
|
|
266
266
|
`:`
|
|
267
267
|
background-color: ${i};
|
|
268
|
-
`}}exports.AlignSetting=dt;exports.AnimationSetting=_t;exports.BackgroundSettingSet=le;exports.BorderSettingSet=Yt;exports.ButtonSetting=kt;exports.ColorSetting=A;exports.ColorWithOpacitySetting=
|
|
268
|
+
`}}exports.AlignSetting=dt;exports.AnimationSetting=_t;exports.BackgroundSettingSet=le;exports.BorderSettingSet=Yt;exports.ButtonSetting=kt;exports.ColorSetting=A;exports.ColorWithOpacitySetting=U;exports.DimensionSetting=St;exports.GapSetting=Gt;exports.GradientSetting=Jt;exports.HeaderTypographySettingSet=ee;exports.HeightSetting=Ht;exports.HtmlSetting=wt;exports.MarginBottomSetting=Wt;exports.MarginSettingGroup=ie;exports.MarginTopSetting=Ut;exports.MultiLanguageSetting=jt;exports.NumberSetting=B;exports.OpacitySetting=ht;exports.SelectApiSettings=Bt;exports.SelectSetting=Y;exports.Setting=S;exports.SettingGroup=W;exports.StringSetting=ct;exports.TabSettingGroup=st;exports.TabsSettingGroup=st;exports.Toggle=Dt;exports.UploadSetting=nt;exports.WidthSetting=Ot;exports.asSettingGroupWithSettings=yt;exports.createSettingGroup=rt;exports.createTabSettingGroup=Ct;exports.isSetting=j;exports.isSettingChild=it;exports.isSettingGroup=N;exports.iterateSettings=q;
|