/**
 * skylark-osjsv2-client - A version of osjs-client that ported to running on skylarkjs
 * @author Hudaokeji, Inc.
 * @version v0.9.0
 * @link https://github.com/skylark-integration/skylark-osjsv2-client/
 * @license MIT
 */
define(["../core/dialog","../utils/misc","../utils/colors","../core/locales"],function(o,t,e,i){"use strict";return class extends o{constructor(o,t){o=Object.assign({},{},o);const[l,s]=function(o){let t=o;return"string"==typeof o?(t=o,(o=e.convertToRGB(o)).a=null):(void 0===o.a?o.a=null:o.a>1&&(o.a/=100),o=o||{r:0,g:0,b:0,a:100},t=e.convertToHEX(o.r,o.g,o.b)),[o,t]}(o.color);super("ColorDialog",{title:o.title||i._("DIALOG_COLOR_TITLE"),icon:"apps/preferences-desktop-theme.png",width:400,height:null!==l.a?300:220},o,t),this.color={r:l.r,g:l.g,b:l.b,a:l.a,hex:s}}init(){const o=super.init(...arguments),l=o=>{this._find("LabelRed").set("value",i._("DIALOG_COLOR_R",this.color.r)),this._find("LabelGreen").set("value",i._("DIALOG_COLOR_G",this.color.g)),this._find("LabelBlue").set("value",i._("DIALOG_COLOR_B",this.color.b)),this._find("LabelAlpha").set("value",i._("DIALOG_COLOR_A",this.color.a)),o&&(this.color.hex=e.convertToHEX(this.color.r,this.color.g,this.color.b));let l=this.color.hex;null===this.color.a||isNaN(this.color.a)||(l=t.format("rgba({0}, {1}, {2}, {3})",this.color.r,this.color.g,this.color.b,this.color.a)),this._find("ColorPreview").set("value",l)};return this._find("ColorSelect").on("change",o=>{this.color=o.detail,this._find("Red").set("value",this.color.r),this._find("Green").set("value",this.color.g),this._find("Blue").set("value",this.color.b),l(!0)}),this._find("Red").on("change",o=>{this.color.r=parseInt(o.detail,10),l(!0)}).set("value",this.color.r),this._find("Green").on("change",o=>{this.color.g=parseInt(o.detail,10),l(!0)}).set("value",this.color.g),this._find("Blue").on("change",o=>{this.color.b=parseInt(o.detail,10),l(!0)}).set("value",this.color.b),this._find("Alpha").on("change",o=>{this.color.a=parseInt(o.detail,10)/100,l(!0)}).set("value",100*this.color.a),null===this.color.a&&(this._find("AlphaContainer").hide(),this._find("AlphaLabelContainer").hide()),l(!1,this.color.a),o}onClose(o,t){this.closeCallback(o,t,"ok"===t?this.color:null)}}});
//# sourceMappingURL=../sourcemaps/dialogs/color.js.map
