!function(){"use strict";jQuery(e=>{const s="site_reviews_gamipress_rating",t="site_reviews_gamipress_rating_condition",i="site_reviews_gamipress_user_id",r=e=>{const r=e.find(".select-trigger-type").val(),c=e.find("select."+i),d=e.find("select."+t),u=!!~r.indexOf("site_reviews_gamipress"),p=u&&!!~["minimum","exact"].indexOf(d.val());l(d,u),l(e.find("input."+s),p),l(e.find("."+s+"-text"),p),u&&~r.indexOf("/user_id")?(c.show().data("trigger-type",r),c.hasClass("select2-hidden-accessible")?c.val("").trigger("change").next().show():c.gamipress_select2({ajax:{data:e=>({q:e.term,page:e.page||1,action:"site_reviews_gamipress/users",nonce:gamipress_requirements_ui.nonce,trigger_type:r}),dataType:"json",delay:250,processResults:a,type:"POST",url:ajaxurl},allowClear:!0,escapeMarkup:e=>e,multiple:!1,placeholder:"Select a User",templateResult:n,theme:"default gamipress-select2"})):(c.hide(),c.hasClass("select2-hidden-accessible")&&c.next().hide())},a=e=>{if(null===e)return{results:[]};const s=e.data.results??e.data;return s.forEach(e=>{e.id=e.ID,e.text=e.display_name+" (#"+e.ID+")"}),{pagination:{more:e.data.more_results??!1},results:s}},n=e=>{if(void 0===e.ID)return e.text;const s=void 0!==e.site_name?` (${e.site_name})`:"";return`<strong>${e.display_name}</strong><span class="result-description">ID: ${e.ID}<span class="align-right">User</span>${s}</span>`},l=(e,s)=>e[s?"show":"hide"]();e(".requirements-list").on("change",".select-trigger-type, ."+t,function(){r(e(this).closest("li"))}),e(".requirements-list").on("update_requirement_data",".requirement-row",function(e,r,a){~r.trigger_type.indexOf("site_reviews_gamipress")&&(r[s]=a.find("input."+s).val()??"",r[t]=a.find("select."+t).val()??"",r[i]=a.find("select."+i).val()??"")}),e(".requirements-list li").each((s,t)=>r(e(t)))})}();
