1import{_ as M,j as w,L as v,m as F,X as l,M as x,l as I,a5 as R,i as N,c,a as s,g as S,F as $,r as L,G as T,$ as B,W as E,o as r,d as O,f as V}from"./index-D4lqpvgS.js";const j={class:"cfm-root"},A={class:"cfm-body"},D={key:0,class:"cfm-spinner-wrap"},G={key:1,class:"cfm-grid"},J=["onClick"],U=["src"],W={key:2,class:"cfm-empty"},X={key:0,class:"pagination-loader"},q={__name:"ChooseFacebookMedia",setup(z){const g=I(),{proxy:h}=w(),_=v(!1),p=v(!1),i=v(""),d=v(null),f=v(null),m=F(()=>l.state.facebook.pagePosts);let u=null;async function b(e=null){var n;const a={};return e&&(a.after=e),((n=(await E({method:"GET",url:`${h.$fbURL}/api/facebook/${u}/posts`,params:a,withCredentials:!0,headers:{"Content-Type":"application/json"}})).data)==null?void 0:n.payload)||{}}async function k(){var e,a,o,n;if(!(p.value||!i.value)){p.value=!0;try{const t=await b(i.value);((e=t==null?void 0:t.data)==null?void 0:e.length)>0?(l.dispatch("facebook/setPagePosts",[...m.value,...t.data]),i.value=((o=(a=t.paging)==null?void 0:a.cursors)==null?void 0:o.after)||""):(i.value="",(n=f.value)==null||n.disconnect())}catch(t){console.log(t)}finally{p.value=!1}}}function y(){f.value&&d.value&&(f.value.unobserve(d.value),f.value.observe(d.value))}async function P(e){for(const a of e)a.isIntersecting&&i.value&&await k()}x(async()=>{var e,a,o,n;if(u=(e=l.state.facebook.activePage)==null?void 0:e.page_id,!u)try{const t=sessionStorage.getItem("hypd_fb_active_page");t&&(u=(a=JSON.parse(t))==null?void 0:a.page_id)}catch{}if(!u){g.replace({name:"AutoDMRules"});return}if(!l.state.facebook.activePage){g.replace({name:"AutoDMRules",params:{platform:"facebook",accountId:u}});return}if(await R(),f.value=N(d.value,P),!(m.value.length>0)){_.value=!0;try{const t=await b();l.dispatch("facebook/setPagePosts",(t==null?void 0:t.data)||[]),i.value=((n=(o=t==null?void 0:t.paging)==null?void 0:o.cursors)==null?void 0:n.after)||""}catch(t){console.log(t)}finally{_.value=!1,y()}}});function C(e){V("autoreply_select_post:clicked",{facebook_post_id:e==null?void 0:e.id,media_type:"post"}),l.dispatch("facebook/clearFbRule"),l.dispatch("facebook/setSelectedFbMedia",{...e,media_url:e.thumbnail_url||e.media_url||e.full_picture,caption:e.message||""}),g.push({name:"ManageRule",params:{mode:"create"}})}return(e,a)=>(r(),c("div",j,[a[3]||(a[3]=s("div",{class:"cfm-header"},[s("h4",{class:"cfm-title"},"Select Post"),s("div",{class:"cfm-steps"},"Step 1/3")],-1)),s("div",A,[_.value?(r(),c("div",D,a[0]||(a[0]=[s("div",{class:"rolling-spinner"},[s("div"),s("div"),s("div"),s("div")],-1)]))):m.value.length>0?(r(),c("div",G,[(r(!0),c($,null,L(m.value,o=>(r(),c("div",{key:o.id,class:"cfm-post",onClick:n=>C(o)},[s("img",{class:"cfm-thumb",src:o.thumbnail_url||o.media_url||o.full_picture,alt:""},null,8,U)],8,J))),128))])):(r(),c("div",W,a[1]||(a[1]=[s("div",{class:"cfm-empty-heading"},"No posts found on this Facebook page.",-1),s("p",null,"Publish a post on Facebook to get started.",-1)]))),S(B,{name:"pagination-fade"},{default:T(()=>[p.value?(r(),c("div",X,a[2]||(a[2]=[s("div",{class:"pagination-spinner"},null,-1),s("span",null,"Loading moreâ¦",-1)]))):O("",!0)]),_:1}),s("div",{ref_key:"target",ref:d},null,512)])]))}},K=M(q,[["__scopeId","data-v-d1856a7f"]]);export{K 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.