import{template as e,RenderIf as s,isLocalEnv as o,baseAssetURL as r}from"@gem-sdk/core";import{getDynamicSourceLocales as t,getSettingPreloadData as d}from"../../../helpers.js";import{createStyle as l,createClass as p,If as i}from"@gem-sdk/system";import{composeContainerStyles as m,composeFormDropdownStyles as a,getAppendTypoStyleFirstTime as n,getStyleOption as c}from"./common/styles.js";import{composeContainerClasses as $,composeFormDropdownClasses as f}from"./common/classes.js";let FormDropdown=({builderProps:u,setting:g,advanced:y,pageContext:v,styles:j})=>{let{name:w,childItem:S,required:h,translate:N}=g??{},O=S?.map((e,s)=>t({val:e,uid:u?.uid,settingId:`childItem_${s}`,pageContext:v,translate:N})),b=l(m(y,g)),k=l({...a(y,g,j),...n(g)}),E=l(c(g)),A=p($(y,u)),I=p(f(g));return e`
    <gp-form-dropdown
      data-id="${u?.uid}"
      class="${A}"
      style="${b}"
    >
      <select
        type="email"
        class="${I}"
        style="${k}"
        ${i(h,"required")}
        name="${w}"
        gp-data='${JSON.stringify(g).replaceAll("'","&#039;")}'
      >
        ${i(!Number(g?.defaultOption),`<option class="gp-hidden" value="" disabled selected>
            ${g?.placeholder}
          </option>`)}
        ${O?.map(s=>e`
            <option
              value="${s}"
              style="${E}"
              ${i(!!Number(g?.defaultOption),`selected: ${s===O[Number(g?.defaultOption)-1]}`)}
            >
              ${s}
            </option>`).join("")}
      </select>
    </gp-form-dropdown>
    ${s(o,`<script ${d('class="gps-link" delay',"src")}="{{ 'gp-form-dropdown-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${d('class="gps-link" delay',"src")}="${r}/assets-v2/gp-form-dropdown-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};export{FormDropdown as default};
