(()=>{var t={23779:t=>{t.exports=()=>'\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n \n
\n
\n
\n
\n
\n
\n
\n \n \n
\n
\n
\n
\n
\n
'},45523:t=>{t.exports={loaderSVG:()=>'',getStockImageSVG:()=>'',photosIconSvg:()=>'',unsplashOutboundLinkSVG:()=>'',searchButtonSVG:()=>'',downloadButtonSVG:()=>'',gearButtonSVG:()=>'',checkSVG:()=>''}},78410:(t,e,n)=>{const o=n(45523),a=n(23779);t.exports=t=>{const e=wp.media.view.MediaFrame.Select.prototype.browseRouter,n=".tcb-unsplash-grid";let s=1;const i="#tcb-unsplash-loader",l="#tcb-unsplash-search-input",c="#tcb-unsplash-clear-search-btn",r="#tcb-unsplash-order-dropdown",d="#tcb-unsplash-ordination-dropdown",p="#tcb-unsplash-category-dropdown";let h=!1;wp.media.view.MediaFrame.Select.prototype.browseRouter=function(n){const a=this;setTimeout(()=>{const e=t('.media-menu-item:contains("Stock Library")');e.length&&e.html(`Stock Library ${o.getStockImageSVG()}`)},100),e.call(this,n),window.originalBrowseRouterFrame=this,n.set({upload:{text:wp.media.view.l10n.uploadFilesTitle,priority:20,click:()=>this.content.mode("upload")},browse:{text:wp.media.view.l10n.mediaLibraryTitle,priority:40,click:()=>this.content.mode("browse")},unsplash:{text:"Stock Library",priority:60,click:()=>{s=1,"unsplash"!==this.content.mode()&&(this.content.mode("unsplash"),this.loadUnsplashContent(),t('[aria-labelledby="menu-item-unsplash"]').css("overflow-y","scroll"))}}}),this.content.mode("browse"),this.on("close",function(){s=1}),t(document).on("click",".media-menu-item",function(){s=1});const i=setInterval(()=>{const e=t(".media-frame-content");e.length>0&&(e.off("scroll",a.checkScrollPosition.bind(this)).on("scroll",a.checkScrollPosition.bind(this)),clearInterval(i))},100)},wp.media.view.MediaFrame.Select.prototype.loadUnsplashContent=function(){if(window.isUnsplashContentLoaded)return;const e=this;this.unsplashContent=new wp.media.View({className:"unsplash-content"}),this.unsplashContent.render(),this.unsplashContent.$el.html(a),this.loadUnsplashImages(s,"",t(r).val(),t(d).val()),e.$el.on("focus",l,function(){t(this).on("input",function(){const n=t(this).val();n&&n.length>0?e.$el.find(c).show():e.$el.find(c).hide()})}),e.$el.on("keypress",l,function(t){l&&"Enter"===t.key&&(t.preventDefault(),e.$el.find("#tcb-unsplash-search-btn").click())}),e.$el.find(r).on("change input",function(){e.$el.find("#tcb-unsplash-search-btn").click(),console.log("Order by changed")}),e.$el.on("click","#tcb-unsplash-search-btn",function(){const t=e.$el.find(l).val();if(!t.trim()&&!e.$el.find(r).val())return;let o=t;const a=e.$el.find(p).val();a&&(o+=` ${a}`,e.$el.find("#tcb-full-search-term").data("full-search-term",o));const i=e.$el.find(r).val(),h=e.$el.find(d).val();s=1,e.unsplashContent.$el.find(n).empty(),e.loadUnsplashImages(s,o,i,h),t&&t.length>0&&e.$el.find(c).show()}),e.$el.on("click",c,function(){e.$el.find(l).val(""),e.$el.find(r).val("relevant"),e.$el.find(d).val(""),e.$el.find(p).val(""),s=1,e.$el.find("#tcb-full-search-term").data("full-search-term",""),e.unsplashContent.$el.find(n).empty(),e.loadUnsplashImages(s,"",e.$el.find(r).val(),e.$el.find(d).val()),e.$el.find(".tcb-unsplash-ordination").addClass("hidden"),e.$el.find(".tcb-unsplash-category").addClass("hidden"),e.$el.find(".tcb-unsplash-total-count").html(`${o.photosIconSvg()} Photos`),e.$el.find(c).hide()}),this.content.set(this.unsplashContent)},wp.media.view.MediaFrame.Select.prototype.loadUnsplashImages=function(e,o="",a="relevant",s=""){const l=this;h||(h=!0,l.$el.find(i).show(),t.ajax({url:unsplashApi.ajax_url,method:"POST",data:{action:"unsplash_list",nonce:unsplashApi.nonce,count:20,page:e,search:o,order_by:a,orientation:s},success:t=>{l.processImagesResponse(t)},error:()=>{t(n).append("Unable to load images from Unsplash.
")},complete:()=>{h=!1,l.unsplashContent.$el.find(i).hide(),t(".tcb-unsplash-holder").css({display:"block",opacity:1})}}))},wp.media.view.MediaFrame.Select.prototype.processImagesResponse=function(t){const e=this;if(!t.success)return void e.$el.find(n).append("Unable to load images from Unsplash.
");const a=t.data.results.map(t=>{const e=t.height/t.width;return`\n\t\t\t\t\n\t\t\t\t\t${function(t){const{id:e,urls:n,unsplash_link:a,unsplash_author_link:s,user_name:i,user_photo:l,alt_description:c}=t;return`

\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t

\n\t\t\t\t\t
${i}\n\t\t\t\t
\n\t\t\t\t
`}(t)}\n\t\t\t\t
\n\t\t\t`}).join("");e.unsplashContent.$el.find(n).append(a);const i=e.unsplashContent.$el.find(n).children();_.debounce(()=>{i.css("opacity",1)},400)(),t.data.total>0&&e.$el.find(l).val()&&(e.$el.find(".tcb-unsplash-ordination").removeClass("hidden"),e.$el.find(".tcb-unsplash-category").removeClass("hidden"),e.updatePhotoCount(t.data.total)),s++},wp.media.view.MediaFrame.Select.prototype.updatePhotoCount=function(t){const e=this,n=(e.$el.find(l).val().trim(),e.$el.find(p).val(),function(t){if(t>=1e3){const e=(t/1e3).toFixed(1);return e.endsWith(".0")?e.slice(0,-2)+"k":e+"k"}return t}(t));e.$el.find(".tcb-unsplash-total-count").html(`${o.photosIconSvg()} Photos ${n}`)},wp.media.view.MediaFrame.Select.prototype.checkScrollPosition=function(){const t=this,e=t.$el.find(".media-frame-content");if(0===e.length)return;const n=e.scrollTop();if(e.prop("scrollHeight")-n-e.innerHeight()<200&&!h){const e=t.$el.find(l).val(),n=t.$el.find("#tcb-full-search-term").data("full-search-term")||e,o=t.$el.find(r).val(),a=t.$el.find(d).val();t.loadUnsplashImages(s,n,o,a)}},wp.media.events.on("close",function(){s=1})}}},e={};function n(o){var a=e[o];if(void 0!==a)return a.exports;var s=e[o]={exports:{}};return t[o](s,s.exports,n),s.exports}const o=n(45523),a=n(78410);window.originalBrowseRouterFrame="",jQuery(document).ready(function(t){a(t),t(document).on("click",'body:not([data-element="image_gallery"]) .tcb-unsplash-download-button',function(){const e=t(this);if(e.data("clicked"))return void console.warn("This button click is already being handled.");e.data("clicked",!0);const n=e.closest(".tcb-unsplash-grid-item"),a=n.data("photo-id"),s=n.find(".tcb-unsplash-image").attr("photo-title")||"No Title",i=t(".tcb-unsplash-stock-author"),l=t(".tcb-stock-image-buttons");i.hide(),l.hide();const c=n.find("#tcb-unsplash-loading-container .loading-background");c.html(o.loaderSVG()).show().css("display","flex"),t.ajax({url:unsplashApi.ajax_url,method:"POST",data:{action:"unsplash_download_image",nonce:unsplashApi.nonce,photo_id:a,title:s},beforeSend(){},success(t){if(t.success){wp.media.frames.unsplashFrame||(wp.media.frames.unsplashFrame=wp.media({title:"Select or Upload Media",button:{text:"Use this media"},multiple:!1})),wp.media.frames.unsplashFrame;const n=t.data.attachment_id;wp.media.attachment(n).fetch().then(function(t){const n=window.originalBrowseRouterFrame.state().get("selection");n.add(new wp.media.model.Attachment(t)),e.closest(".tcb-editor-main").length>0?(window.originalBrowseRouterFrame.state().trigger("insert",n),window.originalBrowseRouterFrame.state().trigger("reset",n),window.originalBrowseRouterFrame.close(),window.originalBrowseRouterFrame.content.mode("browse"),window.originalBrowseRouterFrame.content.get().collection.props.set({ignore:Date.now()})):(window.originalBrowseRouterFrame.content.mode("browse"),window.originalBrowseRouterFrame.content.get().collection.props.set({ignore:Date.now()}))}).catch(function(t){console.error("Failed to fetch attachment details:",t)})}else console.error("Server-side error:",t.data)},error(t,e,n){console.error("AJAX request failed. Status:",e,"Error:",n)},complete(){c.empty().hide(),e.removeData("clicked"),i.show(),l.show()}})}),t(document).on("click",'body:not([data-element="image_gallery"]) .tcb-unsplash-gear-button',function(e){t(".unsplash-gear-popup").remove();const n=t(this),a=n.closest(".tcb-unsplash-grid-item"),s=a.find(".tcb-unsplash-image"),i=n.closest(".tcb-unsplash-grid-item").find("#tcb-unsplash-loading-container .loading-background"),l=s.attr("photo-title")||"No Title Available",c=s.attr("filename")||"No Title Available",r=s.attr("alt")||"No Title Available",d=a.data("photo-id"),p=s.position(),h=s.outerWidth()-18,u=s.outerHeight()-18,m=p.top+(s.outerHeight()-u)/2,w=p.left+(s.outerWidth()-h)/2,f=t(".tcb-unsplash-stock-author"),g=t(".tcb-stock-image-buttons");f.hide(),g.hide();const v=t('