import*as Common from"../common/common.js";import*as TextUtils from"../text_utils/text_utils.js";import*as UI from"../ui/ui.js";import{ColorSwatch}from"./ColorSwatch.js";export class BezierSwatch extends HTMLSpanElement{constructor(){super();const t=UI.Utils.createShadowRootWithCoreStyles(this,{cssFile:"inline_editor/bezierSwatch.css",enableLegacyPatching:!0,delegatesFocus:void 0});this._iconElement=UI.Icon.Icon.create("smallicon-bezier","bezier-swatch-icon"),t.appendChild(this._iconElement),this._textElement=this.createChild("span"),t.createChild("slot")}static create(){let t=BezierSwatch._constructor;return t||(t=UI.Utils.registerCustomElement("span","bezier-swatch",BezierSwatch),BezierSwatch._constructor=t),t()}bezierText(){return this._textElement.textContent||""}setBezierText(t){this._textElement.textContent=t}hideText(t){this._textElement.hidden=t}iconElement(){return this._iconElement}}BezierSwatch._constructor=null;export class CSSShadowSwatch extends HTMLSpanElement{constructor(){super();const t=UI.Utils.createShadowRootWithCoreStyles(this,{cssFile:"inline_editor/cssShadowSwatch.css",enableLegacyPatching:!0,delegatesFocus:void 0});this._iconElement=UI.Icon.Icon.create("smallicon-shadow","shadow-swatch-icon"),t.appendChild(this._iconElement),t.createChild("slot"),this._contentElement=this.createChild("span"),this._colorSwatch}static create(){let t=CSSShadowSwatch._constructor;return t||(t=UI.Utils.registerCustomElement("span","css-shadow-swatch",CSSShadowSwatch),CSSShadowSwatch._constructor=t),t()}model(){return this._model}setCSSShadow(t){this._model=t,this._contentElement.removeChildren();const e=TextUtils.TextUtils.Utils.splitStringByRegexes(t.asCSSText(),[/!important/g,/inset/g,Common.Color.Regex]);for(let o=0;o<e.length;o++){const n=e[o];if(2===n.regexIndex){if(!this._colorSwatch){this._colorSwatch=new ColorSwatch;const t=this._colorSwatch.createChild("span");this._colorSwatch.addEventListener("format-changed",(e=>{t.textContent=e.data.text}))}this._colorSwatch.renderColor(t.color());const e=this._colorSwatch.querySelector("span");e&&(e.textContent=t.color().asString()),this._contentElement.appendChild(this._colorSwatch)}else this._contentElement.appendChild(document.createTextNode(n.value))}}hideText(t){this._contentElement.hidden=t}iconElement(){return this._iconElement}colorSwatch(){return this._colorSwatch}}CSSShadowSwatch._constructor=null;