PageSourceSearch

https://leanpub.com/assets/recommendation_cart_button-B9AXVWCf.js

js leanpub.com collected 2026-09-24 08:27:10 UTC 2,620 bytes, 5 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ab14d67c-eee6-5907-9a3b-67f7b30557ac")}catch(e){}}();
3import{b as k,r as b,j as f}from"./vendor-react-qLnyzkeB.js";import{R as T}from"./r_button-BiU6XUE-.js";import{R as v}from"./index-9As2c7F9.js";import{Q as A}from"./quick_buy_modal-B0I3NmcI.js";import{g as x}from"./cartable_form-Dhm6fOWR.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"13978386027a4a2683cfa43e79422df47742043f"}}catch{}})();function P(a,e,s){switch(a){case"StoreBundleProduct":return`/b/${e}`;case"StoreCourseProduct":return`/c/${s}/${e}`;case"StoreTrackProduct":return`/t/${s}/${e}`;default:return`/${e}`}}function E(){let a=0;const e=60,s=800;let d=!1,c=0,r=1/0;const n=i=>{if(!d){if(document.documentElement.style.overflow==="hidden"&&a<e){a+=1,requestAnimationFrame(n);return}d=!0,c=i+s,r=window.scrollY,window.scrollTo({top:0,behavior:"smooth"}),requestAnimationFrame(n);return}window.scrollY>r+2&&window.scrollTo({top:0}),r=window.scrollY,i<c&&requestAnimationFrame(n)};requestAnimationFrame(n)}const q=({productId:a,slug:e,publisherSlug:s,type:d,title:c,redirectToCartAfterAdd:r=!1,moveToCart:n=!1,replaceInCart:i=!1,hideCredits:w=!1,couponCode:m=null})=>{const o=k(),[_,h]=b.useState(!1),[y,$]=b.useState(null),t=o.data&&"product"in o.data?o.data.product:null,p=o.data&&"coupon"in o.data?o.data.coupon:null,g=o.state==="loading",R=()=>{if(h(!0),!t&&o.state==="idle"){const l=m?`?coupon=${encodeURIComponent(m)}`:"";o.load(`/quick_buy/${encodeURIComponent(a)}${l}`)}},u=(t==null?void 0:t.variants.find(l=>l.id===y))??(t==null?void 0:t.defaultVariant),S=p&&u?x(p.productVariantDiscounts,u)??null:null;return f.jsxs("div",{className:"relative z-10",children:[f.jsx(T,{type:"button",color:"blue",size:"compact",className:"min-w-48 whitespace-nowrap",disabled:g,"aria-label":i?`Upgrade to ${c} in cart`:`${n?"Move":"Add"} ${c} to Cart`,onClick:R,children:f.jsx(v,{k:i?"w_upgrade_in_cart":n?"w_move_to_cart":"w_add_to_cart"})}),t&&u&&f.jsx(A,{action:P(d,e,s),show:_,onClose:()=>h(!1),product:t,details:t,cartable:u,authors:t.authors,coupon:p,productVariantDiscount:S,showPackageSelection:t.hasMultiplePackages,onPackageChange:l=>$(l),redirectToCartAfterAdd:r,replaceInCart:i,hideCredits:w,onAddedToCart:r?void 0:E})]})};export{q as R};
4
5//# debugId=ab14d67c-eee6-5907-9a3b-67f7b30557ac

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.