jQuery(document).ready(function(b){function c(){b("#loading-posts").show();b.ajax({url:ajax_linkedin.ajax_url,method:"POST",data:{action:"linkedin_request",nonce:ajax_linkedin.nonce,organization_id:ajax_linkedin.organization_id,limit:ajax_linkedin.limit,text_char_limit:ajax_linkedin.text_char_limit,post_image:ajax_linkedin.post_image},success:function(a){b("#loading-posts").hide();a.success?(console.log("Fetched fresh LinkedIn posts."),f(a.data)):(console.error("Error: "+a.data),b("#error-linkedin-message").html("Error: "+
a.data))},error:function(a,e,d){b("#loading-posts").hide();console.error("Ajax error: "+d);b("#linkedin-data").html("Ajax error: "+d)}})}function f(a){var e=a.organization_details,d=a.organization_followers,c="";a.posts.slice(0,8).forEach(function(a){var b="";a.video_url?b='<video width="100%" height="100%" autoplay loop muted>\n                            <source src="'+a.video_url+'" type="video/mp4">\n                            Your browser does not support the video tag.\n                         </video>':
a.image_url&&(b='<img class="image-preview-wt" width="100%" height="100%" src="'+a.image_url+'" alt="media-image" loading="lazy">');c+='\n        <div class="masonry-item">\n            <a target="_blank" href="'+a.post_url+'">\n                '+b+'\n                <div class="masonry-info">\n                    <p>'+a.description+'</p>\n                    <div class="masonry-company">\n                        <img width="100%" height="100%" src="'+e.logo+'" alt="Company Logo" loading="lazy">\n                        <div class="masonry-company-container">\n                            <div class="masonry-company-details">\n                                <p style="font-weight: 700;font-size: 14px;">'+
e.name+"</p>\n                                <span>"+d.followers+" "+ajax_linkedin.followers_text+"</span>\n                                <p>"+a.timestamp+'</p>\n                            </div>\n                            <div class="masonry-linked-in">\n                                <svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 24 24">\n                                    <path d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z"/>\n                                </svg>\n                            </div>\n                        </div>\n                    </div>\n                </div>\n            </a>\n        </div>'});
b("#linkedin-data").html(c)}b("#loading-posts").show();b.ajax({url:ajax_linkedin.ajax_url,method:"POST",data:{action:"linkedin_get_cached_posts"},success:function(a){b("#loading-posts").hide();a.success?(console.log("Loaded cached LinkedIn posts."),f(a.data)):(console.log("No cached posts found, fetching new data..."),c())},error:function(){b("#loading-posts").hide();console.log("Error fetching cached posts. Fetching new data...");c()}})});