drill.init(async(e,a)=>{await e("./bg.css","components/p-input -pack","components/p-selector -pack");let[t,o]=await e("util/syncPannelSelected","util/selecteSource"),{code:u}=await e("./bg.dcode"),c=$(u),l=$.xdata({"background-image":"","background-color":"","background-size":"","background-position":"","background-repeat":""});t(a,l);let i=c.que(".bgimage"),r=c.que(".bgcolor"),n=c.que(".bgposition"),s=c.que(".bgPositionX"),d=c.que(".bgPositionY"),g=c.que(".bgsize"),b=c.que(".bgsizeX"),p=c.que(".bgsizeY"),v=c.que(".bgrepeat"),k=c.que(".delete_bgimg_btn");i.on("click",async e=>{let a=await o();a&&(l["background-image"]=a.url,l["background-size"]="contain",l["background-position"]="center center",l["background-repeat"]="no-repeat")}),k.on("click",async e=>{l["background-image"]="",l["background-size"]="",l["background-position"]="",l["background-repeat"]=""}),l.sync(r,{"background-color":"value"},!0),l.sync(v,{"background-repeat":"value"},!0),l.watch("background-image",(e,a)=>{a?(i.style["background-image"]=`url(${a})`,i.parents(".p_group_line")[0].class.add("imgmode")):(i.style["background-image"]="",i.parents(".p_group_line")[0].class.remove("imgmode")),a?c.queAll(".p_group_line").forEach((e,a)=>{0!==a&&e.class.remove("hide")}):c.queAll(".p_group_line").forEach((e,a)=>{0!==a&&e.class.add("hide")})},!0);let m=e=>{if(""==(e=String(e).trim()))return;let a=n.que(`[value="${e}"]`);n.value=a?e:"custom";let t=e.split(/ +/);1 in t&&(s.value=t[0],d.value=t[1]),l["background-position"]=e};s.watch("value",e=>{m(s.value+" "+d.value)}),d.watch("value",e=>{m(s.value+" "+d.value)}),l.watch("background-position",e=>{let a=l["background-position"];m(a)}),n.watch("value",e=>{let{value:a}=n;switch(a){case"custom":s.removeAttr("disabled"),d.removeAttr("disabled"),s.value="0%",d.value="0%";break;default:s.attr("disabled",""),d.attr("disabled",""),m(a)}}),n.value=l["background-position"];let h=e=>{if(""!=(e=String(e).trim())){switch(e){case"auto":case"cover":case"contain":g.value=e;break;default:g.value="custom";let a=e.split(/ +/);b.value=a[0],p.value=a[1]}l["background-size"]=e}};return b.watch("value",e=>{h(b.value+" "+p.value)}),p.watch("value",e=>{h(b.value+" "+p.value)}),l.watch("background-size",e=>{h(l["background-size"])}),g.watch("value",e=>{let{value:a}=g;switch(a){case"custom":b.style.opacity=1,p.style.opacity=1,b.removeAttr("disabled"),p.removeAttr("disabled"),l["background-size"]?h(l["background-size"]):h("100px auto");break;default:b.style.opacity=0,p.style.opacity=0,b.attr("disabled",""),p.attr("disabled",""),h(a)}}),l["background-size"]&&(g.value="custom"),c});