var e,t,s,i,a,r,c,n,o,u,h,d,l,g,v=Object.defineProperty,S=(e,t,s)=>(((e,t,s)=>{t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s})(e,"symbol"!=typeof t?t+"":t,s),s),w=(e,t,s)=>{if(!t.has(e))throw TypeError("Cannot "+s)},m=(e,t,s)=>(w(e,t,"read from private field"),s?s.call(e):t.get(e)),R=(e,t,s)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,s)},E=(e,t,s,i)=>(w(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{r as _}from"./react-B_SyE9nW.js";import{aH as p,be as I,aZ as b,aU as T,b4 as y,bh as N,t as B,aR as O,p as P,q as C,r as f,O as D,au as k,m as L,F as U,ao as F,aS as A,v as W,bi as V,bj as M,P as x,bk as K,bl as z,bm as $,a_ as H,w as j,y as J,aN as G,aQ as Y,bn as q,bf as Q,bo as Z,bp as X,A as ee,bq as te}from"./index-Flm6m8Wj.js";import{B as se,M as ie,b as ae}from"./BusinessReviewStore-DfTzlAZI.js";const re={search:"",location:""};class ce extends p{constructor(){super(),R(this,e,re),S(this,"setInfo",((t={...re})=>(E(this,e,t),this))),S(this,"clear",(()=>(this.resetPagination(),this.setInfo(),this))),this.page_size=15,this.page_offset=9}get info(){return m(this,e)}}e=new WeakMap;class ne extends ce{constructor(){super(),S(this,"callSvc",(async({page:e,page_size:t})=>{const{search:s,location:i}=this.info,a="name",r={search:s,order_by:a,page:e,page_size:t};i&&(r.order_by=`location,${a}`,r.current_location=i);const{errors:c,success:n,data:o}=await I.getBusiness(r);return n?o.results=o.results.map((({name:e,slug:t,...s})=>({label:`${e}${s&&s.city?`, ${String(s.city)}`:""}`,value:t,data:s}))):console.log(`ERROR: ${JSON.stringify(c,null,2)}`),{success:n,data:o}}))}}class oe extends p{constructor(){super(),R(this,t,""),S(this,"setLocation",((e="")=>(E(this,t,e),this))),S(this,"clear",(()=>{E(this,t,""),this.resetPagination()})),S(this,"callSvc",(async({page_size:e,page:s})=>{const{data:i,success:a}=await I.getBusiness({page_size:e,page:s,order_by:"location",current_location:m(this,t)});return a&&i&&(i.results=i.results.map((({slug:e,name:t,main_picture:s,num_reviews:i,address:a,enjoty_rating:r,city:c,main_type_str:n,cuisines:o})=>({slug:e,name:t,main_picture:s,main_type_str:n,num_reviews:i,address:a,enjoty_rating:r,city:c,cuisines:o})))),{success:a,data:i}}))}}t=new WeakMap;class ue extends p{constructor(){super(),S(this,"clear",(()=>{this.resetPagination()})),S(this,"callSvc",(async()=>{let e=[];const{data:t,success:s}=await b.getLastViewedBusiness();return s&&t&&(e=t.map((({business:{slug:e,name:t,main_picture:s,num_reviews:i,address:a,enjoty_rating:r,city:c,main_type_str:n,cuisines:o}})=>({slug:e,name:t,main_picture:s,main_type_str:n,num_reviews:i,address:a,enjoty_rating:r,city:c,cuisines:o})))),{success:s,data:{results:e,count:e.length}}}))}}class he extends p{constructor(){super(),R(this,s,T.FOOD),R(this,i,""),S(this,"setSlug",((e="")=>(E(this,i,e),this))),S(this,"setProductType",(e=>(E(this,s,e),this))),S(this,"clear",(()=>{E(this,i,""),this.resetPagination()})),S(this,"callSvc",(async()=>{let e=[];const{data:t,success:a}=await b.getLastViewedProducts({product_type:m(this,s),business_slug:m(this,i)});return a&&t&&(e=t.map((({product:{slug:e,name:t,main_picture:s,num_reviews:i,rating:a,business:r},business:c})=>({slug:e,name:t,main_picture:s,num_reviews:i,main_type_str:(null==c?void 0:c.main_type_str)||"",rating:a,city:(null==c?void 0:c.city)||"",business:r})))),{success:a,data:{results:e,count:e.length}}}))}}s=new WeakMap,i=new WeakMap;const de={product_type:T.FOOD,slug:"",city:"",business:""};class le extends p{constructor(){super(),R(this,a,{...de}),S(this,"setInfo",((e={...de})=>(E(this,a,e),this))),S(this,"clear",(()=>{this.setInfo(),this.resetPagination()})),S(this,"callSvc",(async({page_size:e,page:t})=>{const{product_type:s,city:i,business:r,slug:c}=m(this,a),{data:n,success:o}=await I.getBusinessProducts(c,{page:t,page_size:e,product_type:s,order_by:"-rating"});return o&&n&&(n.results=n.results.map((({slug:e,name:t,main_picture:s,num_reviews:a,rating:c,business:n})=>({slug:e,name:t,main_picture:s,num_reviews:a,rating:c,city:i,business:r,main_type_str:n.main_type_str})))),{success:o,data:n}}))}}a=new WeakMap;class ge extends p{constructor(){super(),R(this,r,T.FOOD),S(this,"setProductType",(e=>(E(this,r,e),this))),S(this,"clear",(()=>{this.resetPagination()})),S(this,"callSvc",(async({page_size:e,page:t})=>{const{data:s,success:i}=await y.loadNearProducts({page:t,page_size:e,product_type:m(this,r),order_by:"location"},"",!1);return i&&s&&(s.results=s.results.map((({slug:e,name:t,main_picture:s,num_reviews:i,rating:a,business:{name:r,city:c,main_type_str:n}})=>({slug:e,name:t,main_picture:s,main_type_str:n,num_reviews:i,rating:a,city:c,business:r})))),{success:i,data:s}}))}}r=new WeakMap;const ve="publish",Se="businessMenu",we="reviewBusinessMenu",me="reviewABusiness",Re="rateDishOrFood",Ee="rateDrink",_e="chooseBusiness",pe="MAIN",Ie="MENU_BUSINESS_SELECTION",be="REVIEW",Te="REVIEW_BUSINESS_BUSINESS_SELECTION",ye="REVIEW_FOOD_BUSINESS_SELECTION",Ne="REVIEW_DRINK_BUSINESS_SELECTION",Be="REVIEW_FOOD_FOOD_SELECTION",Oe="REVIEW_FOOD";class Pe extends ce{constructor(e=15){super(),S(this,"extraInfo",{businessSlug:""}),S(this,"setExtraInfo",(e=>(this.extraInfo=e,this))),S(this,"callSvc",(async({page:e,page_size:t})=>{const{search:s}=this.info,i={order_by:"name",page:e,page_size:t,product_type:this.extraInfo.productType,search_name:s},{errors:a,success:r,data:c}=await I.getBusinessProducts(this.extraInfo.businessSlug,i);return r?c.results=c.results.map((({slug:e,name:t,main_picture:s,num_reviews:i,rating:a})=>({label:t,value:e,data:{slug:e,name:t,main_picture:s,num_reviews:i,rating:a,city:this.extraInfo.productCity,business:this.extraInfo.productName}}))):console.log(`ERROR: ${JSON.stringify(a,null,2)}`),{success:r,data:c}})),this.page_size=e}get getExtraInfo(){return this.extraInfo}}const Ce={location:""},fe={where:"LOCAL",when:"",mealTime:0};c=new WeakMap,n=new WeakMap,o=new WeakMap,u=new WeakMap,h=new WeakMap,d=new WeakMap,l=new WeakMap,g=new WeakMap;const De=_.createContext(new class{constructor(){S(this,"tabNav",[pe]),S(this,"title",ve),S(this,"businessSt",new se),S(this,"menuSt",new ie),S(this,"svcImage",new N),R(this,c,new oe),R(this,n,new ue),S(this,"selected"),R(this,o,new ge),R(this,u,new he),R(this,h,new le),S(this,"productSelected"),S(this,"productStr",new y),S(this,"productReview",!1),S(this,"businessReviewStr",new ae),S(this,"locations",[]),S(this,"filter",B({...Ce})),S(this,"businessFormData",B({...fe})),S(this,"productReviewForm",B({...O(),menu_dish:!1})),S(this,"search",""),S(this,"addBusiness",!1),S(this,"addProduct",!1),S(this,"activityTraceUuid",""),R(this,d,new ne),R(this,l,new Pe),R(this,g,void 0),S(this,"bulkReviews",[]),S(this,"imgsToCrop",[]),S(this,"currentCropImage"),S(this,"selectedReviews",[]),S(this,"setProductStore",((e=new y)=>{this.productStr=e})),S(this,"setProductReview",((e=!1)=>{this.productReview=e})),S(this,"setSearch",((e="")=>{this.search=e})),S(this,"setAddBusiness",((e=!1)=>{this.addBusiness=e})),S(this,"setAddProduct",((e=!1)=>{this.addProduct=e})),S(this,"setTabNav",(e=>{this.getTab!==e&&this.tabNav.push(e)})),S(this,"setTitle",(e=>{this.title=e})),S(this,"hasErrorImages",(()=>this.bulkReviews.some((e=>e.hasErrorImages)))),S(this,"setErrorImages",((e,t=!0)=>{const s=this.bulkReviews.findIndex((t=>t.uuid===e));k((()=>{this.bulkReviews[s].hasErrorImages=t}))})),S(this,"setBulkedReviews",((e=[])=>{this.bulkReviews=e})),S(this,"onClickNextPublish",(()=>{this.getSelected&&setTimeout((()=>{switch(this.getPrevTab){case"REVIEW_FOOD_BUSINESS_SELECTION":this.publishTabsNavigation("REVIEW_FOOD_FOOD_SELECTION");break;case"REVIEW_DRINK_BUSINESS_SELECTION":this.publishTabsNavigation("REVIEW_DRINK_DRINK_SELECTION")}}))})),S(this,"isReviewSelected",(e=>this.selectedReviews.includes(e))),S(this,"markReview",(e=>{if(this.selectedReviews.includes(e)){const t=this.selectedReviews.findIndex((t=>t===e));k((()=>{this.selectedReviews.splice(t,1)}))}else k((()=>{this.selectedReviews.push(e)}))})),S(this,"markAllReviews",(()=>{this.bulkReviews.forEach((e=>{e.uuid&&!this.selectedReviews.includes(e.uuid)&&k((()=>{this.selectedReviews.push(e.uuid??"")}))}))})),S(this,"unMarkAllReviews",(()=>{k((()=>{this.selectedReviews=[]}))})),S(this,"setSelected",(e=>{this.selected=e,e&&setTimeout((()=>{switch(this.getTab){case"MENU_BUSINESS_SELECTION":this.setTabNav("MENU_REVIEW");break;case"REVIEW_BUSINESS_BUSINESS_SELECTION":this.setTabNav("REVIEW_BUSINESS");break;case"REVIEW_FOOD_BUSINESS_SELECTION":this.publishTabsNavigation("REVIEW_FOOD_SELECT_BUSINESS_DATA");break;case"REVIEW_DRINK_BUSINESS_SELECTION":this.publishTabsNavigation("REVIEW_DRINK_SELECT_BUSINESS_DATA")}}))})),S(this,"setCurrentCropImage",(e=>{this.currentCropImage=e})),S(this,"setProductSelected",(e=>{this.productSelected=e,e&&setTimeout((()=>{switch(this.getTab){case"REVIEW_BUSINESS_BUSINESS_SELECTION":case"REVIEW_FOOD_BUSINESS_SELECTION":case"REVIEW_FOOD_FOOD_SELECTION":this.clearProductReviewForm(),this.setTabNav("REVIEW_FOOD");break;case"REVIEW_DRINK_BUSINESS_SELECTION":case"REVIEW_DRINK_DRINK_SELECTION":this.clearProductReviewForm(),this.setTabNav("REVIEW_DRINK")}}))})),S(this,"setBusinessReviewStr",((e=new ae)=>{this.businessReviewStr=e})),S(this,"setLocations",((e=[])=>{this.locations=e})),S(this,"setImgsToCrop",(e=>{this.imgsToCrop=e})),S(this,"clearBusinessReview",(()=>{this.businessReviewStr=new ae,this.activityTraceUuid="",E(this,g,"")})),S(this,"clear",(()=>{k((()=>{this.setProductStore(),this.tabNav=[pe],this.title=ve,this.selected=void 0,this.productSelected=void 0,this.search="",this.addBusiness=!1,this.businessSt=new se,this.menuSt=new ie,this.productStr=new y,m(this,u).clear(),m(this,h).clear(),m(this,n).clear(),m(this,c).clear(),m(this,o).clear(),this.setBusinessReviewStr(),this.locations=[],this.filter=B({...Ce}),this.clearBusinessDataForm(),this.clearProductReviewForm(),this.activityTraceUuid=""}))})),S(this,"loadBusinessData",(async()=>{L.setLoading(!0),await Promise.all([this.loadBusiness(),this.loadLastViewed()]),L.setLoading()})),S(this,"loadLastViewed",(async()=>{m(this,n).resetPagination(),U.isAuth&&await m(this,n).loadData()})),S(this,"loadBusiness",(async()=>{try{const{longitude:e=0,latitude:t=0}=await F.getCurrentPosition();m(this,c).resetPagination(),await m(this,c).setLocation(`${t},${e}`).loadData()}catch(e){console.log(`ERR-PublishLoadBusiness: ${JSON.stringify(e)}`)}finally{L.setLoading()}})),S(this,"loadBusinessBySlug",(async e=>{L.setLoading(!0),await A(100);try{const{success:t,data:s,errors:i}=await I.getBusinessBySlug(e);t?this.setSelected(s):console.log("Error-LoadBusiness: ",i)}catch(t){console.log(`ERR-PublishLoadBusiness: ${JSON.stringify(t)}`)}finally{L.setLoading()}})),S(this,"addImgToCrop",(e=>{this.imgsToCrop.push(e),this.currentCropImage||this.setCurrentCropImage(e.id)})),S(this,"saveBusinessReview",(async()=>{L.setLoading(!0);try{this.activityTraceUuid=this.activityTraceUuid||W();const e=String(this.selected.slug),{images:t,...s}=this.businessReviewStr.form.values;s.activity_trace_uuid=this.activityTraceUuid,s.is_draft=!0;const{success:i,data:a}=await I.addBusinessReviews(e,s);let r=!1;if(i){if(E(this,g,a.uuid),t.length){const{success:e,errors:s}=await this.svcImage.addBusinessImagesReview(a.uuid,t,this.activityTraceUuid);e||(r=!0,this.businessReviewStr.form.images.onChange(V((null==s?void 0:s.images)||[],t)))}}else r=!0;if(!r){const{success:t}=await this.businessSt.updateBusinessReview(e,a.uuid,{is_draft:!1,activity_trace_uuid:this.activityTraceUuid});t&&(await this.loadShowPoints(),this.onBack(),this.businessReviewStr.clear(),this.activityTraceUuid="",E(this,g,""),this.loadBusinessData().then())}}catch(e){console.log("ERROR:",e)}finally{L.setLoading()}})),S(this,"loadShowPoints",(async()=>{await M.getObtainedPoints(this.activityTraceUuid),this.setSelected(void 0),this.activityTraceUuid=""})),S(this,"loadLocation",(async e=>{if(this.setSearch(e.trim()),!this.search)return this.setLocations([]),void this.filterLocation.onChange("");try{m(this,d).clear(),await m(this,d).setInfo({search:e}).loadData();const t=m(this,d).getElements;this.setLocations(this.search&&t.length?t:[])}catch(t){console.log("ERROR-loadUser: ",t)}finally{this.setAddBusiness(!this.locationsList.length&&!!this.search)}})),S(this,"loadProducts",(async e=>{if(this.setSearch(e.trim()),!this.search)return this.setLocations([]),void this.filterLocation.onChange("");try{if(this.selected){m(this,l).clear(),await m(this,l).setExtraInfo({productCity:this.selected.city,productName:this.selected.name,productType:this.isFoodTab?T.FOOD:T.DRINK,businessSlug:this.selected.slug??""}).setInfo({search:e}).loadData();const t=m(this,l).getElements;this.setLocations(this.search&&t.length?t:[])}}catch(t){console.log("ERROR-loadUser: ",t)}finally{this.setAddProduct(!this.locationsList.length&&!!this.search)}})),S(this,"preloadBusinessProduct",(async(e,t=!1,s=!1)=>{L.setLoading(!0),m(this,o).clear(),m(this,h).clear();const i=[];try{if(this.selected){const{city:t="",name:s="",slug:a=""}=this.selected||{};i.push(m(this,h).setInfo({slug:a,city:t,business:s,product_type:e}).loadData())}t&&i.push(m(this,o).setProductType(e).loadData()),s||i.push(this.loadLastViewed()),await Promise.all(i)}catch(a){console.log("ERROR-preloadBusinessProduct: ",a)}finally{L.setLoading()}})),S(this,"checkLogin",(async()=>{const e=await U.isValidAction({modalOpen:"LOGIN_FORM"});return e&&L.setLoading(),e})),S(this,"publishTabsNavigation",(async e=>{if(await this.checkLogin()){switch(e){case"MENU_BUSINESS_SELECTION":case"REVIEW_BUSINESS_BUSINESS_SELECTION":await this.loadBusinessData(),this.setTabNav(e);break;case"REVIEW_FOOD_BUSINESS_SELECTION":await this.loadBusinessData(),this.getAddProductStore.setProductType(!0),this.setTabNav(e),this.activityTraceUuid="";break;case"REVIEW_FOOD_FOOD_SELECTION":await this.preloadBusinessProduct(T.FOOD,!1,!0),this.setTabNav(e);break;case"REVIEW_DRINK_BUSINESS_SELECTION":await this.loadBusinessData(),this.getAddProductStore.setProductType(!1),this.setTabNav(e);break;case"REVIEW_DRINK_DRINK_SELECTION":await this.preloadBusinessProduct(T.DRINK),this.getAddProductStore.clearForm(),this.getAddProductStore.setProductType(!1),this.getAddProductStore.ensureValidators(),this.setTabNav(e);break;case"REVIEW":this.setTabNav(e);break;case"REVIEW_FOOD_SELECT_BUSINESS_DATA":case"REVIEW_DRINK_SELECT_BUSINESS_DATA":this.clearBusinessDataForm(),this.setTabNav(e)}this.publishTabAddTitle(e)}})),S(this,"publishTabAddTitle",(e=>{switch(console.log("exec: ",e),e){case"MAIN":this.setTitle(ve);break;case"MENU_BUSINESS_SELECTION":this.setTitle(Se),this.setProductReview(),this.activityTraceUuid="";break;case"MENU_REVIEW":this.setTitle(Se),this.setProductReview();break;case"REVIEW_BUSINESS_BUSINESS_SELECTION":this.setTitle(me),this.setProductReview(),this.activityTraceUuid="";break;case"REVIEW_BUSINESS":this.setTitle(me),this.setProductReview();break;case"REVIEW":this.setTitle(we),this.setProductReview();break;case"REVIEW_FOOD_BUSINESS_SELECTION":this.setBulkedReviews(),this.setTitle(_e),this.setProductReview(!1);break;case"REVIEW_FOOD_SELECT_BUSINESS_DATA":case"REVIEW_FOOD_FOOD_SELECTION":case"REVIEW_FOOD":this.setTitle(Re),this.setProductReview(!0);break;case"REVIEW_DRINK_BUSINESS_SELECTION":this.setBulkedReviews(),this.setTitle(_e),this.setProductReview(!0),this.activityTraceUuid="";break;case"REVIEW_DRINK_SELECT_BUSINESS_DATA":case"REVIEW_DRINK_DRINK_SELECTION":case"REVIEW_DRINK":this.setTitle(Ee),this.setProductReview(!0)}})),S(this,"directNavigation",(e=>{this.publishTabsNavigation(e)})),S(this,"deleteBulkedReviews",(()=>{this.selectedReviews.length&&k((()=>{this.bulkReviews=this.bulkReviews.filter((e=>!this.selectedReviews.includes(e.uuid??"")))}))})),S(this,"uploadImages",(async(e,t,s,i,a,r,c,n=W())=>{x(!0);try{if(t.length){const{success:o,data:u,errors:h}=await K.addImagesReview(e,t,n);if(o){const t=this.getBulkReviews.findIndex((t=>t.uuid===e));k((()=>{this.bulkReviews[t].uploadedImages=[...this.bulkReviews[t].uploadedImages,...u.images]})),i()}else a([...r,...z((null==h?void 0:h.images)||[],t)]),s($((null==h?void 0:h.images)||[],t)),c([])}}catch(o){console.log(o)}finally{x()}})),S(this,"deleteImages",(async(e,t)=>{x(!0);try{const{success:s}=await K.removeBatch([e]);if(s){const s=this.getBulkReviews.findIndex((e=>e.uuid===t));-1!==s&&(this.bulkReviews[s].uploadedImages=this.bulkReviews[s].uploadedImages.filter((t=>t.uuid!==e)))}}catch(s){console.log(s)}finally{x(!1)}})),S(this,"deleteSelectedReviews",(async()=>{x(!0);try{const{success:e,data:t}=await H.deleteReviewBulk(this.selectedReviews);e&&t.num_removed&&(j("EDIT_SUCCESS"),k((()=>{this.deleteBulkedReviews(),this.selectedReviews=[]})))}catch(e){}finally{x(!1)}})),S(this,"onClickMenu",(()=>{this.publishTabsNavigation(Ie)})),S(this,"onClickBusiness",(()=>{this.publishTabsNavigation(Te)})),S(this,"onClickReview",(()=>{this.publishTabsNavigation(be)})),S(this,"onClickFood",(()=>{this.publishTabsNavigation(ye)})),S(this,"onClickDrink",(()=>{this.publishTabsNavigation(Ne)})),S(this,"onBack",(()=>{k((()=>{if(1!==this.tabNav.length)switch(this.tabNav.pop(),this.publishTabAddTitle(this.getTab),this.getTab){case"REVIEW_DRINK_BUSINESS_SELECTION":case"REVIEW_FOOD_BUSINESS_SELECTION":{const e=this.getTab===ye;this.setSelected(void 0),this.preloadBusinessProduct(e?T.FOOD:T.DRINK,!0);break}case"MAIN":case"REVIEW":case"REVIEW_BUSINESS_BUSINESS_SELECTION":this.setSelected(void 0)}else J.goBack()}))})),S(this,"onSelectBusiness",(({slug:e,list:t})=>{let s;switch(t){case"NEAR":s=m(this,c).with({slug:e});break;case"RECENTLY":s=m(this,n).with({slug:e})}this.setSelected(s),this.activityTraceUuid=""})),S(this,"onSelectProduct",(({slug:e,list:t},s)=>{this.productStr.setSlug(e),this.productStr.setActivityTraceUuid(this.activityTraceUuid);let i=s;if(!s)switch(t){case"NEAR":i=m(this,o).with({slug:e});break;case"RECENTLY":i=m(this,u).with({slug:e});break;case"POPULAR":i=m(this,h).with({slug:e})}this.setProductSelected(i)})),S(this,"onBusinessReviewEditSauces",(async()=>{x(!0);const{success:e}=await this.businessSt.updateBusinessReview(this.selected.slug??"",m(this,g)??"",{is_draft:!1,activity_trace_uuid:this.activityTraceUuid});e&&(await this.loadShowPoints(),this.onBack(),this.clearBusinessReview(),this.loadBusinessData()),x()})),S(this,"onRemoveReviewImage",(e=>this.businessReviewStr.removeImage(e))),S(this,"onAddBusinessImageReview",((e,t)=>this.businessReviewStr.onHandleUploadClick(e,t))),S(this,"onClickAcceptAddReviewImage",(e=>this.businessReviewStr.onHandleImgClick(e))),S(this,"onClickAddBusinessReview",(async()=>{x(!0);const{hasError:e}=await this.businessReviewStr.form.validate;if(e)return L.setModal("ALMOST_THERE"),void x();m(this,g)?this.businessSt.editBusinessReview({data:{...this.businessReviewStr.form.values,activity_trace_uuid:this.activityTraceUuid},businessSlug:this.selected.slug??"",reviewUuid:m(this,g)},{...this.businessReviewStr.form.values,activity_trace_uuid:this.activityTraceUuid},this.businessReviewStr.form.images,this.onBusinessReviewEditSauces,this.businessReviewStr.form,!0):await this.saveBusinessReview()})),S(this,"onSearchLocation",G((e=>e?this.loadLocation(String(e||"").trim()):this.onResetSearchActive("")),300,{trailing:!0})),S(this,"onSearchProducts",G((e=>e?this.loadProducts(String(e||"").trim()):this.onResetSearchProductActive()),300,{trailing:!0})),S(this,"onResetSearchActive",(e=>{this.setLocations([]),this.filterLocation.onChange(""),this.setSearch(),e&&this.loadBusinessBySlug(String(e))})),S(this,"onResetSearchProductActive",(e=>{var t;if(e){const s=null==(t=this.locations.find((({value:t})=>t===String(e))))?void 0:t.data;this.onSelectProduct({slug:String(e)},s)}this.setLocations([]),this.filterLocation.onChange(""),this.setSearch()})),S(this,"onClickAddBusiness",(()=>{this.businessSt.loadDefaultCity(),this.search&&(this.businessSt.searchedName=this.search),L.setModal("ADD_BUSINESS")})),S(this,"onClickAddProduct",(async()=>{this.getAddProductStore.clearForm();const{name:e,business:t}=this.getAddProductStore.form;this.search&&e.onChange(this.search),t.onChange(this.selected.slug),this.productStr.getAddProductSt.setProductType(this.isFoodTab),await this.getAddProductStore.preloadBaseProductInfo({name:this.search}),L.setModal("ADD_PRODUCT"),this.setSearch()})),S(this,"onClickAddBusinessMenu",(async()=>{L.setLoading(!0);try{this.activityTraceUuid=this.activityTraceUuid||W();const{success:e,errors:t}=await this.menuSt.addBusinessMenu(String(this.selected.slug),this.activityTraceUuid);e?(await this.loadShowPoints(),this.menuSt.clear(),this.onBack(),await this.loadBusinessData()):this.menuSt.setImages(V((null==t?void 0:t.images)||[],this.menuSt.getImages))}catch(e){console.log("Error-onClickAddBusinessMenu: ",e)}finally{L.setLoading()}})),S(this,"onBusinessSuccessSaved",(({business:e,traceUuid:t})=>{this.setSelected(e),this.activityTraceUuid=t,this.setSearch()})),S(this,"clearProductReviewForm",(()=>{this.productReviewForm=B({...O(),menu_dish:!1})})),S(this,"clearBusinessDataForm",(()=>{this.businessFormData=B({...fe})})),S(this,"onProductSuccessSaved",(({product:e,traceUuid:t})=>{this.activityTraceUuid=t;const{slug:s,name:i,main_picture:a}=e;switch(this.setProductSelected({slug:s,name:i,main_picture:a,city:this.selected.city,business:this.selected.name,rating:0,num_reviews:0}),this.productStr.setSlug(s),this.getTab){case"REVIEW_DRINK_DRINK_SELECTION":this.preloadBusinessProduct(T.DRINK);break;case"REVIEW_FOOD_FOOD_SELECTION":this.preloadBusinessProduct(T.FOOD,!1,!0)}})),S(this,"onProductReviewSuccessSaved",((e=!1)=>{if(!e){this.productStr.clear();const e=this.getTab===Oe?T.FOOD:T.DRINK;this.getAddProductStore.clear(),this.clearProductReviewForm(),this.onBack(),this.preloadBusinessProduct(e,!0)}this.activityTraceUuid="",x()})),S(this,"onProductReviewSuccessEdited",(async(e=!1)=>{x(!0);const{success:t}=await H.updateProductReviews(this.productSelected.slug??"",this.productStr.reviewUuid??"",{is_draft:!1,activity_trace_uuid:this.activityTraceUuid});t&&await M.getObtainedPoints(this.activityTraceUuid),this.onProductReviewSuccessSaved(e)})),S(this,"onAddProductReview",(async()=>{await this.publishProductReview()})),S(this,"onAddBusiness",(e=>this.businessSt.onAddBusiness(e??this.onBusinessSuccessSaved))),S(this,"onAddProduct",(()=>this.getAddProductStore.onAddProduct(this.onProductSuccessSaved,this.activityTraceUuid))),S(this,"onRemoveImage",(e=>{const t=this.productReviewForm.images;t.onChange(t.value.filter(((t,s)=>s!==e)))})),S(this,"onHandleUploadClick",((e,t,s)=>{Y(e,this.addImgToCrop,void 0,t-(s||(this.productReviewForm.images.value.length??0)),this.deleteImgs)})),S(this,"ensureValidators",(()=>{this.validators()})),S(this,"onHandleClose",(()=>{this.deleteImgs()})),S(this,"deleteImgs",(()=>{this.imgsToCrop=[],this.currentCropImage=void 0})),S(this,"onHandleClickEdit",(e=>{this.setCurrentCropImage(e)})),S(this,"onHandleCropImage",(({id:e,...t})=>{const s=this.imgsToCrop.map((s=>s.id===e?{...s,...t}:s));this.setImgsToCrop(s)})),S(this,"deleteImageFromCrops",(e=>{var t;const s=this.imgsToCrop.filter((({id:t})=>t!==e));this.setImgsToCrop(s),this.currentCropImage===e&&this.setCurrentCropImage((null==(t=this.imgsToCrop[0])?void 0:t.id)??"")})),S(this,"onHandleDelete",(e=>{this.deleteImageFromCrops(e)})),S(this,"onHandleImgClick",(async e=>{let t=0;for(const s of this.imgsToCrop)t+=1,s&&t<=e&&(this.productReviewForm.images.value.length<e&&await q(s.croppedImage??s.image,(e=>{const t=this.productReviewForm.images;t.onChange([...t.value,e])}),s.image,s.type,Boolean(s.croppedImage)),this.deleteImageFromCrops(s.id))})),S(this,"validators",(()=>{const{review_date:e,rating:t}=this.productReviewForm;e.validators(Q,Z),t.validators(X(.5,"valuationIsMandatory"))})),S(this,"publishProductReview",(async()=>{this.ensureValidators();const{hasError:e}=await this.productReviewForm.validate;e||await this.saveReview()})),S(this,"publishBulkedReviews",(async()=>{var e;x(!0);try{for(const e of this.bulkReviews)if(e.images.length){const{success:t,errors:s}=await K.addImagesReview(e.uuid||"",e.images,e.activity_trace_uuid??"");if(!t)return void this.productReviewForm.images.onChange(V((null==s?void 0:s.images)||[],e.images))}const t=this.bulkReviews.map((e=>H.updateProductReviews(e.slug,e.uuid??"",{is_draft:!1,activity_trace_uuid:e.activity_trace_uuid,opinion:e.opinion,is_menu_item:e.menu_dish,rating:e.rating})));await Promise.all(t),this.tabNav.pop(),await M.getObtainedPoints(this.bulkReviews[0].activity_trace_uuid??""),null==(e=this.onProductReviewSuccessSaved)||e.call(this),this.productReviewForm.images.onChange([])}catch(t){console.log("ERROR:",t)}finally{x()}})),S(this,"saveReview",(async()=>{var e;x(!0);let t=[];try{this.activityTraceUuid=this.activityTraceUuid||W();const{images:s,...i}=this.productReviewForm.values;delete i.uuid,i.activity_trace_uuid=this.activityTraceUuid,this.businessFormData.when.value&&(i.review_date=ee(this.businessFormData.when.value).toISOString()),this.businessFormData.where.value?(i.is_at_business="LOCAL"===this.businessFormData.where.value,i.is_delivery="DELIVERY"===this.businessFormData.where.value,i.is_pickup="PICKUP"===this.businessFormData.where.value):i.is_at_business=!0,this.productReviewForm.menu_dish.value?i.is_menu_item=this.productReviewForm.menu_dish.value:i.is_menu_item=!1;const{success:a,data:r,errors:c}=await H.addProductReviews(this.productStr.getSlug,i);let n=!1;if(!a)return n=!0,void console.log(`ERROR: ${JSON.stringify(c)}`);if(s.length){const{success:e,errors:i,data:a}=await K.addImagesReview(r.uuid||"",s,this.activityTraceUuid);if(!e)return n=!0,void this.productReviewForm.images.onChange(V((null==i?void 0:i.images)||[],s));t=a.images}if(!n&&!this.getReviewDraft){const{success:t}=await H.updateProductReviews(this.productStr.getSlug??"",r.uuid||"",{is_draft:this.getReviewDraft,activity_trace_uuid:this.activityTraceUuid});if(t){const t=M.getObtainedPoints(this.activityTraceUuid);await t,null==(e=this.onProductReviewSuccessSaved)||e.call(this),this.productReviewForm.images.onChange([])}}if(this.getReviewDraft)if(this.bulkReviews.find((e=>e.slug===this.productStr.getSlug)))L.setError("ERR-REVI-016"),j("GENERIC_ERROR");else{const e={images:[],slug:this.productStr.getSlug,name:this.getSelectedProductName??"",uuid:r.uuid,productImage:this.getSelectedProductPicture??"",uploadedImages:t,...i};this.clearProductReviewForm(),k((()=>{this.tabNav.pop(),this.bulkReviews.push(e)}))}}catch(s){console.log("ERROR:",s)}finally{x()}})),P(this,{tabNav:C,title:C,selected:C,productSelected:C,locations:C,search:C,addBusiness:C,addProduct:C,productReview:C,productStr:C,businessReviewStr:C,bulkReviews:C,currentCropImage:C,imgsToCrop:C,selectedReviews:C,setTabNav:f,setTitle:f,setSelected:f,setProductSelected:f,setLocations:f,setSearch:f,setAddBusiness:f,setAddProduct:f,setProductReview:f,setProductStore:f,setBusinessReviewStr:f,setBulkedReviews:f,canGoBack:D})}get getBulkReviews(){return this.bulkReviews}get nearStr(){return m(this,o)}get businessStr(){return m(this,c)}get lastProductsStr(){return m(this,u)}get lastBusinessStr(){return m(this,n)}get popularStr(){return m(this,h)}get getProductStore(){return this.productStr}get getAddProductStore(){return this.productStr.getAddProductSt}get isProductReview(){return this.productReview}get getSearch(){return this.search}get showAddBusiness(){return this.addBusiness}get showAddProduct(){return this.addProduct}get getBusinessStore(){return this.businessSt}get getTab(){return this.tabNav[this.tabNav.length-1]}get getPrevTab(){return this.tabNav[this.tabNav.length-2]}get isFoodTab(){return this.getTab===Be}get canGoBack(){return this.tabNav.length>1}get getTitle(){return this.title}get getSearchBusinessStore(){return m(this,d)}get getSearchBusinessProductStore(){return m(this,l)}get getSelectedPicture(){var e;return null==(e=this.selected)?void 0:e.main_picture}get getSelected(){return this.selected}get getProductSelected(){return this.productSelected}get getSelectedName(){var e;return null==(e=this.selected)?void 0:e.name}get getSelectedAddress(){var e;return null==(e=this.selected)?void 0:e.address}get getSelectedFullAddress(){var e;return null==(e=this.selected)?void 0:e.full_address}get getSelectedProductPicture(){var e;return null==(e=this.productSelected)?void 0:e.main_picture}get getSelectedProductName(){var e;return null==(e=this.productSelected)?void 0:e.name}get getSelectedProductBusiness(){var e;return null==(e=this.productSelected)?void 0:e.business}get getSelectedProductCity(){var e;return null==(e=this.productSelected)?void 0:e.city}get getPriceValuation(){return this.businessReviewStr.getPriceValuation}get getReviewImages(){return this.businessReviewStr.getReviewImages}get isReviewImagesMax(){return this.businessReviewStr.isReviewImagesMax}get getImgsToCrop(){return this.businessReviewStr.getImgsToCrop}get getImgs(){return this.imgsToCrop}get getExtension(){return this.businessReviewStr.getExtension}get businessReviewForm(){return this.businessReviewStr.form}get getBusinessReviewStr(){return this.businessReviewStr}get locationsList(){return this.locations}get productsList(){return this.locations}get filterLocation(){return this.filter.location}get businessWhereTried(){return this.businessFormData.where}get businessWhenTried(){return this.businessFormData.when}get businessMealTime(){return this.businessFormData.mealTime}get menuStore(){return this.menuSt}get defaultListValues(){return!m(this,h).getSize&&!m(this,u).getSize}get getCurrentCropImage(){return this.businessReviewStr.getCurrentCropImage}get getCurrentImg(){return this.currentCropImage}get validNext(){return this.businessFormData.when.value&&this.businessFormData.where.value&&this.businessFormData.mealTime.value}get getReviewDraft(){return"REVIEW_FOOD_FOOD_SELECTION"===this.tabNav[this.tabNav.length-2]||"REVIEW_DRINK_DRINK_SELECTION"===this.tabNav[this.tabNav.length-2]}}),ke=_.createContext(new te("3"));export{ce as B,ke as I,De as P,ne as S};