PageSourceSearch

https://hiker.bg/assets/ProviderPanelView-YiAp9awS.js

js hiker.bg collected 2026-10-02 00:27:01 UTC 14,454 bytes, 1 lines download raw bytes

1import{d as ae,x as pe,r as _,c as A,E as de,f as i,i as s,a as _e,g as r,t as n,l as y,b as N,e as z,k as D,H as ue,F as g,j as x,n as T,J as I,h as S,m as C,o as V,y as re,p as ce,q as o,s as ve}from"./index-C1-QU8qG.js";import{v}from"./verifiedRouteService-CiUpWvap.js";import{t as he}from"./trailService-SizvijqX.js";import{e as w}from"./eventService-BDhzSjKo.js";import"./polylineDecode-CfIHnuhL.js";import"./parseGpx-EQ90uhtc.js";const fe={class:"pp scrollable-view"},me={class:"pp__header"},be={class:"pp__title"},ye={key:0,class:"pp__profile"},ge={class:"pp__profile-logo-wrap"},ke=["src"],Ee={key:1,class:"pp__profile-logo pp__profile-logo--placeholder"},Pe={class:"pp__profile-info"},Ce={class:"pp__profile-name"},we={key:0,class:"pp__profile-name-en"},$e=["href"],Be={class:"pp__section"},Re={class:"pp__section-header"},Ue={class:"pp__section-title"},De={key:0,class:"pp__empty"},xe={key:1,class:"pp__empty"},Se={key:2,class:"pp__list"},Ve={class:"pp__item"},Fe={class:"pp__item-info"},Le={class:"pp__item-name"},We={key:0,class:"pp__item-sub"},Me={class:"pp__item-actions"},Ne=["onClick"],ze={key:0,class:"pp__spinner"},Te=["disabled","onChange"],Ge=["onClick"],He=["onClick"],qe=["onClick"],je={class:"pp__photos"},Ae={key:0,class:"pp__photos-loading"},Ie={key:0,class:"pp__photos-empty"},Je={key:1,class:"pp__photos-grid"},Oe=["onClick"],Xe=["src"],Ke=["onClick"],Qe={key:3,class:"pp__deleted-section"},Ye={key:0,class:"pp__list pp__list--deleted"},Ze={class:"pp__item-info"},et={class:"pp__item-name pp__item-name--deleted"},tt={key:0,class:"pp__item-sub"},st={class:"pp__item-actions"},lt=["onClick"],ot={class:"pp__section"},it={class:"pp__section-header"},nt={class:"pp__section-title"},at={key:0,class:"pp__empty"},pt={key:1,class:"pp__empty"},dt={key:2,class:"pp__list"},_t={class:"pp__item"},ut={class:"pp__item-info"},rt={class:"pp__item-name"},ct={class:"pp__item-sub"},vt={class:"pp__item-actions"},ht={key:0,class:"pp__spinner"},ft=["disabled","onChange"],mt=["onClick"],bt=["onClick"],yt={class:"pp__photos"},gt={key:0,class:"pp__photos-loading"},kt={key:0,class:"pp__photos-empty"},Et={key:1,class:"pp__photos-grid"},Pt=["onClick"],Ct=["src"],wt=["onClick"],$t={class:"pp__modal"},Bt={class:"pp__modal-grid"},Rt={class:"pp__modal-field"},Ut={class:"pp__modal-label"},Dt={class:"pp__modal-field"},xt={class:"pp__modal-label"},St={class:"pp__modal-field pp__modal-field--full"},Vt={class:"pp__modal-label"},Ft={class:"pp__modal-field pp__modal-field--full"},Lt={class:"pp__modal-label"},Wt={class:"pp__modal-field"},Mt={class:"pp__modal-label"},Nt={value:1},zt={value:2},Tt={value:3},Gt={class:"pp__modal-field pp__modal-field--full"},Ht={class:"pp__modal-label"},qt={class:"pp__modal-field pp__modal-field--full"},jt={key:0,style:{"font-size":"0.8rem",color:"#1c7c54","margin-top":"0.2rem"}},At={class:"pp__modal-actions"},It=["disabled"],Jt={key:0,class:"pp__modal-error"},Ot=["src"],Xt=ae({__name:"ProviderPanelView",setup(Kt){const m=pe(),u=_([]),c=_([]),M=_(!0),G=_(!0),k=_(null),E=_(null),h=_(null),F=_(!1),$=_(""),d=_({nameBg:"",nameEn:"",descriptionBg:"",descriptionEn:"",difficulty:1,routeWebsiteUrl:"",gpxFile:null}),P=_(null),L=_(!1),H=A(()=>u.value.filter(e=>!e.isDeleted)),W=A(()=>u.value.filter(e=>e.isDeleted)),b=_({}),B=_({}),f=_({}),R=_({});de(async()=>{try{u.value=await v.list(),u.value.forEach(e=>q(e.publicRouteId))}finally{M.value=!1}try{c.value=await w.listMy(),c.value.forEach(e=>j(e.id))}finally{G.value=!1}});function J(e){return new Date(e).toLocaleDateString()}async function O(e){h.value=e,d.value={nameBg:e.nameBg,nameEn:e.nameEn??"",descriptionBg:"",descriptionEn:"",difficulty:1,routeWebsiteUrl:e.routeWebsiteUrl??"",gpxFile:null},$.value="";try{const l=await he.getTrail(e.publicRouteId);if(h.value?.id!==e.id)return;d.value.descriptionBg=l.descriptionBg??"",d.value.descriptionEn=l.descriptionEn??"",l.difficulty&&(d.value.difficulty=l.difficulty)}catch{}}function X(e){d.value.gpxFile=e.target.files?.[0]??null}async function K(){if(h.value){F.value=!0,$.value="";try{let e=await v.update(h.value.id,{nameBg:d.value.nameBg,nameEn:d.value.nameEn||void 0,descriptionBg:d.value.descriptionBg||void 0,descriptionEn:d.value.descriptionEn||void 0,difficulty:d.value.difficulty,routeWebsiteUrl:d.value.routeWebsiteUrl||void 0});
1d.value.gpxFile&&(e=await v.replaceGpx(h.value.id,d.value.gpxFile));const l=u.value.findIndex(a=>a.id===e.id);l>=0&&(u.value[l]=e),h.value=null}catch(e){$.value=String(e)}finally{F.value=!1}}}async function q(e){B.value={...B.value,[e]:!0};try{const l=await v.listPhotos(e);b.value={...b.value,[e]:l}}finally{B.value={...B.value,[e]:!1}}}async function Q(e,l){await v.deletePhoto(e,l),b.value[e]&&(b.value={...b.value,[e]:b.value[e].filter(a=>a.id!==l)})}async function j(e){R.value={...R.value,[e]:!0};try{const l=await w.listPhotos(e);f.value={...f.value,[e]:l}}finally{R.value={...R.value,[e]:!1}}}async function Y(e,l){if(await w.deletePhoto(e,l),f.value[e]){const a=f.value[e].find(t=>t.id===l);if(f.value={...f.value,[e]:f.value[e].filter(t=>t.id!==l)},a){const t=c.value.find(p=>p.id===e);t&&(t.photoUrls=t.photoUrls.filter(p=>p!==a.storagePath))}}}async function Z(e,l){const a=l.target.files?.[0];if(a){k.value=e;try{await v.uploadPhoto(e,a),await q(e)}catch(t){alert(String(t))}finally{k.value=null,l.target.value=""}}}async function ee(e){const l=await v.publish(e),a=u.value.findIndex(t=>t.id===e);a>=0&&(u.value[a]=l)}async function te(e){const l=await v.unpublish(e),a=u.value.findIndex(t=>t.id===e);a>=0&&(u.value[a]=l)}async function se(e){if(!confirm("Delete this route?"))return;await v.delete(e);const l=u.value.findIndex(a=>a.id===e);l>=0&&(u.value[l]={...u.value[l],isDeleted:!0})}async function le(e){const l=await v.restore(e),a=u.value.findIndex(t=>t.id===e);a>=0&&(u.value[a]=l)}async function oe(e){const l=await w.publish(e),a=c.value.findIndex(t=>t.id===e);a>=0&&(c.value[a]=l)}async function ie(e){confirm("Delete this event?")&&(await w.delete(e),c.value=c.value.filter(l=>l.id!==e))}async function ne(e,l){const a=l.target.files?.[0];if(a){E.value=e;try{const t=await w.uploadPhoto(e,a),p=c.value.find(U=>U.id===e);p&&!p.photoUrls.includes(t)&&p.photoUrls.push(t),await j(e)}catch(t){alert("Photo upload failed: "+String(t))}finally{E.value=null,l.target.value=""}}}return(e,l)=>{const a=ue("RouterLink");return o(),i(g,null,[s("div",fe,[s("div",me,[s("h1",be,n(e.$t("provider.panel")),1)]),y(m).providerProfile?(o(),i("div",ye,[s("div",ge,[y(m).providerProfile.logoUrl?(o(),i("img",{key:0,src:y(m).providerProfile.logoUrl,class:"pp__profile-logo",alt:""},null,8,ke)):(o(),i("div",Ee,[...l[12]||(l[12]=[s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"#aaa","stroke-width":"1.5"},[s("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s("polyline",{points:"9 22 9 12 15 12 15 22"})],-1)])]))]),s("div",Pe,[s("div",Ce,n(y(m).providerProfile.nameBg),1),y(m).providerProfile.nameEn?(o(),i("div",we,n(y(m).providerProfile.nameEn),1)):r("",!0),s("a",{href:y(m).providerProfile.websiteUrl,target:"_blank",class:"pp__profile-link"},n(y(m).providerProfile.websiteUrl),9,$e)])])):r("",!0),s("section",Be,[s("div",Re,[s("h2",Ue,n(e.$t("provider.myRoutes")),1),N(a,{to:{name:"provider-upload-route"},class:"pp__btn pp__btn--primary"},{default:z(()=>[D(" + "+n(e.$t("provider.uploadRoute")),1)]),_:1})]),M.value?(o(),i("div",De,"…")):!H.value.length&&!W.value.length?(o(),i("p",xe,n(e.$t("provider.noRoutes")),1)):(o(),i("div",Se,[(o(!0),i(g,null,x(H.value,t=>(o(),i("div",{key:t.id,class:"pp__item-wrap"},[s("div",Ve,[s("div",Fe,[s("span",Le,n(t.nameBg),1),t.nameEn?(o(),i("span",We," / "+n(t.nameEn),1)):r("",!0),s("span",{class:T(["pp__badge",t.isPublished?"pp__badge--green":"pp__badge--gray"])},n(t.isPublished?e.$t("provider.published"):"Draft"),3)]),s("div",Me,[s("button",{class:"pp__btn pp__btn--outline pp__btn--sm",onClick:p=>O(t)},"Edit",8,Ne),s("label",{class:"pp__btn pp__btn--outline pp__btn--sm",style:I(k.value===t.publicRouteId?"pointer-events:none;opacity:0.65":"cursor:pointer")},[k.value===t.publicRouteId?(o(),i("span",ze)):r("",!0),D(" "+n(k.value===t.publicRouteId?"Uploading…":"+ Photo")+" ",1),s("input",{type:"file",accept:"image/*",style:{display:"none"},disabled:k.value===t.publicRouteId,onChange:p=>Z(t.publicRouteId,p)},null,40,Te)],4),t.isPublished?(o(),i("button",{key:1,class:"pp__btn pp__btn--outline pp__btn--sm",onClick:p=>te(t.id)},n(e.$t("provider.unpublish")),9,He)):(o(),i("button",{key:0,class:"pp__btn pp__btn--primary pp__btn--sm",onClick:p=>ee(t.id)},n(e.$t("provider.publish")),9,Ge)),s("button",{class:"pp__btn pp__btn--danger pp__btn--sm",onClick:p=>se(t.id)}," Delete ",8,qe)])]),s("div",je,[B.value[t.publicRouteId]?(o(),i("div",Ae,"Loa
1ding…")):(o(),i(g,{key:1},[b.value[t.publicRouteId]?.length?(o(),i("div",Je,[(o(!0),i(g,null,x(b.value[t.publicRouteId],p=>(o(),i("div",{key:p.id,class:"pp__photo-thumb",onClick:U=>P.value=p.storagePath},[s("img",{src:p.storagePath,class:"pp__photo-img",alt:""},null,8,Xe),s("button",{class:"pp__photo-del",title:"Delete",onClick:S(U=>Q(t.publicRouteId,p.id),["stop"])},"×",8,Ke)],8,Oe))),128))])):(o(),i("p",Ie,"No photos yet"))],64))])]))),128))])),!M.value&&W.value.length?(o(),i("div",Qe,[s("div",{class:"pp__deleted-header",onClick:l[0]||(l[0]=t=>L.value=!L.value)},[s("span",null,"Deleted routes ("+n(W.value.length)+")",1),s("span",{class:T(["pp__deleted-chevron",{"pp__deleted-chevron--open":L.value}])},"›",2)]),L.value?(o(),i("div",Ye,[(o(!0),i(g,null,x(W.value,t=>(o(),i("div",{key:t.id,class:"pp__item"},[s("div",Ze,[s("span",et,n(t.nameBg),1),t.nameEn?(o(),i("span",tt," / "+n(t.nameEn),1)):r("",!0),l[13]||(l[13]=s("span",{class:"pp__badge pp__badge--red"},"Deleted",-1))]),s("div",st,[s("button",{class:"pp__btn pp__btn--outline pp__btn--sm",onClick:p=>le(t.id)},"Restore",8,lt)])]))),128))])):r("",!0)])):r("",!0)]),s("section",ot,[s("div",it,[s("h2",nt,n(e.$t("provider.myEvents")),1),N(a,{to:{name:"provider-create-event"},class:"pp__btn pp__btn--primary"},{default:z(()=>[D(" + "+n(e.$t("provider.createEvent")),1)]),_:1})]),G.value?(o(),i("div",at,"…")):c.value.length?(o(),i("div",dt,[(o(!0),i(g,null,x(c.value,t=>(o(),i("div",{key:t.id,class:"pp__item-wrap"},[s("div",_t,[s("div",ut,[s("span",rt,n(t.titleBg),1),s("span",ct," · "+n(J(t.eventDate)),1),s("span",{class:T(["pp__badge",t.isPublished?"pp__badge--green":"pp__badge--gray"])},n(t.isPublished?e.$t("provider.published"):"Draft"),3)]),s("div",vt,[N(a,{to:{name:"provider-edit-event",params:{id:t.id}},class:"pp__btn pp__btn--outline pp__btn--sm"},{default:z(()=>[...l[14]||(l[14]=[D(" Edit ",-1)])]),_:1},8,["to"]),s("label",{class:"pp__btn pp__btn--outline pp__btn--sm",style:I(E.value===t.id?"pointer-events:none;opacity:0.65":"cursor:pointer"),title:"Upload photo"},[E.value===t.id?(o(),i("span",ht)):r("",!0),D(" "+n(E.value===t.id?"Uploading…":"+ Photo")+" ",1),s("input",{type:"file",accept:"image/*",style:{display:"none"},disabled:E.value===t.id,onChange:p=>ne(t.id,p)},null,40,ft)],4),t.isPublished?r("",!0):(o(),i("button",{key:0,class:"pp__btn pp__btn--primary pp__btn--sm",onClick:p=>oe(t.id)},n(e.$t("provider.publish")),9,mt)),s("button",{class:"pp__btn pp__btn--danger pp__btn--sm",onClick:p=>ie(t.id)}," Delete ",8,bt)])]),s("div",yt,[R.value[t.id]?(o(),i("div",gt,"Loading…")):(o(),i(g,{key:1},[f.value[t.id]?.length?(o(),i("div",Et,[(o(!0),i(g,null,x(f.value[t.id],p=>(o(),i("div",{key:p.id,class:"pp__photo-thumb",onClick:U=>P.value=p.storagePath},[s("img",{src:p.storagePath,class:"pp__photo-img",alt:""},null,8,Ct),s("button",{class:"pp__photo-del",title:"Delete",onClick:S(U=>Y(t.id,p.id),["stop"])},"×",8,wt)],8,Pt))),128))])):(o(),i("p",kt,"No photos yet"))],64))])]))),128))])):(o(),i("p",pt,n(e.$t("provider.noEvents")),1))]),h.value?(o(),i("div",{key:1,class:"pp__modal-overlay",onClick:l[8]||(l[8]=S(t=>h.value=null,["self"]))},[s("div",$t,[l[16]||(l[16]=s("h2",{class:"pp__modal-title"},"Edit Route",-1)),s("form",{onSubmit:S(K,["prevent"])},[s("div",Bt,[s("div",Rt,[s("label",Ut,n(e.$t("provider.nameBg"))+" *",1),C(s("input",{"onUpdate:modelValue":l[1]||(l[1]=t=>d.value.nameBg=t),class:"pp__modal-input",required:""},null,512),[[V,d.value.nameBg]])]),s("div",Dt,[s("label",xt,n(e.$t("provider.nameEn")),1),C(s("input",{"onUpdate:modelValue":l[2]||(l[2]=t=>
1d.value.nameEn=t),class:"pp__modal-input"},null,512),[[V,d.value.nameEn]])]),s("div",St,[s("label",Vt,n(e.$t("provider.descBg")),1),C(s("textarea",{"onUpdate:modelValue":l[3]||(l[3]=t=>d.value.descriptionBg=t),class:"pp__modal-input",rows:"3"},null,512),[[V,d.value.descriptionBg]])]),s("div",Ft,[s("label",Lt,n(e.$t("provider.descEn")),1),C(s("textarea",{"onUpdate:modelValue":l[4]||(l[4]=t=>d.value.descriptionEn=t),class:"pp__modal-input",rows:"3"},null,512),[[V,d.value.descriptionEn]])]),s("div",Wt,[s("label",Mt,n(e.$t("provider.difficulty")),1),C(s("select",{"onUpdate:modelValue":l[5]||(l[5]=t=>d.value.difficulty=t),class:"pp__modal-input"},[s("option",Nt,n(e.$t("provider.difficultyEasy")),1),s("option",zt,n(e.$t("provider.difficultyModerate")),1),s("option",Tt,n(e.$t("provider.difficultyHard")),1)],512),[[re,d.value.difficulty]])]),s("div",Gt,[s("label",Ht,n(e.$t("provider.routeWebsiteUrl")),1),C(s("input",{"onUpdate:modelValue":l[6]||(l[6]=t=>d.value.routeWebsiteUrl=t),type:"url",class:"pp__modal-input",placeholder:"https://example.com/this-route"},null,512),[[V,d.value.routeWebsiteUrl]])]),s("div",qt,[l[15]||(l[15]=s("label",{class:"pp__modal-label"},"Replace GPX file (optional)",-1)),s("input",{type:"file",accept:".gpx",class:"pp__modal-input",onChange:X},null,32),d.value.gpxFile?(o(),i("span",jt,n(d.value.gpxFile.name),1)):r("",!0)])]),s("div",At,[s("button",{type:"button",class:"pp__btn pp__btn--outline pp__btn--sm",onClick:l[7]||(l[7]=t=>h.value=null)},"Cancel"),s("button",{type:"submit",class:"pp__btn pp__btn--primary pp__btn--sm",disabled:F.value},n(F.value?e.$t("provider.saving"):e.$t("provider.save")),9,It)]),$.value?(o(),i("p",Jt,n($.value),1)):r("",!0)],32)])])):r("",!0)]),(o(),_e(ce,{to:"body"},[P.value?(o(),i("div",{key:0,class:"pp__lightbox",onClick:l[11]||(l[11]=t=>P.value=null)},[s("img",{src:P.value,class:"pp__lightbox__img",alt:"",onClick:l[9]||(l[9]=S(()=>{},["stop"]))},null,8,Ot),s("button",{class:"pp__lightbox__close",onClick:l[10]||(l[10]=t=>P.value=null)},"✕")])):r("",!0)]))],64)}}}),ls=ve(Xt,[["__scopeId","data-v-cf24dac2"]]);export{ls as default};

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.