1import{a as p}from"./DXbo10_u.js";import{r as L}from"./KI3naYzN.js";import{u as P}from"./4ocfwtbW.js";import{c$ as l,at as A}from"./BQpWByWK.js";const N="/api/app/marketplace",O=12e3;function F(e){const{data:t}=P(()=>`market-seo-links-${e.value}`,async()=>[],{watch:[e],default:()=>[]});return t}function T(){return{categories:[],countries:[],merchantEntry:{hasChannel:!1,isReady:!1,channelId:"",channelUrl:"/Register?from=create-channel"},locationHint:null}}async function i(e,t){const a=new AbortController,u=globalThis.setTimeout(()=>a.abort(),O),s=new Headers(t?.headers);s.set("Content-Type","application/json"),s.set("X-WeiCity-App-Auth","1");try{const o=await fetch(`${N}${e}`,{...t,credentials:"include",headers:s,signal:a.signal});if(!o.ok)throw new Error(`API ${e}: ${o.status}`);return o.json()}finally{globalThis.clearTimeout(u)}}function H(){const e=l(null),t=l(!0),a=l("");async function u(s=p,o=!1){t.value=!0,a.value="";try{const c=new URLSearchParams({region:s});o&&c.set("allCountries","true"),e.value=await i(`/init?${c.toString()}`)}catch(c){a.value=c.message,e.value=T()}finally{t.value=!1}}return{data:e,loading:t,error:a,load:u}}function _(){const e=l(null),t=l(!1),a=l("");async function u(s){t.value=!0,a.value="";try{const o=new URLSearchParams;o.set("region",s.region),s.country&&o.set("country",s.country),s.state&&o.set("state",s.state),s.city&&o.set("city",s.city),s.scope&&o.set("scope",s.scope),s.search&&o.set("search",s.search),s.categories.length>0&&o.set("categories",s.categories.join(",")),s.view&&o.set("view",s.view),e.value=await i(`/dashboard?${o}`)}catch(o){a.value=o.message}finally{t.value=!1}}return{data:e,loading:t,error:a,load:u}}function G(){const e=l([]),t=l(!1),a=l(!1),u=l(""),s=l(0);async function o(c,v=!1){if(!(a.value&&!v)){a.value=!0,u.value="",v&&(e.value=[],s.value=0,t.value=!1);try{const r=new URLSearchParams;r.set("region",c.region),c.country&&r.set("country",c.country),c.state&&r.set("state",c.state),c.city&&r.set("city",c.city),c.scope&&r.set("scope",c.scope),c.search&&r.set("search",c.search),c.categories.length>0&&r.set("categories",c.categories.join(",")),c.tab&&r.set("tab",c.tab),c.module&&r.set("module",c.module),r.set("startIndex",String(s.value));const f=await i(`/feed?${r}`);if(v)e.value=f.items;else{const g=new Set(e.value.map(d=>d.docId)),m=f.items.filter(d=>!g.has(d.docId));e.value=[...e.value,...m]}t.value=f.hasMore,s.value+=f.items.length}catch(r){u.value=r?.message||"Feed load failed"}finally{a.value=!1}}}return{items:e,hasMore:t,loading:a,error:u,load:o}}function q(e,t){const a=new URLSearchParams;return a.set("region",e.region),e.country&&a.set("country",e.country),e.state&&a.set("state",e.state),e.city&&a.set("city",e.city),e.scope&&a.set("scope",e.scope),e.search&&a.set("search",e.search),e.categories.length>0&&a.set("categories",e.categories.join(",")),a.set("startIndex",String(t)),a.toString()}function R(e){const t=l([]),a=l(!1),u=l(!1),s=l(""),o=l(!1),c=l(!1),v=l(0),r=l(0);let f=0;function g(d){return d.voucher?.docId||d.product?.id||""}async function m(d,I=!1){if(u.value&&!I)return;const k=++f;u.value=!0,s.value="",I&&(t.value=[],r.value=0,a.value=!1,o.value=!1,c.value=!1,v.value=0);try{const y=await i(`${e}?${q(d,r.value)}`);if(k!==f)return;L(y?.nowUtc);const w=y.items??[];if(I)t.value=w;else{const M=new Set(t.value.map(g));t.value=[...t.value,...w.filter(S=>!M.has(g(S)))]}a.value=!!y.hasMore,o.value=!!y.pending,c.value=!!y.truncated,v.value=y.totalCount??0,r.value+=w.length}catch(y){if(k!==f)return;s.value=y?.message||"Directory deal load failed"}finally{k===f&&(u.value=!1)}}return{items:t,hasMore:a,loading:u,error:s,pending:o,truncated:c,totalCount:v,load:m}}function B(){return R("/vouchers")}function J(){return R("/deal-products")}function Q(e){const t=l(""),a=l(""),u=l(""),s=l(""),o=l(""),c=l(""),v=l(!0),r=l([]),f=l([]),g=l(!1),m=l(!1);async function d(n,C){if(t.value=n,a.value=C||e.value.find(h=>h.value===n)?.label||n,u.value="",s.value="",o.value="",c.value="",f.value=[],v.value=!1,n){g.value=!0;try{r.value=await i(`/states?country=${encodeURIComponent(n)}`)}catch{r.value=[]}finally{g.value=!1}}else r.value=[]}
1async function I(n,C){if(u.value=n,s.value=C||r.value.find(h=>h.value===n)?.label||n,o.value="",c.value="",n&&t.value){m.value=!0;try{f.value=await i(`/cities?country=${encodeURIComponent(t.value)}&state=${encodeURIComponent(n)}`)}catch{f.value=[]}finally{m.value=!1}}else f.value=[]}function k(n,C){o.value=n,c.value=C||f.value.find(h=>h.value===n)?.label||n}function y(n){v.value=!1,o.value=n.cityId,c.value=n.cityLabel||n.cityId,n.countryCode?(t.value=n.countryCode,a.value=n.countryName||n.countryCode):(t.value="",a.value=""),n.stateName?(u.value=n.stateName,s.value=n.stateName):(u.value="",s.value=""),r.value=[],f.value=[]}function w(n,C,h){v.value=!1,t.value=n,a.value=C||n,u.value=h||"",s.value=h||"",o.value="",c.value="",r.value=[],f.value=[]}function M(){v.value=!0,t.value="",a.value="",u.value="",s.value="",o.value="",c.value="",r.value=[],f.value=[]}function S(){v.value=!1,t.value="",a.value="",u.value="",s.value="",o.value="",c.value="",r.value=[],f.value=[]}async function b(n){n.countryCode&&(await d(n.countryCode,n.countryName||n.countryCode),n.stateName&&await I(n.stateName,n.stateName),n.cityId&&k(n.cityId))}const U=A(()=>({country:t.value,state:u.value,city:o.value,scope:v.value?"global":""}));return{selectedCountry:t,selectedCountryLabel:a,selectedState:u,selectedStateLabel:s,selectedCity:o,selectedCityLabel:c,isGlobal:v,stateOptions:r,cityOptions:f,statesLoading:g,citiesLoading:m,selectCountry:d,selectState:I,selectCity:k,applyCity:y,applyCountryOnly:w,setGlobal:M,reset:S,applyHint:b,scopeParams:U}}async function W(e){return i(`/feed/${encodeURIComponent(e)}/like`,{method:"POST"})}async function V(e){return i(`/feed/${encodeURIComponent(e)}/bookmark`,{method:"POST"})}async function X(e){return i("/location-preference",{method:"POST",body:JSON.stringify(e)})}async function z(e,t,a=20){const u=(e||"").trim();return u.length<2?[]:i(`/cities/search?q=${encodeURIComponent(u)}&limit=${a}®ion=${encodeURIComponent(t)}`)}async function K(e,t=12){return i(`/cities/popular?limit=${t}®ion=${encodeURIComponent(e)}`)}async function Y(e){return i(`/cities/center?cityId=${encodeURIComponent(e)}`)}async function Z(){const e=await i("/location-hint/ip");return e.found?e.hint:null}async function ee(e,t,a){return i(`/cities/nearest?lat=${encodeURIComponent(e)}&lng=${encodeURIComponent(t)}®ion=${encodeURIComponent(a)}`)}function $(e){const t=new URLSearchParams;return t.set("region",e.region),e.country&&t.set("country",e.country),e.state&&t.set("state",e.state),e.city&&t.set("city",e.city),e.scope&&t.set("scope",e.scope),e.categories&&e.categories.length>0&&t.set("categories",e.categories.join(",")),t.set("startIndex",String(e.startIndex)),t.set("take",String(e.take??12)),t.toString()}async function te(e){return i(`/merchants/popular?${$(e)}`)}async function ae(e){return i(`/merchants/latest?${$(e)}`)}async function ne(e){return i(`/merchants/recommended?${$(e)}`)}async function se(e){return i(`/aggregates/recent?${$({...e,categories:[]})}`)}async function ce(e){return i(`/aggregates/hot?${$({...e,categories:[]})}`)}async function oe(e){return i(`/aggregates/recommended?${$({...e,categories:[]})}`)}async function le(e){return i(`/feed/${encodeURIComponent(e)}/comments`)}async function ue(e,t){return i(`/feed/${encodeURIComponent(e)}/comments`,{method:"POST",body:JSON.stringify({content:t})})}export{Z as a,Y as b,ce as c,ae as d,te as e,le as f,se as g,oe as h,ne as i,K as j,ee as k,z as l,W as m,J as n,G as o,ue as p,H as q,Q as r,X as s,V as t,_ as u,F as v,B as w};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.