diff --git a/dist/asset-manifest.json b/dist/asset-manifest.json deleted file mode 100644 index 5ef0a3d..0000000 --- a/dist/asset-manifest.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "/assets/index-6eoTm8wC.css": { - "hash": "83b2b4cfbc17a5fdb809072471930bc37ad8eed049b6763723e96333b7bcb8da", - "size": 52948 - }, - "/assets/index-CO3v1MWd.js": { - "hash": "22bab8fa45c6df2b720b6f51b78fea2ac36dbbea7ff810dd25adb2d9d10b9d7c", - "size": 740112 - }, - "/cart.png": { - "hash": "7f447e40edee2caa22d91ccab3420324a3ed86c61b1dc6fa3dd8a53fb2ea0c82", - "size": 45827 - }, - "/index.html": { - "hash": "106ebf923deb5b4c9e499e25de95b9c618e681a1d17aae63cffc082d3f07d52b", - "size": 455 - }, - "/logo.png": { - "hash": "876df5d6c4960441007de433e054433e06c14d6233c331cb351dc5db02ab5f35", - "size": 648990 - }, - "/logo.svg": { - "hash": "1e7acf9b67412ab2d260d9cd504d4f66bfc1f79b1c4dbcca2a1a68cd6e1f2af2", - "size": 760 - }, - "/skinnylogo.png": { - "hash": "29380663a5375bc9ac63b26d91a3542ec9654cc55d68f20b151859832b80a991", - "size": 283578 - } -} \ No newline at end of file diff --git a/dist/assets/index-CO3v1MWd.js b/dist/assets/index-BiCSRSdf.js similarity index 97% rename from dist/assets/index-CO3v1MWd.js rename to dist/assets/index-BiCSRSdf.js index e6a48c7..0ba2a65 100644 --- a/dist/assets/index-CO3v1MWd.js +++ b/dist/assets/index-BiCSRSdf.js @@ -227,7 +227,7 @@ Please change the parent to {j(),e||A()},[e]);const j=async()=>{try{const[O,_]=await Promise.all([fetch("/api/collections"),fetch("/api/products")]);if(O.ok&&_.ok){const k=await O.json(),M=await _.json();n(k);const P=k.map(z=>({...z,products:M.filter(G=>G.collectionId===z.id)}));o(P)}}catch(O){console.error("Error fetching collections and products:",O)}},A=async()=>{try{const O=await fetch("/api/store-settings");if(O.ok){const _=await O.json();f(_)}}catch(O){console.error("Error fetching store settings:",O)}},E=O=>{const _=new Set(p);_.has(O)?_.delete(O):_.add(O),g(_)},T=({to:O,className:_,children:k,onClick:M})=>t?d.jsx("span",{className:`${_} cursor-default`,onClick:P=>{P.preventDefault(),M&&M(P)},children:k}):d.jsx(gr,{to:O,className:_,onClick:M,children:k});return d.jsxs("nav",{className:"bg-white shadow-sm border-b relative z-50 storefront-nav",children:[d.jsx("div",{className:"max-w-8xl mx-auto px-4 sm:px-6 lg:px-8",children:d.jsxs("div",{className:"flex items-center justify-between h-16",children:[d.jsxs(T,{to:"/",className:"flex-shrink-0",children:[S.logoType==="image"&&S.logoImageUrl?d.jsx("img",{src:S.logoImageUrl,alt:S.storeName||"Store Logo",className:"h-8 max-w-48 object-contain",onError:O=>{O.target.style.display="none",O.target.nextSibling.style.display="block"}}):null,d.jsx("h1",{className:`text-2xl font-bold storefront-heading ${S.logoType==="image"&&S.logoImageUrl?"hidden":"block"}`,children:S.logoText||"OpenShop"})]}),d.jsx("div",{className:"hidden md:flex absolute left-1/2 transform -translate-x-1/2",children:d.jsxs("div",{className:"flex items-baseline space-x-6",children:[d.jsx(T,{to:"/",className:"storefront-heading hover:text-slate-600 px-3 py-2 rounded-md text-sm font-medium transition-colors duration-200",children:"Home"}),l.map(O=>d.jsxs("div",{className:"relative group",children:[d.jsxs(T,{to:`/collections/${O.id}`,className:"storefront-heading hover:text-slate-600 px-3 py-2 rounded-md text-sm font-medium transition-colors duration-200 flex items-center",children:[O.name,O.products.length>0&&d.jsx("svg",{className:"w-4 h-4 ml-1 transition-transform duration-200 group-hover:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),O.products.length>0&&d.jsx("div",{className:"absolute left-0 top-full w-72 bg-white rounded-md rounded-t-none shadow-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 z-[100] pointer-events-none group-hover:pointer-events-auto storefront-surface-inverse storefront-radius",children:d.jsxs("div",{className:"py-2",children:[d.jsxs("div",{className:"px-4 py-2 text-xs font-semibold storefront-subtle uppercase tracking-wide border-b",children:[O.name," Products"]}),d.jsx("div",{className:"max-h-80 overflow-y-auto",children:O.products.map(_=>d.jsx(T,{to:`/products/${_.id}`,className:"block px-4 py-3 hover:bg-slate-50 transition-colors duration-150",children:d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsxs("div",{className:"flex-shrink-0",children:[_.images&&_.images.length>0?d.jsx("img",{src:bt(_.images[0]),alt:_.name,className:"w-10 h-10 object-cover rounded-md",onError:k=>{k.target.style.display="none",k.target.nextSibling.style.display="flex"}}):_.imageUrl?d.jsx("img",{src:bt(_.imageUrl),alt:_.name,className:"w-10 h-10 object-cover rounded-md",onError:k=>{k.target.style.display="none",k.target.nextSibling.style.display="flex"}}):null,d.jsx("div",{className:"w-10 h-10 bg-slate-200 rounded-md flex items-center justify-center",style:{display:_.images&&_.images.length>0||_.imageUrl?"none":"flex"},children:d.jsx("svg",{className:"w-5 h-5 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})})]}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-sm font-medium storefront-heading truncate",children:_.name}),d.jsxs("p",{className:"text-sm storefront-subtle font-semibold",children:["$",_.price]})]})]})},_.id))}),d.jsx("div",{className:"border-t px-4 py-2",children:d.jsxs(T,{to:`/collections/${O.id}`,className:"text-sm storefront-subtle hover:text-slate-700 font-medium",children:["View all ",O.name," →"]})})]})})]},O.id))]})}),d.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[d.jsxs("button",{onClick:t?O=>O.preventDefault():w,className:`relative p-2 storefront-heading hover:text-slate-600 transition-all duration-200 hover:scale-110 ${t?"cursor-default":""}`,children:[d.jsx(uN,{className:"w-6 h-6 transition-transform duration-200"}),b>0&&d.jsx("span",{className:"absolute -top-1 -right-1 bg-slate-600 text-white text-xs font-bold rounded-full h-5 w-5 flex items-center justify-center animate-bounce-in",children:b>99?"99+":b})]}),d.jsx("button",{onClick:()=>m(!h),className:"md:hidden storefront-heading hover:text-slate-600 transition-colors duration-200 p-2",children:h?d.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}):d.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})]})]})}),h&&d.jsx("div",{className:"md:hidden border-t bg-white storefront-surface-inverse",children:d.jsxs("div",{className:"px-2 pt-2 pb-3 space-y-1",children:[d.jsx(T,{to:"/",className:"block px-3 py-2 text-base font-medium storefront-heading hover:text-slate-600 hover:bg-slate-50 rounded-md transition-colors duration-200",onClick:()=>m(!1),children:"Home"}),l.map(O=>d.jsxs("div",{className:"space-y-1",children:[d.jsxs("button",{onClick:()=>E(O.id),className:"flex items-center justify-between w-full px-3 py-2 text-base font-medium storefront-heading hover:text-slate-600 hover:bg-slate-50 rounded-md transition-colors duration-200",children:[d.jsx("span",{children:O.name}),d.jsx("svg",{className:`w-4 h-4 transition-transform duration-200 ${p.has(O.id)?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),O.products.length>0&&p.has(O.id)&&d.jsxs("div",{className:"pl-6 space-y-1",children:[O.products.slice(0,5).map(_=>d.jsx(T,{to:`/products/${_.id}`,className:"block px-3 py-2 text-sm storefront-subtle hover:bg-slate-50 rounded-md transition-colors duration-200",onClick:()=>m(!1),children:d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsx("div",{className:"flex-shrink-0",children:_.images&&_.images.length>0?d.jsx("img",{src:_.images[0],alt:_.name,className:"w-8 h-8 object-cover rounded"}):_.imageUrl?d.jsx("img",{src:_.imageUrl,alt:_.name,className:"w-8 h-8 object-cover rounded"}):d.jsx("div",{className:"w-8 h-8 bg-slate-200 rounded flex items-center justify-center",children:d.jsx("svg",{className:"w-4 h-4 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})})}),d.jsxs("div",{className:"flex-1",children:[d.jsx("p",{className:"font-medium storefront-heading truncate",children:_.name}),d.jsxs("p",{className:"storefront-subtle font-semibold",children:["$",_.price]})]})]})},_.id)),d.jsx(T,{to:`/collections/${O.id}`,className:"block px-3 py-2 text-sm storefront-subtle hover:text-slate-700 font-medium border-t border-slate-200 pt-2 mt-2",onClick:()=>m(!1),children:"View Collection →"}),O.products.length>5&&d.jsxs(T,{to:`/collections/${O.id}`,className:"block px-3 py-2 text-sm storefront-subtle hover:text-slate-700 font-medium",onClick:()=>m(!1),children:["View all ",O.products.length," products →"]})]})]},O.id))]})})]})}function dN({previewSettings:e}){const[t,r]=x.useState({heroImageUrl:"",heroTitle:"Welcome to OpenShop",heroSubtitle:"Discover amazing products at unbeatable prices. Built on Cloudflare for lightning-fast performance."}),n=e||t;return x.useEffect(()=>{if(e)return;let l=!0;async function o(){try{const c=await fetch("/api/store-settings");if(c.ok){const f=await c.json();l&&r(h=>({...h,heroImageUrl:f.heroImageUrl||"",heroTitle:f.heroTitle||h.heroTitle,heroSubtitle:f.heroSubtitle||h.heroSubtitle}))}}catch(c){console.error("Failed to load store settings",c)}}return o(),()=>{l=!1}},[e]),d.jsxs("section",{className:"relative w-full overflow-hidden storefront-hero",children:[n.heroImageUrl?d.jsx("img",{src:bt(n.heroImageUrl),alt:"Hero",className:"w-full h-[90vh] object-cover block"}):d.jsx("div",{className:"w-full min-h-[320px] sm:min-h-[420px] lg:min-h-[560px]",style:{backgroundColor:"#1e293b"}}),d.jsx("div",{className:"absolute inset-0 bg-black/35","aria-hidden":!0}),d.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center px-4 sm:px-6 lg:px-8 py-12 text-center text-white",children:d.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[d.jsx("h1",{className:"text-4xl md:text-6xl font-bold",children:n.heroTitle}),d.jsx("p",{className:"text-xl md:text-2xl max-w-3xl mx-auto",children:n.heroSubtitle}),d.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[d.jsx(Se,{size:"lg",children:"Shop Now"}),d.jsx(Se,{size:"lg",variant:"outline",className:"border-white text-slate-900 bg-white hover:bg-gradient-to-r hover:from-slate-600 hover:to-slate-700 hover:text-white hover:border-transparent transition-all duration-300",asChild:!0,children:d.jsx(gr,{to:"/about",children:"Learn More"})})]})]})})]})}function n4({products:e=[]}){const[t,r]=x.useState(0);x.useEffect(()=>{if(e.length===0)return;const c=setInterval(()=>{r(f=>f===e.length-1?0:f+1)},5e3);return()=>clearInterval(c)},[e.length]);const n=()=>{r(t===0?e.length-1:t-1)},l=()=>{r(t===e.length-1?0:t+1)};if(e.length===0)return d.jsx("div",{className:"relative w-full h-96 rounded-lg flex items-center justify-center storefront-surface-inverse",children:d.jsx("p",{className:"storefront-subtle",children:"No featured products available"})});const o=e[t];return d.jsxs("div",{className:"relative w-full h-96 overflow-hidden storefront-hero storefront-radius-lg",children:[d.jsx("div",{className:"absolute inset-0",onClick:l,children:o.images&&o.images.length>0?d.jsx("img",{src:bt(o.images[0]),alt:o.name,className:"w-full h-full object-cover opacity-50"}):o.imageUrl?d.jsx("img",{src:bt(o.imageUrl),alt:o.name,className:"w-full h-full object-cover opacity-50"}):d.jsx("div",{className:"w-full h-full opacity-50",style:{background:"linear-gradient(135deg, var(--storefront-color-secondary), var(--storefront-color-primary))"}})}),d.jsx("div",{className:"relative z-10 flex items-center justify-center h-full text-center px-8",children:d.jsxs("div",{children:[d.jsx("h2",{className:"text-4xl font-bold mb-4 storefront-heading",children:o.name}),d.jsx("p",{className:"text-lg mb-6 max-w-2xl storefront-subtle",children:o.tagline||o.description}),d.jsx(gr,{to:`/products/${o.id}`,onClick:c=>c.stopPropagation(),children:d.jsxs(Se,{size:"lg",className:"cursor-pointer",children:["Shop Now - $",o.price]})})]})}),d.jsx("button",{type:"button",onClick:n,"aria-label":"Previous product",className:"absolute left-4 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white p-2 rounded-full hover:bg-opacity-75 transition-all z-20 cursor-pointer",children:d.jsx(oN,{className:"w-6 h-6"})}),d.jsx("button",{type:"button",onClick:l,"aria-label":"Next product",className:"absolute right-4 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white p-2 rounded-full hover:bg-opacity-75 transition-all z-20 cursor-pointer",children:d.jsx(sN,{className:"w-6 h-6"})}),d.jsx("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 flex space-x-2 z-20",children:e.map((c,f)=>d.jsx("button",{onClick:()=>r(f),className:`w-3 h-3 rounded-full transition-all cursor-pointer ${f===t?"bg-white":"bg-white bg-opacity-50"}`},f))})]})}const it=x.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:tn("rounded-lg border border-slate-200 bg-white text-slate-950 shadow-sm",e),...t}));it.displayName="Card";const un=x.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:tn("flex flex-col space-y-1.5 p-6",e),...t}));un.displayName="CardHeader";const fn=x.forwardRef(({className:e,...t},r)=>d.jsx("h3",{ref:r,className:tn("text-2xl font-semibold leading-none tracking-tight",e),...t}));fn.displayName="CardTitle";const a4=x.forwardRef(({className:e,...t},r)=>d.jsx("p",{ref:r,className:tn("text-sm text-slate-500",e),...t}));a4.displayName="CardDescription";const ft=x.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:tn("p-6 pt-0",e),...t}));ft.displayName="CardContent";const hN=x.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:tn("flex items-center p-6 pt-0",e),...t}));hN.displayName="CardFooter";var mN="basil",i4=function(t){return t===3?"v3":t},pN="https://js.stripe.com",l4="".concat(pN,"/").concat(mN,"/stripe.js"),o4=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,s4=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;var c4=function(t){return o4.test(t)||s4.test(t)},u4=function(){for(var t=document.querySelectorAll('script[src^="'.concat(pN,'"]')),r=0;r element.");return l.appendChild(n),n},f4=function(t,r){!t||!t._registerWrapper||t._registerWrapper({name:"stripe-js",version:"7.9.0",startTime:r})},os=null,pu=null,vu=null,d4=function(t){return function(r){t(new Error("Failed to load Stripe.js",{cause:r}))}},h4=function(t,r){return function(){window.Stripe?t(window.Stripe):r(new Error("Stripe.js not available"))}},m4=function(t){return os!==null?os:(os=new Promise(function(r,n){if(typeof window>"u"||typeof document>"u"){r(null);return}if(window.Stripe){r(window.Stripe);return}try{var l=u4();if(!(l&&t)){if(!l)l=Nw(t);else if(l&&vu!==null&&pu!==null){var o;l.removeEventListener("load",vu),l.removeEventListener("error",pu),(o=l.parentNode)===null||o===void 0||o.removeChild(l),l=Nw(t)}}vu=h4(r,n),pu=d4(n),l.addEventListener("load",vu),l.addEventListener("error",pu)}catch(c){n(c);return}}),os.catch(function(r){return os=null,Promise.reject(r)}))},p4=function(t,r,n){if(t===null)return null;var l=r[0],o=l.match(/^pk_test/),c=i4(t.version),f=mN;o&&c!==f&&console.warn("Stripe.js@".concat(c," was loaded on the page, but @stripe/stripe-js@").concat("7.9.0"," expected Stripe.js@").concat(f,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var h=t.apply(void 0,r);return f4(h,n),h},ss,vN=!1,gN=function(){return ss||(ss=m4(null).catch(function(t){return ss=null,Promise.reject(t)}),ss)};Promise.resolve().then(function(){return gN()}).catch(function(e){vN||console.warn(e)});var yN=function(){for(var t=arguments.length,r=new Array(t),n=0;n(Hm||(Hm=yN(void 0)),Hm);async function xN(e){try{const t=await v4(),n=await(await fetch("/api/create-checkout-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({priceId:e})})).json();if(n.error)throw new Error(n.error);const l=await t.redirectToCheckout({sessionId:n.sessionId});if(l.error)throw new Error(l.error.message)}catch(t){throw console.error("Error redirecting to checkout:",t),t}}function Mg({product:e,disableNavigation:t}){const[r,n]=x.useState(0),{addItem:l}=Df(),o=(Array.isArray(e.images)?e.images:e.imageUrl?[e.imageUrl]:[]).map(bt),c=o.length>1,f=async()=>{if(!t)try{await xN(e.stripePriceId)}catch(b){console.error("Error initiating checkout:",b),alert("Error starting checkout. Please try again.")}},h=()=>{n(b=>(b+1)%o.length)},m=()=>{n(b=>(b-1+o.length)%o.length)},p=()=>{t||l(e)},g=({to:b,children:w,className:S})=>t?d.jsx("div",{className:S,children:w}):d.jsx(gr,{to:b,className:S,children:w});return d.jsxs(it,{className:"group overflow-hidden hover:shadow-xl transition-shadow duration-300 storefront-card storefront-radius",children:[d.jsx(g,{to:`/products/${e.id}`,className:"block",children:d.jsx("div",{className:"relative aspect-w-16 aspect-h-12 overflow-hidden",style:{backgroundColor:"var(--storefront-color-accent-soft)",borderTopLeftRadius:"var(--storefront-radius-lg)",borderTopRightRadius:"var(--storefront-radius-lg)"},children:o.length>0?d.jsxs(d.Fragment,{children:[d.jsx("img",{src:o[r],alt:e.name,className:"w-full h-48 object-cover",style:{borderTopLeftRadius:"var(--storefront-radius-lg)",borderTopRightRadius:"var(--storefront-radius-lg)"}}),c&&d.jsxs(d.Fragment,{children:[d.jsx("button",{onClick:b=>{b.preventDefault(),m()},className:"absolute left-2 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white p-1 rounded-full hover:bg-opacity-75 transition-all opacity-0 group-hover:opacity-100",children:d.jsx(oN,{className:"w-4 h-4"})}),d.jsx("button",{onClick:b=>{b.preventDefault(),h()},className:"absolute right-2 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white p-1 rounded-full hover:bg-opacity-75 transition-all opacity-0 group-hover:opacity-100",children:d.jsx(sN,{className:"w-4 h-4"})}),d.jsx("div",{className:"absolute bottom-2 left-1/2 transform -translate-x-1/2 flex space-x-1",children:o.map((b,w)=>d.jsx("button",{onClick:S=>{S.preventDefault(),n(w)},className:`w-2 h-2 rounded-full transition-all ${w===r?"bg-white":"bg-white bg-opacity-50"}`},w))})]})]}):d.jsx("div",{className:"w-full h-48 flex items-center justify-center",style:{backgroundColor:"var(--storefront-color-accent-soft)"},children:d.jsx("svg",{className:"w-12 h-12 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})})}),d.jsxs(ft,{className:"p-4",children:[d.jsx(g,{to:`/products/${e.id}`,className:"hover:text-slate-600",children:d.jsx("h3",{className:"text-lg font-semibold storefront-heading mb-2 line-clamp-2",children:e.name})}),d.jsx("p",{className:"storefront-subtle text-sm mb-3 line-clamp-2",children:e.tagline||e.description}),d.jsx("div",{className:"flex items-center justify-between",children:d.jsx("span",{className:"text-2xl font-bold storefront-heading",children:Dr(e.price,e.currency)})})]}),d.jsx(hN,{className:"p-4 pt-0",children:d.jsxs("div",{className:"grid grid-cols-2 gap-2 w-full",children:[d.jsxs(Se,{onClick:p,variant:"outline",className:"w-full",disabled:t,children:[d.jsx(uN,{className:"w-4 h-4 mr-2"}),"Add to Cart"]}),d.jsx(Se,{onClick:f,className:"w-full",disabled:!e.stripePriceId||t,children:"Buy Now"})]})})]})}function Mi({previewSettings:e}){const[t,r]=x.useState("contact@example.com"),[n,l]=x.useState(!0);x.useEffect(()=>{if(e){r(e.contactEmail||"contact@example.com"),l(!1);return}o()},[e]);const o=async()=>{try{const c=await fetch("/api/contact-email");if(c.ok){const f=await c.json();r(f.email||"contact@example.com")}else r("contact@example.com")}catch(c){console.error("Error fetching contact email:",c),r("contact@example.com")}finally{l(!1)}};return d.jsx("footer",{className:"storefront-surface border-t border-gray-200",children:d.jsxs("div",{className:"max-w-8xl mx-auto px-4 sm:px-6 lg:px-8 py-6",children:[d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 min-h-32 md:h-24",children:[d.jsxs("div",{className:"flex flex-col justify-center items-center text-center space-y-2 md:col-span-1",children:[d.jsx("h3",{className:"text-lg font-semibold storefront-heading",children:"Get in Touch"}),d.jsx("p",{className:"storefront-subtle text-sm",children:"Have questions about our products or need support? We'd love to hear from you."}),d.jsx("a",{href:`mailto:${t&&t!=="contact@example.com"?t:"contact@example.com"}`,className:"inline-flex items-center px-4 py-2 storefront-button-outline storefront-radius-sm text-sm font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-300",children:n?"Loading...":"Contact Us"})]}),d.jsx("div",{className:"flex flex-col justify-center items-center md:col-span-1",children:d.jsxs("a",{href:"https://github.com/AJFrio/OpenShop",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center px-4 py-2 storefront-button-outline storefront-radius-sm text-sm font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-300",children:[d.jsx("svg",{className:"w-4 h-4 mr-2",fill:"currentColor",viewBox:"0 0 20 20",children:d.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),"Made with OpenShop"]})})]}),d.jsx("div",{className:"mt-6 pt-4 md:mt-3 md:pt-3 border-t border-gray-200",children:d.jsxs("p",{className:"text-center text-sm storefront-subtle",children:["Copyright ",new Date().getFullYear()," OpenShop. All rights reserved."]})})]})})}function g4(){const[e,t]=x.useState([]),[r,n]=x.useState([]),[l,o]=x.useState(null),[c,f]=x.useState(!0);x.useEffect(()=>{h()},[]);const h=async()=>{try{f(!0);const[g,b]=await Promise.all([fetch("/api/products"),fetch("/api/collections")]);if(g.ok){const w=await g.json();t(w)}if(b.ok){const w=await b.json();n(w)}}catch(g){console.error("Error fetching data:",g)}finally{f(!1)}},m=l?e.filter(g=>g.collectionId===l):e,p=e.slice(0,3);return c?d.jsxs("div",{className:"min-h-screen storefront-surface",children:[d.jsx(mn,{}),d.jsx("div",{className:"flex items-center justify-center h-96",children:d.jsxs("div",{className:"text-center",children:[d.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 mx-auto mb-4",style:{borderColor:"var(--storefront-color-primary)",borderBottomColor:"transparent"}}),d.jsx("p",{className:"storefront-subtle",children:"Loading products..."})]})})]}):d.jsxs("div",{className:"min-h-screen storefront-surface",children:[d.jsx(mn,{}),d.jsx(dN,{}),p.length>0&&d.jsxs("section",{className:"max-w-8xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[d.jsx("h2",{className:"text-3xl font-bold storefront-heading mb-8 text-center",children:"Featured Products"}),d.jsx(n4,{products:p})]}),d.jsx("section",{className:"max-w-8xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:d.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[d.jsx(Se,{variant:l===null?"default":"outline",onClick:()=>o(null),children:"All Products"}),r.map(g=>d.jsx(Se,{variant:l===g.id?"default":"outline",onClick:()=>o(g.id),children:g.name},g.id))]})}),d.jsx("section",{className:"max-w-8xl mx-auto px-3 sm:px-4 lg:px-6 pb-16",children:m.length===0?d.jsxs("div",{className:"text-center py-16",children:[d.jsx("div",{className:"storefront-subtle mb-4",children:d.jsx("svg",{className:"w-16 h-16 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}),d.jsx("h3",{className:"text-xl font-semibold storefront-heading mb-2",children:"No products found"}),d.jsx("p",{className:"storefront-subtle mb-6",children:l?"No products in this collection yet.":"No products available at the moment."}),l&&d.jsx(Se,{onClick:()=>o(null),children:"View All Products"})]}):d.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-6",children:m.map(g=>d.jsx(Mg,{product:g},g.id))})}),d.jsx(Mi,{})]})}const Pg="openshop_admin_token";function y4(e){localStorage.setItem(Pg,e);try{window.dispatchEvent(new CustomEvent("openshop-admin-login"))}catch{}}function wN(){return localStorage.getItem(Pg)}function kv(){localStorage.removeItem(Pg);try{window.dispatchEvent(new CustomEvent("openshop-admin-logout"))}catch{}}function b4(){const e=wN();return e!==null&&e.length>0}async function ct(e,t={}){const r=wN();if(!r)throw kv(),new Error("Admin authentication required");const n={"Content-Type":"application/json","X-Admin-Token":r,...t.headers},l=await fetch(e,{...t,headers:n});if(l.status===401)throw kv(),new Error("Admin session expired. Please log in again.");if(l.status===502){const o=await l.json().catch(()=>({}));throw new Error(o.error||"Service temporarily unavailable")}return l}async function x4(e){try{const t=await fetch("/api/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})});if(t.ok){const{token:r}=await t.json();return y4(r),!0}else return!1}catch(t){return console.error("Admin login error:",t),!1}}const Ye=x.forwardRef(({className:e,type:t,...r},n)=>d.jsx("input",{type:t,className:tn("flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r}));Ye.displayName="Input";function w4({onLoginSuccess:e}){const[t,r]=x.useState(""),[n,l]=x.useState(!1),[o,c]=x.useState(""),f=async h=>{h.preventDefault(),l(!0),c("");try{await x4(t)?e():c("Invalid password. Please try again.")}catch{c("Login failed. Please try again.")}finally{l(!1)}};return d.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:d.jsxs(it,{className:"w-full max-w-md",children:[d.jsx(un,{children:d.jsx(fn,{className:"text-center",children:"Admin Login"})}),d.jsxs(ft,{children:[d.jsxs("form",{onSubmit:f,className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium mb-2",children:"Password"}),d.jsx(Ye,{type:"password",value:t,onChange:h=>r(h.target.value),placeholder:"Enter admin password",required:!0,disabled:n})]}),o&&d.jsx("div",{className:"text-red-600 text-sm",children:o}),d.jsx(Se,{type:"submit",className:"w-full bg-slate-900 text-white hover:bg-gradient-to-r hover:from-gray-600 hover:to-gray-700 transition-all duration-300",disabled:n,children:n?"Logging in...":"Login"})]}),d.jsxs("div",{className:"mt-4 text-center text-sm text-gray-600",children:[d.jsxs("p",{children:["Default password: ",d.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded",children:"admin123"})]}),d.jsx("p",{className:"mt-1",children:"Change this in your environment variables!"})]})]})]})})}const $a=x.forwardRef(({className:e,children:t,...r},n)=>d.jsxs("div",{className:"relative",children:[d.jsx("select",{className:tn("flex h-10 w-full appearance-none rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-slate-950 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r,children:t}),d.jsx(p3,{className:"absolute right-3 top-3 h-4 w-4 opacity-50 pointer-events-none"})]}));$a.displayName="Select";const Dg=x.forwardRef(({className:e,...t},r)=>d.jsx("textarea",{className:tn("flex min-h-[80px] w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...t}));Dg.displayName="Textarea";function Mv({open:e,onClose:t,onPick:r}){const[n,l]=x.useState([]),[o,c]=x.useState(!1),[f,h]=x.useState("");x.useEffect(()=>{e&&m()},[e]);async function m(){try{c(!0),h("");const g=await ct("/api/admin/media",{method:"GET"});if(!g.ok)throw new Error("Failed to load media");const b=await g.json(),w=Array.isArray(b)?[...b].sort((S,j)=>(j.createdAt||0)-(S.createdAt||0)):[];l(w)}catch(g){h(g.message||"Failed to load media")}finally{c(!1)}}function p(g){r?.(g),t?.()}return e?d.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50",onClick:t,children:d.jsxs("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-3xl mx-4 flex flex-col max-h-[80vh] overflow-hidden",onClick:g=>g.stopPropagation(),children:[d.jsx("div",{className:"p-4 border-b flex items-center justify-between flex-shrink-0",children:d.jsx("h3",{className:"text-lg font-semibold",children:"Select existing media"})}),d.jsx("div",{className:"p-4 flex-1 overflow-y-auto",children:o?d.jsx("p",{className:"text-sm text-gray-500",children:"Loading…"}):f?d.jsx("p",{className:"text-sm text-red-600",children:f}):n.length===0?d.jsx("p",{className:"text-sm text-gray-600",children:"No media yet. Add images in the Media tab."}):d.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:n.map(g=>d.jsx("button",{type:"button",className:"aspect-square rounded border overflow-hidden bg-white hover:ring-2 hover:ring-gray-500",title:g.filename||g.url,onClick:()=>p(g.url),children:d.jsx("img",{src:bt(g.url),alt:g.filename||"media",className:"w-full h-full object-cover"})},g.id))})}),d.jsx("div",{className:"p-3 border-t flex justify-end flex-shrink-0",children:d.jsx(Se,{type:"button",variant:"outline",onClick:t,children:"Close"})})]})}):null}function bs({value:e,onChange:t,placeholder:r="Image URL",onPreview:n,onRemove:l,required:o=!1,inputName:c,hideInput:f=!1}){const[h,m]=x.useState(""),p=x.useRef(null),[g,b]=x.useState(!1),w=j=>{const A=S(j.target.value);t(A)},S=j=>{const A=(j||"").trim();if(!A||!(A.includes("drive.google.com")||A.includes("drive.usercontent.google.com")))return j;const T=A.match(/\/file\/d\/([a-zA-Z0-9_-]+)/),O=A.match(/[?&#]id=([a-zA-Z0-9_-]+)/),_=T&&T[1]||O&&O[1]||null,k=_?`https://drive.usercontent.google.com/download?id=${_}&export=view`:A;return k!==A&&(m("Google Drive link detected — converted for reliable preview and delivery."),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>m(""),3e3)),k};return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-2",children:[!f&&d.jsx(Ye,{name:c,type:"url",value:e,onChange:w,placeholder:r,required:o,className:"flex-1"}),d.jsxs(Se,{type:"button",onClick:()=>b(!0),className:"flex items-center gap-1",children:[d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12 5v14"}),d.jsx("path",{d:"M5 12h14"})]}),"Select media"]}),e&&d.jsx("button",{type:"button",className:"w-12 h-12 rounded overflow-hidden border bg-white",title:"Preview",onClick:()=>n&&n(bt(e)),children:d.jsx("img",{src:bt(e),alt:"preview",className:"w-full h-full object-cover"})}),l&&d.jsx(Se,{type:"button",variant:"outline",size:"sm",onClick:l,className:"px-3",children:"×"})]}),h&&d.jsx("p",{className:"text-xs text-gray-700 mt-2",children:h}),d.jsx(Mv,{open:g,onClose:()=>b(!1),onPick:j=>{t(j),b(!1)}})]})}const Lf=x.createContext({open:!1,setOpen:()=>{}});function Uu({open:e,onOpenChange:t,children:r}){const[n,l]=x.useState(!1),o=typeof e=="boolean",c=o?e:n,f=h=>{o&&t&&t(h),o||l(h)};return d.jsx(Lf.Provider,{value:{open:c,setOpen:f},children:r})}function Bu({children:e}){const{open:t,setOpen:r}=x.useContext(Lf);return t?d.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[d.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:()=>r(!1)}),d.jsx("div",{className:"relative bg-white rounded-lg shadow-lg w-full max-w-md mx-4",children:e})]}):null}function Iu({children:e}){return d.jsx("div",{className:"p-6 pb-2",children:e})}function $u({children:e}){return d.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:e})}function qu({children:e}){return d.jsx("p",{className:"mt-2 text-sm text-gray-600",children:e})}function Hu({children:e}){return d.jsx("div",{className:"p-6 pt-2 flex justify-end gap-2",children:e})}function S4({children:e,onClick:t}){const{setOpen:r}=x.useContext(Lf);return d.jsx("button",{type:"button",className:"px-4 py-2 rounded border hover:bg-gray-50",onClick:n=>{t?.(n),r(!1)},children:e})}function Ku({children:e,onClick:t}){const{setOpen:r}=x.useContext(Lf);return d.jsx("button",{type:"button",className:"px-4 py-2 rounded bg-slate-900 text-white hover:bg-gradient-to-r hover:from-slate-600 hover:to-slate-700",onClick:n=>{t?.(n),r(!1)},children:e})}function Pi({checked:e=!1,onCheckedChange:t,className:r,id:n}){return d.jsx("button",{id:n,role:"switch","aria-checked":e,type:"button",onClick:()=>t&&t(!e),className:tn("relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200",e?"bg-purple-600":"bg-gray-300",r),children:d.jsx("span",{"aria-hidden":"true",className:tn("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200",e?"translate-x-5":"translate-x-0")})})}function j4({collection:e,onSave:t,onCancel:r}){const[n,l]=x.useState({id:"",name:"",description:"",heroImage:"",archived:!1}),[o,c]=x.useState(!1),[f,h]=x.useState(null),[m,p]=x.useState(!1),[g,b]=x.useState(""),[w,S]=x.useState(""),[j,A]=x.useState(null),E=o;x.useEffect(()=>{l(e||(k=>({...k,id:js()})))},[e]);const T=k=>{const{name:M,value:P}=k.target,z=M==="heroImage"?O(P):P;l(G=>({...G,[M]:z}))};function O(k){const M=(k||"").trim();if(!M||!(M.includes("drive.google.com")||M.includes("drive.usercontent.google.com")))return k;const z=M.match(/\/file\/d\/([a-zA-Z0-9_-]+)/),G=M.match(/[?&#]id=([a-zA-Z0-9_-]+)/),le=z&&z[1]||G&&G[1]||null,J=le?`https://drive.usercontent.google.com/download?id=${le}&export=view`:M;if(J!==M){S("Google Drive link detected — converted for reliable preview and delivery."),j&&clearTimeout(j);const ae=setTimeout(()=>S(""),3e3);A(ae)}return J}const _=async k=>{k.preventDefault(),c(!0);try{const M=e?`/api/admin/collections/${e.id}`:"/api/admin/collections",z=await ct(M,{method:e?"PUT":"POST",body:JSON.stringify(n)});if(z.ok){const G=await z.json();t(G)}else throw new Error("Failed to save collection")}catch(M){console.error("Error saving collection:",M),b("Error saving collection. Please try again."),p(!0)}finally{c(!1)}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"w-full max-w-4xl mx-auto space-y-6",children:[d.jsxs("div",{className:"sticky top-0 z-20 px-6 py-4 bg-white/95 backdrop-blur border border-gray-200 rounded-lg flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:e?"Edit Collection":"Create New Collection"}),d.jsx("p",{className:"text-sm text-gray-500",children:"Organize products into collections with names, descriptions, and hero imagery."})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Se,{type:"button",variant:"outline",onClick:r,children:"Cancel"}),d.jsx(Se,{type:"submit",form:"collection-form",disabled:E,children:o?"Saving...":e?"Update Collection":"Create Collection"})]})]}),d.jsx(it,{className:"w-full",children:d.jsx(ft,{className:"p-6",children:d.jsxs("form",{id:"collection-form",onSubmit:_,className:"space-y-6",children:[d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium mb-2",children:"Collection Name *"}),d.jsx(Ye,{name:"name",value:n.name,onChange:T,placeholder:"Enter collection name",required:!0})]}),w&&d.jsx("p",{className:"text-xs text-gray-700 mt-2",children:w}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Pi,{id:"collection-archived",checked:!!n.archived,onCheckedChange:k=>l(M=>({...M,archived:k}))}),d.jsx("label",{htmlFor:"collection-archived",className:"text-sm text-gray-700 select-none",children:"Archived (hide from storefront)"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium mb-2",children:"Description"}),d.jsx(Dg,{name:"description",value:n.description,onChange:T,placeholder:"Enter collection description",rows:3})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium mb-2",children:"Hero Banner Image"}),d.jsx(bs,{value:n.heroImage,onChange:k=>l(M=>({...M,heroImage:k})),placeholder:"https://example.com/hero-banner.jpg",onPreview:k=>h(k),hideInput:!0}),d.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"This image will be displayed as a banner on the collection page"})]})]})})})]}),f&&d.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50",onClick:()=>h(null),children:d.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-3xl w-full mx-4 relative max-h-[90vh] overflow-auto",onClick:k=>k.stopPropagation(),children:[d.jsx("button",{type:"button",className:"absolute top-2 right-2 px-2 py-1 rounded border bg-white/90 hover:bg-white",onClick:()=>h(null),"aria-label":"Close",children:"×"}),d.jsx("img",{src:f,alt:"preview",className:"w-full h-auto max-h-[80vh] object-contain rounded"}),d.jsx("div",{className:"p-3 border-t text-center",children:d.jsx("a",{href:f,target:"_blank",rel:"noreferrer",className:"text-sm text-gray-600 hover:text-gray-700",children:"Open original"})})]})}),d.jsx(Uu,{open:m,onOpenChange:p,children:d.jsxs(Bu,{children:[d.jsxs(Iu,{children:[d.jsx($u,{children:"Something went wrong"}),d.jsx(qu,{children:g})]}),d.jsx(Hu,{children:d.jsx(Ku,{children:"OK"})})]})})]})}const A4=[{id:"mock-1",name:"Premium Headphones",tagline:"High-fidelity wireless audio",description:"High-fidelity wireless headphones with noise cancellation.",price:29900,currency:"USD",imageUrl:"https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=500&q=80",stripePriceId:"price_mock"},{id:"mock-2",name:"Ergonomic Chair",tagline:"Comfort for your workspace",description:"Designed for comfort and productivity during long work sessions.",price:45e3,currency:"USD",imageUrl:"https://images.unsplash.com/photo-1592078615290-033ee584e267?w=500&q=80",stripePriceId:"price_mock"},{id:"mock-3",name:"Mechanical Keyboard",tagline:"Tactile typing experience",description:"Tactile switches and customizable RGB lighting.",price:12e3,currency:"USD",imageUrl:"https://images.unsplash.com/photo-1587829741301-dc798b91a91e?w=500&q=80",stripePriceId:"price_mock"}],N4=[{title:"Brand Colors",description:"Primary palette for calls to action, highlights, and text accents.",fields:[{key:"primary",label:"Primary Color"},{key:"secondary",label:"Secondary Color"},{key:"accent",label:"Accent Color"},{key:"text",label:"Text Color"}]},{title:"Surface Colors",description:"Backgrounds that shape the storefront canvas and product cards.",fields:[{key:"background",label:"Page Background"},{key:"card",label:"Product Card Background"}]}];function SN(e=gt){return{colors:{primary:e.colors.primary,secondary:e.colors.secondary,accent:e.colors.accent,text:e.colors.text,background:e.colors&&e.colors.background||gt.colors.background,card:e.colors&&e.colors.card||gt.colors.card},typography:{fontId:e.typography.fontId},corners:{enabled:e.corners.enabled,radiusMultiplier:e.corners.radiusMultiplier}}}function Km(e){return SN({colors:e.colors||gt.colors,typography:{fontId:e.typography?.fontId||gt.typography.fontId},corners:{enabled:e.corners?.enabled??gt.corners.enabled,radiusMultiplier:e.corners?.radiusMultiplier??gt.corners.radiusMultiplier}})}function O4(e){if(!e)return"#";let t=String(e).trim().replace(/[^0-9a-fA-F#]/g,"");if(t.startsWith("#")||(t=`#${t}`),t.length===4){const[,r,n,l]=t;t=`#${r}${r}${n}${n}${l}${l}`}return t.length>7&&(t=t.slice(0,7)),t.toUpperCase()}function E4(){const[e,t]=x.useState("theme"),[r,n]=x.useState({logoType:"text",logoText:"OpenShop",logoImageUrl:"",storeName:"OpenShop",storeDescription:"Your amazing online store",heroImageUrl:"",heroTitle:"Welcome to OpenShop",heroSubtitle:"Discover amazing products at unbeatable prices. Built on Cloudflare for lightning-fast performance.",aboutHeroImageUrl:"",aboutHeroTitle:"About Us",aboutHeroSubtitle:"Learn more about our story and mission",aboutContent:`Welcome to our store! We are passionate about providing high-quality products and exceptional customer service. Our journey began with a simple idea: to make great products accessible to everyone. + */const r4=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],kg=Ze("x",r4);function mn({previewSettings:e,disableNavigation:t}){const[r,n]=x.useState([]),[l,o]=x.useState([]),[c,f]=x.useState({logoType:"text",logoText:"OpenShop",logoImageUrl:""}),[h,m]=x.useState(!1),[p,g]=x.useState(new Set),{itemCount:b,toggleCart:w}=Df(),S=e||c;x.useEffect(()=>{j(),e||A()},[e]);const j=async()=>{try{const[O,_]=await Promise.all([fetch("/api/collections"),fetch("/api/products")]);if(O.ok&&_.ok){const k=await O.json(),M=await _.json();n(k);const P=k.map(z=>({...z,products:M.filter(G=>G.collectionId===z.id)}));o(P)}}catch(O){console.error("Error fetching collections and products:",O)}},A=async()=>{try{const O=await fetch("/api/store-settings");if(O.ok){const _=await O.json();f(_)}}catch(O){console.error("Error fetching store settings:",O)}},E=O=>{const _=new Set(p);_.has(O)?_.delete(O):_.add(O),g(_)},T=({to:O,className:_,children:k,onClick:M})=>t?d.jsx("span",{className:`${_} cursor-default`,onClick:P=>{P.preventDefault(),M&&M(P)},children:k}):d.jsx(gr,{to:O,className:_,onClick:M,children:k});return d.jsxs("nav",{className:"bg-white shadow-sm border-b relative z-50 storefront-nav",children:[d.jsx("div",{className:"max-w-8xl mx-auto px-4 sm:px-6 lg:px-8",children:d.jsxs("div",{className:"flex items-center justify-between h-16",children:[d.jsxs(T,{to:"/",className:"flex-shrink-0",children:[S.logoType==="image"&&S.logoImageUrl?d.jsx("img",{src:S.logoImageUrl,alt:S.storeName||"Store Logo",className:"h-8 max-w-48 object-contain",onError:O=>{O.target.style.display="none",O.target.nextSibling.style.display="block"}}):null,d.jsx("h1",{className:`text-2xl font-bold storefront-heading ${S.logoType==="image"&&S.logoImageUrl?"hidden":"block"}`,children:S.logoText||"OpenShop"})]}),d.jsx("div",{className:"hidden md:flex absolute left-1/2 transform -translate-x-1/2",children:d.jsxs("div",{className:"flex items-baseline space-x-6",children:[d.jsx(T,{to:"/",className:"storefront-heading hover:text-slate-600 px-3 py-2 rounded-md text-sm font-medium transition-colors duration-200",children:"Home"}),l.map(O=>d.jsxs("div",{className:"relative group",children:[d.jsxs(T,{to:`/collections/${O.id}`,className:"storefront-heading hover:text-slate-600 px-3 py-2 rounded-md text-sm font-medium transition-colors duration-200 flex items-center",children:[O.name,O.products.length>0&&d.jsx("svg",{className:"w-4 h-4 ml-1 transition-transform duration-200 group-hover:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),O.products.length>0&&d.jsx("div",{className:"absolute left-0 top-full w-72 bg-white rounded-md rounded-t-none shadow-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 z-[100] pointer-events-none group-hover:pointer-events-auto storefront-surface-inverse storefront-radius",children:d.jsxs("div",{className:"py-2",children:[d.jsxs("div",{className:"px-4 py-2 text-xs font-semibold storefront-subtle uppercase tracking-wide border-b",children:[O.name," Products"]}),d.jsx("div",{className:"max-h-80 overflow-y-auto",children:O.products.map(_=>d.jsx(T,{to:`/products/${_.id}`,className:"block px-4 py-3 hover:bg-slate-50 transition-colors duration-150",children:d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsxs("div",{className:"flex-shrink-0",children:[_.images&&_.images.length>0?d.jsx("img",{src:bt(_.images[0]),alt:_.name,className:"w-10 h-10 object-cover rounded-md",onError:k=>{k.target.style.display="none",k.target.nextSibling.style.display="flex"}}):_.imageUrl?d.jsx("img",{src:bt(_.imageUrl),alt:_.name,className:"w-10 h-10 object-cover rounded-md",onError:k=>{k.target.style.display="none",k.target.nextSibling.style.display="flex"}}):null,d.jsx("div",{className:"w-10 h-10 bg-slate-200 rounded-md flex items-center justify-center",style:{display:_.images&&_.images.length>0||_.imageUrl?"none":"flex"},children:d.jsx("svg",{className:"w-5 h-5 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})})]}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-sm font-medium storefront-heading truncate",children:_.name}),d.jsxs("p",{className:"text-sm storefront-subtle font-semibold",children:["$",_.price]})]})]})},_.id))}),d.jsx("div",{className:"border-t px-4 py-2",children:d.jsxs(T,{to:`/collections/${O.id}`,className:"text-sm storefront-subtle hover:text-slate-700 font-medium",children:["View all ",O.name," →"]})})]})})]},O.id))]})}),d.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[d.jsxs("button",{onClick:t?O=>O.preventDefault():w,className:`relative p-2 storefront-heading hover:text-slate-600 transition-all duration-200 hover:scale-110 ${t?"cursor-default":""}`,children:[d.jsx(uN,{className:"w-6 h-6 transition-transform duration-200"}),b>0&&d.jsx("span",{className:"absolute -top-1 -right-1 bg-slate-600 text-white text-xs font-bold rounded-full h-5 w-5 flex items-center justify-center animate-bounce-in",children:b>99?"99+":b})]}),d.jsx("button",{onClick:()=>m(!h),className:"md:hidden storefront-heading hover:text-slate-600 transition-colors duration-200 p-2",children:h?d.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}):d.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})]})]})}),h&&d.jsx("div",{className:"md:hidden border-t bg-white storefront-surface-inverse",children:d.jsxs("div",{className:"px-2 pt-2 pb-3 space-y-1",children:[d.jsx(T,{to:"/",className:"block px-3 py-2 text-base font-medium storefront-heading hover:text-slate-600 hover:bg-slate-50 rounded-md transition-colors duration-200",onClick:()=>m(!1),children:"Home"}),l.map(O=>d.jsxs("div",{className:"space-y-1",children:[d.jsxs("button",{onClick:()=>E(O.id),className:"flex items-center justify-between w-full px-3 py-2 text-base font-medium storefront-heading hover:text-slate-600 hover:bg-slate-50 rounded-md transition-colors duration-200",children:[d.jsx("span",{children:O.name}),d.jsx("svg",{className:`w-4 h-4 transition-transform duration-200 ${p.has(O.id)?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),O.products.length>0&&p.has(O.id)&&d.jsxs("div",{className:"pl-6 space-y-1",children:[O.products.slice(0,5).map(_=>d.jsx(T,{to:`/products/${_.id}`,className:"block px-3 py-2 text-sm storefront-subtle hover:bg-slate-50 rounded-md transition-colors duration-200",onClick:()=>m(!1),children:d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsx("div",{className:"flex-shrink-0",children:_.images&&_.images.length>0?d.jsx("img",{src:_.images[0],alt:_.name,className:"w-8 h-8 object-cover rounded"}):_.imageUrl?d.jsx("img",{src:_.imageUrl,alt:_.name,className:"w-8 h-8 object-cover rounded"}):d.jsx("div",{className:"w-8 h-8 bg-slate-200 rounded flex items-center justify-center",children:d.jsx("svg",{className:"w-4 h-4 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})})}),d.jsxs("div",{className:"flex-1",children:[d.jsx("p",{className:"font-medium storefront-heading truncate",children:_.name}),d.jsxs("p",{className:"storefront-subtle font-semibold",children:["$",_.price]})]})]})},_.id)),d.jsx(T,{to:`/collections/${O.id}`,className:"block px-3 py-2 text-sm storefront-subtle hover:text-slate-700 font-medium border-t border-slate-200 pt-2 mt-2",onClick:()=>m(!1),children:"View Collection →"}),O.products.length>5&&d.jsxs(T,{to:`/collections/${O.id}`,className:"block px-3 py-2 text-sm storefront-subtle hover:text-slate-700 font-medium",onClick:()=>m(!1),children:["View all ",O.products.length," products →"]})]})]},O.id))]})})]})}function dN({previewSettings:e}){const[t,r]=x.useState({heroImageUrl:"",heroTitle:"Welcome to OpenShop",heroSubtitle:"Discover amazing products at unbeatable prices. Built on Cloudflare for lightning-fast performance."}),n=e||t;return x.useEffect(()=>{if(e)return;let l=!0;async function o(){try{const c=await fetch("/api/store-settings");if(c.ok){const f=await c.json();l&&r(h=>({...h,heroImageUrl:f.heroImageUrl||"",heroTitle:f.heroTitle||h.heroTitle,heroSubtitle:f.heroSubtitle||h.heroSubtitle}))}}catch(c){console.error("Failed to load store settings",c)}}return o(),()=>{l=!1}},[e]),d.jsxs("section",{className:"relative w-full overflow-hidden storefront-hero",children:[n.heroImageUrl?d.jsx("img",{src:bt(n.heroImageUrl),alt:"Hero",className:"w-full h-[90vh] object-cover block"}):d.jsx("div",{className:"w-full min-h-[320px] sm:min-h-[420px] lg:min-h-[560px]",style:{backgroundColor:"#1e293b"}}),d.jsx("div",{className:"absolute inset-0 bg-black/35","aria-hidden":!0}),d.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center px-4 sm:px-6 lg:px-8 py-12 text-center text-white",children:d.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[d.jsx("h1",{className:"text-4xl md:text-6xl font-bold",children:n.heroTitle}),d.jsx("p",{className:"text-xl md:text-2xl max-w-3xl mx-auto",children:n.heroSubtitle}),d.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[d.jsx(Se,{size:"lg",children:"Shop Now"}),d.jsx(Se,{size:"lg",variant:"outline",className:"border-white text-slate-900 bg-white hover:bg-gradient-to-r hover:from-slate-600 hover:to-slate-700 hover:text-white hover:border-transparent transition-all duration-300",asChild:!0,children:d.jsx(gr,{to:"/about",children:"Learn More"})})]})]})})]})}function n4({products:e=[]}){const[t,r]=x.useState(0);x.useEffect(()=>{if(e.length===0)return;const c=setInterval(()=>{r(f=>f===e.length-1?0:f+1)},5e3);return()=>clearInterval(c)},[e.length]);const n=()=>{r(t===0?e.length-1:t-1)},l=()=>{r(t===e.length-1?0:t+1)};if(e.length===0)return d.jsx("div",{className:"relative w-full h-96 rounded-lg flex items-center justify-center storefront-surface-inverse",children:d.jsx("p",{className:"storefront-subtle",children:"No featured products available"})});const o=e[t];return d.jsxs("div",{className:"relative w-full h-96 overflow-hidden storefront-hero storefront-radius-lg",children:[d.jsx("div",{className:"absolute inset-0",onClick:l,children:o.images&&o.images.length>0?d.jsx("img",{src:bt(o.images[0]),alt:o.name,className:"w-full h-full object-cover opacity-50"}):o.imageUrl?d.jsx("img",{src:bt(o.imageUrl),alt:o.name,className:"w-full h-full object-cover opacity-50"}):d.jsx("div",{className:"w-full h-full opacity-50",style:{background:"linear-gradient(135deg, var(--storefront-color-secondary), var(--storefront-color-primary))"}})}),d.jsx("div",{className:"relative z-10 flex items-center justify-center h-full text-center px-8",children:d.jsxs("div",{children:[d.jsx("h2",{className:"text-4xl font-bold mb-4 storefront-heading",children:o.name}),d.jsx("p",{className:"text-lg mb-6 max-w-2xl storefront-subtle",children:o.tagline||o.description}),d.jsx(gr,{to:`/products/${o.id}`,onClick:c=>c.stopPropagation(),children:d.jsxs(Se,{size:"lg",className:"cursor-pointer",children:["Shop Now - $",o.price]})})]})}),d.jsx("button",{type:"button",onClick:n,"aria-label":"Previous product",className:"absolute left-4 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white p-2 rounded-full hover:bg-opacity-75 transition-all z-20 cursor-pointer",children:d.jsx(oN,{className:"w-6 h-6"})}),d.jsx("button",{type:"button",onClick:l,"aria-label":"Next product",className:"absolute right-4 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white p-2 rounded-full hover:bg-opacity-75 transition-all z-20 cursor-pointer",children:d.jsx(sN,{className:"w-6 h-6"})}),d.jsx("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 flex space-x-2 z-20",children:e.map((c,f)=>d.jsx("button",{onClick:()=>r(f),className:`w-3 h-3 rounded-full transition-all cursor-pointer ${f===t?"bg-white":"bg-white bg-opacity-50"}`},f))})]})}const it=x.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:tn("rounded-lg border border-slate-200 bg-white text-slate-950 shadow-sm",e),...t}));it.displayName="Card";const un=x.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:tn("flex flex-col space-y-1.5 p-6",e),...t}));un.displayName="CardHeader";const fn=x.forwardRef(({className:e,...t},r)=>d.jsx("h3",{ref:r,className:tn("text-2xl font-semibold leading-none tracking-tight",e),...t}));fn.displayName="CardTitle";const a4=x.forwardRef(({className:e,...t},r)=>d.jsx("p",{ref:r,className:tn("text-sm text-slate-500",e),...t}));a4.displayName="CardDescription";const ft=x.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:tn("p-6 pt-0",e),...t}));ft.displayName="CardContent";const hN=x.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:tn("flex items-center p-6 pt-0",e),...t}));hN.displayName="CardFooter";var mN="basil",i4=function(t){return t===3?"v3":t},pN="https://js.stripe.com",l4="".concat(pN,"/").concat(mN,"/stripe.js"),o4=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,s4=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;var c4=function(t){return o4.test(t)||s4.test(t)},u4=function(){for(var t=document.querySelectorAll('script[src^="'.concat(pN,'"]')),r=0;r element.");return l.appendChild(n),n},f4=function(t,r){!t||!t._registerWrapper||t._registerWrapper({name:"stripe-js",version:"7.9.0",startTime:r})},os=null,pu=null,vu=null,d4=function(t){return function(r){t(new Error("Failed to load Stripe.js",{cause:r}))}},h4=function(t,r){return function(){window.Stripe?t(window.Stripe):r(new Error("Stripe.js not available"))}},m4=function(t){return os!==null?os:(os=new Promise(function(r,n){if(typeof window>"u"||typeof document>"u"){r(null);return}if(window.Stripe){r(window.Stripe);return}try{var l=u4();if(!(l&&t)){if(!l)l=Nw(t);else if(l&&vu!==null&&pu!==null){var o;l.removeEventListener("load",vu),l.removeEventListener("error",pu),(o=l.parentNode)===null||o===void 0||o.removeChild(l),l=Nw(t)}}vu=h4(r,n),pu=d4(n),l.addEventListener("load",vu),l.addEventListener("error",pu)}catch(c){n(c);return}}),os.catch(function(r){return os=null,Promise.reject(r)}))},p4=function(t,r,n){if(t===null)return null;var l=r[0],o=l.match(/^pk_test/),c=i4(t.version),f=mN;o&&c!==f&&console.warn("Stripe.js@".concat(c," was loaded on the page, but @stripe/stripe-js@").concat("7.9.0"," expected Stripe.js@").concat(f,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var h=t.apply(void 0,r);return f4(h,n),h},ss,vN=!1,gN=function(){return ss||(ss=m4(null).catch(function(t){return ss=null,Promise.reject(t)}),ss)};Promise.resolve().then(function(){return gN()}).catch(function(e){vN||console.warn(e)});var yN=function(){for(var t=arguments.length,r=new Array(t),n=0;n(Hm||(Hm=yN(void 0)),Hm);async function xN(e){try{const t=await v4(),n=await(await fetch("/api/create-checkout-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({priceId:e})})).json();if(n.error)throw new Error(n.error);const l=await t.redirectToCheckout({sessionId:n.sessionId});if(l.error)throw new Error(l.error.message)}catch(t){throw console.error("Error redirecting to checkout:",t),t}}function Mg({product:e,disableNavigation:t}){const[r,n]=x.useState(0),{addItem:l}=Df(),o=(Array.isArray(e.images)?e.images:e.imageUrl?[e.imageUrl]:[]).map(bt),c=o.length>1,f=async()=>{if(!t)try{await xN(e.stripePriceId)}catch(b){console.error("Error initiating checkout:",b),alert("Error starting checkout. Please try again.")}},h=()=>{n(b=>(b+1)%o.length)},m=()=>{n(b=>(b-1+o.length)%o.length)},p=()=>{t||l(e)},g=({to:b,children:w,className:S})=>t?d.jsx("div",{className:S,children:w}):d.jsx(gr,{to:b,className:S,children:w});return d.jsxs(it,{className:"group overflow-hidden hover:shadow-xl transition-shadow duration-300 storefront-card storefront-radius",children:[d.jsx(g,{to:`/products/${e.id}`,className:"block",children:d.jsx("div",{className:"relative aspect-w-16 aspect-h-12 overflow-hidden",style:{backgroundColor:"var(--storefront-color-accent-soft)",borderTopLeftRadius:"var(--storefront-radius-lg)",borderTopRightRadius:"var(--storefront-radius-lg)"},children:o.length>0?d.jsxs(d.Fragment,{children:[d.jsx("img",{src:o[r],alt:e.name,className:"w-full h-48 object-cover",style:{borderTopLeftRadius:"var(--storefront-radius-lg)",borderTopRightRadius:"var(--storefront-radius-lg)"}}),c&&d.jsxs(d.Fragment,{children:[d.jsx("button",{onClick:b=>{b.preventDefault(),m()},className:"absolute left-2 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white p-1 rounded-full hover:bg-opacity-75 transition-all opacity-0 group-hover:opacity-100",children:d.jsx(oN,{className:"w-4 h-4"})}),d.jsx("button",{onClick:b=>{b.preventDefault(),h()},className:"absolute right-2 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-50 text-white p-1 rounded-full hover:bg-opacity-75 transition-all opacity-0 group-hover:opacity-100",children:d.jsx(sN,{className:"w-4 h-4"})}),d.jsx("div",{className:"absolute bottom-2 left-1/2 transform -translate-x-1/2 flex space-x-1",children:o.map((b,w)=>d.jsx("button",{onClick:S=>{S.preventDefault(),n(w)},className:`w-2 h-2 rounded-full transition-all ${w===r?"bg-white":"bg-white bg-opacity-50"}`},w))})]})]}):d.jsx("div",{className:"w-full h-48 flex items-center justify-center",style:{backgroundColor:"var(--storefront-color-accent-soft)"},children:d.jsx("svg",{className:"w-12 h-12 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})})}),d.jsxs(ft,{className:"p-4",children:[d.jsx(g,{to:`/products/${e.id}`,className:"hover:text-slate-600",children:d.jsx("h3",{className:"text-lg font-semibold storefront-heading mb-2 line-clamp-2",children:e.name})}),d.jsx("p",{className:"storefront-subtle text-sm mb-3 line-clamp-2",children:e.tagline||e.description}),d.jsx("div",{className:"flex items-center justify-between",children:d.jsx("span",{className:"text-2xl font-bold storefront-heading",children:Dr(e.price,e.currency)})})]}),d.jsx(hN,{className:"p-4 pt-0",children:d.jsxs("div",{className:"grid grid-cols-2 gap-2 w-full",children:[d.jsxs(Se,{onClick:p,variant:"outline",className:"w-full",disabled:t,children:[d.jsx(uN,{className:"w-4 h-4 mr-2"}),"Add to Cart"]}),d.jsx(Se,{onClick:f,className:"w-full",disabled:!e.stripePriceId||t,children:"Buy Now"})]})})]})}function Mi({previewSettings:e}){const[t,r]=x.useState("contact@example.com"),[n,l]=x.useState(!0);x.useEffect(()=>{if(e){r(e.contactEmail||"contact@example.com"),l(!1);return}o()},[e]);const o=async()=>{try{const c=await fetch("/api/contact-email");if(c.ok){const f=await c.json();r(f.email||"contact@example.com")}else r("contact@example.com")}catch(c){console.error("Error fetching contact email:",c),r("contact@example.com")}finally{l(!1)}};return d.jsx("footer",{className:"storefront-surface border-t border-gray-200",children:d.jsxs("div",{className:"max-w-8xl mx-auto px-4 sm:px-6 lg:px-8 py-6",children:[d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 min-h-32 md:h-24",children:[d.jsxs("div",{className:"flex flex-col justify-center items-center text-center space-y-2 md:col-span-1",children:[d.jsx("h3",{className:"text-lg font-semibold storefront-heading",children:"Get in Touch"}),d.jsx("p",{className:"storefront-subtle text-sm",children:"Have questions about our products or need support? We'd love to hear from you."}),d.jsx("a",{href:`mailto:${t&&t!=="contact@example.com"?t:"contact@example.com"}`,className:"inline-flex items-center px-4 py-2 storefront-button-outline storefront-radius-sm text-sm font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-300",children:n?"Loading...":"Contact Us"})]}),d.jsx("div",{className:"flex flex-col justify-center items-center md:col-span-1",children:d.jsxs("a",{href:"https://github.com/AJFrio/OpenShop",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center px-4 py-2 storefront-button-outline storefront-radius-sm text-sm font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-300",children:[d.jsx("svg",{className:"w-4 h-4 mr-2",fill:"currentColor",viewBox:"0 0 20 20",children:d.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),"Made with OpenShop"]})})]}),d.jsx("div",{className:"mt-6 pt-4 md:mt-3 md:pt-3 border-t border-gray-200",children:d.jsxs("p",{className:"text-center text-sm storefront-subtle",children:["Copyright ",new Date().getFullYear()," OpenShop. All rights reserved."]})})]})})}function g4(){const[e,t]=x.useState([]),[r,n]=x.useState([]),[l,o]=x.useState(null),[c,f]=x.useState(!0);x.useEffect(()=>{h()},[]);const h=async()=>{try{f(!0);const[g,b]=await Promise.all([fetch("/api/products"),fetch("/api/collections")]);if(g.ok){const w=await g.json();t(w)}if(b.ok){const w=await b.json();n(w)}}catch(g){console.error("Error fetching data:",g)}finally{f(!1)}},m=l?e.filter(g=>g.collectionId===l):e,p=e.slice(0,3);return c?d.jsxs("div",{className:"min-h-screen storefront-surface",children:[d.jsx(mn,{}),d.jsx("div",{className:"flex items-center justify-center h-96",children:d.jsxs("div",{className:"text-center",children:[d.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 mx-auto mb-4",style:{borderColor:"var(--storefront-color-primary)",borderBottomColor:"transparent"}}),d.jsx("p",{className:"storefront-subtle",children:"Loading products..."})]})})]}):d.jsxs("div",{className:"min-h-screen storefront-surface",children:[d.jsx(mn,{}),d.jsx(dN,{}),p.length>0&&d.jsxs("section",{className:"max-w-8xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[d.jsx("h2",{className:"text-3xl font-bold storefront-heading mb-8 text-center",children:"Featured Products"}),d.jsx(n4,{products:p})]}),d.jsx("section",{className:"max-w-8xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:d.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[d.jsx(Se,{variant:l===null?"default":"outline",onClick:()=>o(null),children:"All Products"}),r.map(g=>d.jsx(Se,{variant:l===g.id?"default":"outline",onClick:()=>o(g.id),children:g.name},g.id))]})}),d.jsx("section",{className:"max-w-8xl mx-auto px-3 sm:px-4 lg:px-6 pb-16",children:m.length===0?d.jsxs("div",{className:"text-center py-16",children:[d.jsx("div",{className:"storefront-subtle mb-4",children:d.jsx("svg",{className:"w-16 h-16 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}),d.jsx("h3",{className:"text-xl font-semibold storefront-heading mb-2",children:"No products found"}),d.jsx("p",{className:"storefront-subtle mb-6",children:l?"No products in this collection yet.":"No products available at the moment."}),l&&d.jsx(Se,{onClick:()=>o(null),children:"View All Products"})]}):d.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-6",children:m.map(g=>d.jsx(Mg,{product:g},g.id))})}),d.jsx(Mi,{})]})}const Pg="openshop_admin_token";function y4(e){localStorage.setItem(Pg,e);try{window.dispatchEvent(new CustomEvent("openshop-admin-login"))}catch{}}function wN(){return localStorage.getItem(Pg)}function kv(){localStorage.removeItem(Pg);try{window.dispatchEvent(new CustomEvent("openshop-admin-logout"))}catch{}}function b4(){const e=wN();return e!==null&&e.length>0}async function ct(e,t={}){const r=wN();if(!r)throw kv(),new Error("Admin authentication required");const n={"Content-Type":"application/json","X-Admin-Token":r,...t.headers},l=await fetch(e,{...t,headers:n});if(l.status===401)throw kv(),new Error("Admin session expired. Please log in again.");if(l.status===502){const o=await l.json().catch(()=>({}));throw new Error(o.error||"Service temporarily unavailable")}return l}async function x4(e){try{const t=await fetch("/api/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})});if(t.ok){const{token:r}=await t.json();return y4(r),{success:!0}}else return{success:!1,error:(await t.json().catch(()=>({}))).error||"Login failed"}}catch(t){return console.error("Admin login error:",t),{success:!1,error:"Network error"}}}const Ye=x.forwardRef(({className:e,type:t,...r},n)=>d.jsx("input",{type:t,className:tn("flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r}));Ye.displayName="Input";function w4({onLoginSuccess:e}){const[t,r]=x.useState(""),[n,l]=x.useState(!1),[o,c]=x.useState(""),f=async h=>{h.preventDefault(),l(!0),c("");try{const m=await x4(t);m.success?e():c(m.error||"Invalid password. Please try again.")}catch{c("Login failed. Please try again.")}finally{l(!1)}};return d.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:d.jsxs(it,{className:"w-full max-w-md",children:[d.jsx(un,{children:d.jsx(fn,{className:"text-center",children:"Admin Login"})}),d.jsxs(ft,{children:[d.jsxs("form",{onSubmit:f,className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium mb-2",children:"Password"}),d.jsx(Ye,{type:"password",value:t,onChange:h=>r(h.target.value),placeholder:"Enter admin password",required:!0,disabled:n})]}),o&&d.jsx("div",{className:"text-red-600 text-sm",children:o}),d.jsx(Se,{type:"submit",className:"w-full bg-slate-900 text-white hover:bg-gradient-to-r hover:from-gray-600 hover:to-gray-700 transition-all duration-300",disabled:n,children:n?"Logging in...":"Login"})]}),d.jsxs("div",{className:"mt-4 text-center text-sm text-gray-600",children:[d.jsxs("p",{children:["Default password: ",d.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded",children:"admin123"})]}),d.jsx("p",{className:"mt-1",children:"Change this in your environment variables!"})]})]})]})})}const $a=x.forwardRef(({className:e,children:t,...r},n)=>d.jsxs("div",{className:"relative",children:[d.jsx("select",{className:tn("flex h-10 w-full appearance-none rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-slate-950 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r,children:t}),d.jsx(p3,{className:"absolute right-3 top-3 h-4 w-4 opacity-50 pointer-events-none"})]}));$a.displayName="Select";const Dg=x.forwardRef(({className:e,...t},r)=>d.jsx("textarea",{className:tn("flex min-h-[80px] w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...t}));Dg.displayName="Textarea";function Mv({open:e,onClose:t,onPick:r}){const[n,l]=x.useState([]),[o,c]=x.useState(!1),[f,h]=x.useState("");x.useEffect(()=>{e&&m()},[e]);async function m(){try{c(!0),h("");const g=await ct("/api/admin/media",{method:"GET"});if(!g.ok)throw new Error("Failed to load media");const b=await g.json(),w=Array.isArray(b)?[...b].sort((S,j)=>(j.createdAt||0)-(S.createdAt||0)):[];l(w)}catch(g){h(g.message||"Failed to load media")}finally{c(!1)}}function p(g){r?.(g),t?.()}return e?d.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50",onClick:t,children:d.jsxs("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-3xl mx-4 flex flex-col max-h-[80vh] overflow-hidden",onClick:g=>g.stopPropagation(),children:[d.jsx("div",{className:"p-4 border-b flex items-center justify-between flex-shrink-0",children:d.jsx("h3",{className:"text-lg font-semibold",children:"Select existing media"})}),d.jsx("div",{className:"p-4 flex-1 overflow-y-auto",children:o?d.jsx("p",{className:"text-sm text-gray-500",children:"Loading…"}):f?d.jsx("p",{className:"text-sm text-red-600",children:f}):n.length===0?d.jsx("p",{className:"text-sm text-gray-600",children:"No media yet. Add images in the Media tab."}):d.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:n.map(g=>d.jsx("button",{type:"button",className:"aspect-square rounded border overflow-hidden bg-white hover:ring-2 hover:ring-gray-500",title:g.filename||g.url,onClick:()=>p(g.url),children:d.jsx("img",{src:bt(g.url),alt:g.filename||"media",className:"w-full h-full object-cover"})},g.id))})}),d.jsx("div",{className:"p-3 border-t flex justify-end flex-shrink-0",children:d.jsx(Se,{type:"button",variant:"outline",onClick:t,children:"Close"})})]})}):null}function bs({value:e,onChange:t,placeholder:r="Image URL",onPreview:n,onRemove:l,required:o=!1,inputName:c,hideInput:f=!1}){const[h,m]=x.useState(""),p=x.useRef(null),[g,b]=x.useState(!1),w=j=>{const A=S(j.target.value);t(A)},S=j=>{const A=(j||"").trim();if(!A||!(A.includes("drive.google.com")||A.includes("drive.usercontent.google.com")))return j;const T=A.match(/\/file\/d\/([a-zA-Z0-9_-]+)/),O=A.match(/[?&#]id=([a-zA-Z0-9_-]+)/),_=T&&T[1]||O&&O[1]||null,k=_?`https://drive.usercontent.google.com/download?id=${_}&export=view`:A;return k!==A&&(m("Google Drive link detected — converted for reliable preview and delivery."),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>m(""),3e3)),k};return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-2",children:[!f&&d.jsx(Ye,{name:c,type:"url",value:e,onChange:w,placeholder:r,required:o,className:"flex-1"}),d.jsxs(Se,{type:"button",onClick:()=>b(!0),className:"flex items-center gap-1",children:[d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12 5v14"}),d.jsx("path",{d:"M5 12h14"})]}),"Select media"]}),e&&d.jsx("button",{type:"button",className:"w-12 h-12 rounded overflow-hidden border bg-white",title:"Preview",onClick:()=>n&&n(bt(e)),children:d.jsx("img",{src:bt(e),alt:"preview",className:"w-full h-full object-cover"})}),l&&d.jsx(Se,{type:"button",variant:"outline",size:"sm",onClick:l,className:"px-3",children:"×"})]}),h&&d.jsx("p",{className:"text-xs text-gray-700 mt-2",children:h}),d.jsx(Mv,{open:g,onClose:()=>b(!1),onPick:j=>{t(j),b(!1)}})]})}const Lf=x.createContext({open:!1,setOpen:()=>{}});function Uu({open:e,onOpenChange:t,children:r}){const[n,l]=x.useState(!1),o=typeof e=="boolean",c=o?e:n,f=h=>{o&&t&&t(h),o||l(h)};return d.jsx(Lf.Provider,{value:{open:c,setOpen:f},children:r})}function Bu({children:e}){const{open:t,setOpen:r}=x.useContext(Lf);return t?d.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[d.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:()=>r(!1)}),d.jsx("div",{className:"relative bg-white rounded-lg shadow-lg w-full max-w-md mx-4",children:e})]}):null}function Iu({children:e}){return d.jsx("div",{className:"p-6 pb-2",children:e})}function $u({children:e}){return d.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:e})}function qu({children:e}){return d.jsx("p",{className:"mt-2 text-sm text-gray-600",children:e})}function Hu({children:e}){return d.jsx("div",{className:"p-6 pt-2 flex justify-end gap-2",children:e})}function S4({children:e,onClick:t}){const{setOpen:r}=x.useContext(Lf);return d.jsx("button",{type:"button",className:"px-4 py-2 rounded border hover:bg-gray-50",onClick:n=>{t?.(n),r(!1)},children:e})}function Ku({children:e,onClick:t}){const{setOpen:r}=x.useContext(Lf);return d.jsx("button",{type:"button",className:"px-4 py-2 rounded bg-slate-900 text-white hover:bg-gradient-to-r hover:from-slate-600 hover:to-slate-700",onClick:n=>{t?.(n),r(!1)},children:e})}function Pi({checked:e=!1,onCheckedChange:t,className:r,id:n}){return d.jsx("button",{id:n,role:"switch","aria-checked":e,type:"button",onClick:()=>t&&t(!e),className:tn("relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200",e?"bg-purple-600":"bg-gray-300",r),children:d.jsx("span",{"aria-hidden":"true",className:tn("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200",e?"translate-x-5":"translate-x-0")})})}function j4({collection:e,onSave:t,onCancel:r}){const[n,l]=x.useState({id:"",name:"",description:"",heroImage:"",archived:!1}),[o,c]=x.useState(!1),[f,h]=x.useState(null),[m,p]=x.useState(!1),[g,b]=x.useState(""),[w,S]=x.useState(""),[j,A]=x.useState(null),E=o;x.useEffect(()=>{l(e||(k=>({...k,id:js()})))},[e]);const T=k=>{const{name:M,value:P}=k.target,z=M==="heroImage"?O(P):P;l(G=>({...G,[M]:z}))};function O(k){const M=(k||"").trim();if(!M||!(M.includes("drive.google.com")||M.includes("drive.usercontent.google.com")))return k;const z=M.match(/\/file\/d\/([a-zA-Z0-9_-]+)/),G=M.match(/[?&#]id=([a-zA-Z0-9_-]+)/),le=z&&z[1]||G&&G[1]||null,J=le?`https://drive.usercontent.google.com/download?id=${le}&export=view`:M;if(J!==M){S("Google Drive link detected — converted for reliable preview and delivery."),j&&clearTimeout(j);const ae=setTimeout(()=>S(""),3e3);A(ae)}return J}const _=async k=>{k.preventDefault(),c(!0);try{const M=e?`/api/admin/collections/${e.id}`:"/api/admin/collections",z=await ct(M,{method:e?"PUT":"POST",body:JSON.stringify(n)});if(z.ok){const G=await z.json();t(G)}else throw new Error("Failed to save collection")}catch(M){console.error("Error saving collection:",M),b("Error saving collection. Please try again."),p(!0)}finally{c(!1)}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"w-full max-w-4xl mx-auto space-y-6",children:[d.jsxs("div",{className:"sticky top-0 z-20 px-6 py-4 bg-white/95 backdrop-blur border border-gray-200 rounded-lg flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:e?"Edit Collection":"Create New Collection"}),d.jsx("p",{className:"text-sm text-gray-500",children:"Organize products into collections with names, descriptions, and hero imagery."})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Se,{type:"button",variant:"outline",onClick:r,children:"Cancel"}),d.jsx(Se,{type:"submit",form:"collection-form",disabled:E,children:o?"Saving...":e?"Update Collection":"Create Collection"})]})]}),d.jsx(it,{className:"w-full",children:d.jsx(ft,{className:"p-6",children:d.jsxs("form",{id:"collection-form",onSubmit:_,className:"space-y-6",children:[d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium mb-2",children:"Collection Name *"}),d.jsx(Ye,{name:"name",value:n.name,onChange:T,placeholder:"Enter collection name",required:!0})]}),w&&d.jsx("p",{className:"text-xs text-gray-700 mt-2",children:w}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Pi,{id:"collection-archived",checked:!!n.archived,onCheckedChange:k=>l(M=>({...M,archived:k}))}),d.jsx("label",{htmlFor:"collection-archived",className:"text-sm text-gray-700 select-none",children:"Archived (hide from storefront)"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium mb-2",children:"Description"}),d.jsx(Dg,{name:"description",value:n.description,onChange:T,placeholder:"Enter collection description",rows:3})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium mb-2",children:"Hero Banner Image"}),d.jsx(bs,{value:n.heroImage,onChange:k=>l(M=>({...M,heroImage:k})),placeholder:"https://example.com/hero-banner.jpg",onPreview:k=>h(k),hideInput:!0}),d.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"This image will be displayed as a banner on the collection page"})]})]})})})]}),f&&d.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50",onClick:()=>h(null),children:d.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-3xl w-full mx-4 relative max-h-[90vh] overflow-auto",onClick:k=>k.stopPropagation(),children:[d.jsx("button",{type:"button",className:"absolute top-2 right-2 px-2 py-1 rounded border bg-white/90 hover:bg-white",onClick:()=>h(null),"aria-label":"Close",children:"×"}),d.jsx("img",{src:f,alt:"preview",className:"w-full h-auto max-h-[80vh] object-contain rounded"}),d.jsx("div",{className:"p-3 border-t text-center",children:d.jsx("a",{href:f,target:"_blank",rel:"noreferrer",className:"text-sm text-gray-600 hover:text-gray-700",children:"Open original"})})]})}),d.jsx(Uu,{open:m,onOpenChange:p,children:d.jsxs(Bu,{children:[d.jsxs(Iu,{children:[d.jsx($u,{children:"Something went wrong"}),d.jsx(qu,{children:g})]}),d.jsx(Hu,{children:d.jsx(Ku,{children:"OK"})})]})})]})}const A4=[{id:"mock-1",name:"Premium Headphones",tagline:"High-fidelity wireless audio",description:"High-fidelity wireless headphones with noise cancellation.",price:29900,currency:"USD",imageUrl:"https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=500&q=80",stripePriceId:"price_mock"},{id:"mock-2",name:"Ergonomic Chair",tagline:"Comfort for your workspace",description:"Designed for comfort and productivity during long work sessions.",price:45e3,currency:"USD",imageUrl:"https://images.unsplash.com/photo-1592078615290-033ee584e267?w=500&q=80",stripePriceId:"price_mock"},{id:"mock-3",name:"Mechanical Keyboard",tagline:"Tactile typing experience",description:"Tactile switches and customizable RGB lighting.",price:12e3,currency:"USD",imageUrl:"https://images.unsplash.com/photo-1587829741301-dc798b91a91e?w=500&q=80",stripePriceId:"price_mock"}],N4=[{title:"Brand Colors",description:"Primary palette for calls to action, highlights, and text accents.",fields:[{key:"primary",label:"Primary Color"},{key:"secondary",label:"Secondary Color"},{key:"accent",label:"Accent Color"},{key:"text",label:"Text Color"}]},{title:"Surface Colors",description:"Backgrounds that shape the storefront canvas and product cards.",fields:[{key:"background",label:"Page Background"},{key:"card",label:"Product Card Background"}]}];function SN(e=gt){return{colors:{primary:e.colors.primary,secondary:e.colors.secondary,accent:e.colors.accent,text:e.colors.text,background:e.colors&&e.colors.background||gt.colors.background,card:e.colors&&e.colors.card||gt.colors.card},typography:{fontId:e.typography.fontId},corners:{enabled:e.corners.enabled,radiusMultiplier:e.corners.radiusMultiplier}}}function Km(e){return SN({colors:e.colors||gt.colors,typography:{fontId:e.typography?.fontId||gt.typography.fontId},corners:{enabled:e.corners?.enabled??gt.corners.enabled,radiusMultiplier:e.corners?.radiusMultiplier??gt.corners.radiusMultiplier}})}function O4(e){if(!e)return"#";let t=String(e).trim().replace(/[^0-9a-fA-F#]/g,"");if(t.startsWith("#")||(t=`#${t}`),t.length===4){const[,r,n,l]=t;t=`#${r}${r}${n}${n}${l}${l}`}return t.length>7&&(t=t.slice(0,7)),t.toUpperCase()}function E4(){const[e,t]=x.useState("theme"),[r,n]=x.useState({logoType:"text",logoText:"OpenShop",logoImageUrl:"",storeName:"OpenShop",storeDescription:"Your amazing online store",heroImageUrl:"",heroTitle:"Welcome to OpenShop",heroSubtitle:"Discover amazing products at unbeatable prices. Built on Cloudflare for lightning-fast performance.",aboutHeroImageUrl:"",aboutHeroTitle:"About Us",aboutHeroSubtitle:"Learn more about our story and mission",aboutContent:`Welcome to our store! We are passionate about providing high-quality products and exceptional customer service. Our journey began with a simple idea: to make great products accessible to everyone. We believe in quality, sustainability, and building lasting relationships with our customers. Every product in our catalog is carefully selected to meet our high standards. diff --git a/dist/index.html b/dist/index.html index c9f7397..c954750 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ OpenShop - + diff --git a/dist/worker.bundle.js b/dist/worker.bundle.js index ed18fc7..50f6eee 100644 --- a/dist/worker.bundle.js +++ b/dist/worker.bundle.js @@ -1,13686 +1,16 @@ -// Worker Bundle - Built 2026-02-02T18:08:02Z +// Worker Bundle - Built 2026-02-04T23:03:04.992Z // Version: 0.0.0 -// Built with wrangler (nodejs_compat enabled, node: imports resolved) -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); -var __esm = (fn, res) => function __init() { - return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; -}; -var __commonJS = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; -var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); -}; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; -}; -var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, - mod -)); - -// node_modules/unenv/dist/runtime/_internal/utils.mjs -// @__NO_SIDE_EFFECTS__ -function createNotImplementedError(name) { - return new Error(`[unenv] ${name} is not implemented yet!`); -} -// @__NO_SIDE_EFFECTS__ -function notImplemented(name) { - const fn = /* @__PURE__ */ __name(() => { - throw /* @__PURE__ */ createNotImplementedError(name); - }, "fn"); - return Object.assign(fn, { __unenv__: true }); -} -// @__NO_SIDE_EFFECTS__ -function notImplementedClass(name) { - return class { - __unenv__ = true; - constructor() { - throw new Error(`[unenv] ${name} is not implemented yet!`); - } - }; -} -var init_utils = __esm({ - "node_modules/unenv/dist/runtime/_internal/utils.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - __name(createNotImplementedError, "createNotImplementedError"); - __name(notImplemented, "notImplemented"); - __name(notImplementedClass, "notImplementedClass"); - } -}); - -// node_modules/unenv/dist/runtime/node/internal/perf_hooks/performance.mjs -var _timeOrigin, _performanceNow, nodeTiming, PerformanceEntry, PerformanceMark, PerformanceMeasure, PerformanceResourceTiming, PerformanceObserverEntryList, Performance, PerformanceObserver, performance; -var init_performance = __esm({ - "node_modules/unenv/dist/runtime/node/internal/perf_hooks/performance.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - init_utils(); - _timeOrigin = globalThis.performance?.timeOrigin ?? Date.now(); - _performanceNow = globalThis.performance?.now ? globalThis.performance.now.bind(globalThis.performance) : () => Date.now() - _timeOrigin; - nodeTiming = { - name: "node", - entryType: "node", - startTime: 0, - duration: 0, - nodeStart: 0, - v8Start: 0, - bootstrapComplete: 0, - environment: 0, - loopStart: 0, - loopExit: 0, - idleTime: 0, - uvMetricsInfo: { - loopCount: 0, - events: 0, - eventsWaiting: 0 - }, - detail: void 0, - toJSON() { - return this; - } - }; - PerformanceEntry = class { - static { - __name(this, "PerformanceEntry"); - } - __unenv__ = true; - detail; - entryType = "event"; - name; - startTime; - constructor(name, options) { - this.name = name; - this.startTime = options?.startTime || _performanceNow(); - this.detail = options?.detail; - } - get duration() { - return _performanceNow() - this.startTime; - } - toJSON() { - return { - name: this.name, - entryType: this.entryType, - startTime: this.startTime, - duration: this.duration, - detail: this.detail - }; - } - }; - PerformanceMark = class PerformanceMark2 extends PerformanceEntry { - static { - __name(this, "PerformanceMark"); - } - entryType = "mark"; - constructor() { - super(...arguments); - } - get duration() { - return 0; - } - }; - PerformanceMeasure = class extends PerformanceEntry { - static { - __name(this, "PerformanceMeasure"); - } - entryType = "measure"; - }; - PerformanceResourceTiming = class extends PerformanceEntry { - static { - __name(this, "PerformanceResourceTiming"); - } - entryType = "resource"; - serverTiming = []; - connectEnd = 0; - connectStart = 0; - decodedBodySize = 0; - domainLookupEnd = 0; - domainLookupStart = 0; - encodedBodySize = 0; - fetchStart = 0; - initiatorType = ""; - name = ""; - nextHopProtocol = ""; - redirectEnd = 0; - redirectStart = 0; - requestStart = 0; - responseEnd = 0; - responseStart = 0; - secureConnectionStart = 0; - startTime = 0; - transferSize = 0; - workerStart = 0; - responseStatus = 0; - }; - PerformanceObserverEntryList = class { - static { - __name(this, "PerformanceObserverEntryList"); - } - __unenv__ = true; - getEntries() { - return []; - } - getEntriesByName(_name, _type) { - return []; - } - getEntriesByType(type) { - return []; - } - }; - Performance = class { - static { - __name(this, "Performance"); - } - __unenv__ = true; - timeOrigin = _timeOrigin; - eventCounts = /* @__PURE__ */ new Map(); - _entries = []; - _resourceTimingBufferSize = 0; - navigation = void 0; - timing = void 0; - timerify(_fn, _options) { - throw createNotImplementedError("Performance.timerify"); - } - get nodeTiming() { - return nodeTiming; - } - eventLoopUtilization() { - return {}; - } - markResourceTiming() { - return new PerformanceResourceTiming(""); - } - onresourcetimingbufferfull = null; - now() { - if (this.timeOrigin === _timeOrigin) { - return _performanceNow(); - } - return Date.now() - this.timeOrigin; - } - clearMarks(markName) { - this._entries = markName ? this._entries.filter((e) => e.name !== markName) : this._entries.filter((e) => e.entryType !== "mark"); - } - clearMeasures(measureName) { - this._entries = measureName ? this._entries.filter((e) => e.name !== measureName) : this._entries.filter((e) => e.entryType !== "measure"); - } - clearResourceTimings() { - this._entries = this._entries.filter((e) => e.entryType !== "resource" || e.entryType !== "navigation"); - } - getEntries() { - return this._entries; - } - getEntriesByName(name, type) { - return this._entries.filter((e) => e.name === name && (!type || e.entryType === type)); - } - getEntriesByType(type) { - return this._entries.filter((e) => e.entryType === type); - } - mark(name, options) { - const entry = new PerformanceMark(name, options); - this._entries.push(entry); - return entry; - } - measure(measureName, startOrMeasureOptions, endMark) { - let start; - let end; - if (typeof startOrMeasureOptions === "string") { - start = this.getEntriesByName(startOrMeasureOptions, "mark")[0]?.startTime; - end = this.getEntriesByName(endMark, "mark")[0]?.startTime; - } else { - start = Number.parseFloat(startOrMeasureOptions?.start) || this.now(); - end = Number.parseFloat(startOrMeasureOptions?.end) || this.now(); - } - const entry = new PerformanceMeasure(measureName, { - startTime: start, - detail: { - start, - end - } - }); - this._entries.push(entry); - return entry; - } - setResourceTimingBufferSize(maxSize) { - this._resourceTimingBufferSize = maxSize; - } - addEventListener(type, listener, options) { - throw createNotImplementedError("Performance.addEventListener"); - } - removeEventListener(type, listener, options) { - throw createNotImplementedError("Performance.removeEventListener"); - } - dispatchEvent(event) { - throw createNotImplementedError("Performance.dispatchEvent"); - } - toJSON() { - return this; - } - }; - PerformanceObserver = class { - static { - __name(this, "PerformanceObserver"); - } - __unenv__ = true; - static supportedEntryTypes = []; - _callback = null; - constructor(callback) { - this._callback = callback; - } - takeRecords() { - return []; - } - disconnect() { - throw createNotImplementedError("PerformanceObserver.disconnect"); - } - observe(options) { - throw createNotImplementedError("PerformanceObserver.observe"); - } - bind(fn) { - return fn; - } - runInAsyncScope(fn, thisArg, ...args) { - return fn.call(thisArg, ...args); - } - asyncId() { - return 0; - } - triggerAsyncId() { - return 0; - } - emitDestroy() { - return this; - } - }; - performance = globalThis.performance && "addEventListener" in globalThis.performance ? globalThis.performance : new Performance(); - } -}); - -// node_modules/unenv/dist/runtime/node/perf_hooks.mjs -var init_perf_hooks = __esm({ - "node_modules/unenv/dist/runtime/node/perf_hooks.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - init_performance(); - } -}); - -// node_modules/@cloudflare/unenv-preset/dist/runtime/polyfill/performance.mjs -var init_performance2 = __esm({ - "node_modules/@cloudflare/unenv-preset/dist/runtime/polyfill/performance.mjs"() { - init_perf_hooks(); - globalThis.performance = performance; - globalThis.Performance = Performance; - globalThis.PerformanceEntry = PerformanceEntry; - globalThis.PerformanceMark = PerformanceMark; - globalThis.PerformanceMeasure = PerformanceMeasure; - globalThis.PerformanceObserver = PerformanceObserver; - globalThis.PerformanceObserverEntryList = PerformanceObserverEntryList; - globalThis.PerformanceResourceTiming = PerformanceResourceTiming; - } -}); - -// node_modules/unenv/dist/runtime/mock/noop.mjs -var noop_default; -var init_noop = __esm({ - "node_modules/unenv/dist/runtime/mock/noop.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - noop_default = Object.assign(() => { - }, { __unenv__: true }); - } -}); - -// node_modules/unenv/dist/runtime/node/console.mjs -// node:stream polyfill - Writable class for unenv console polyfill -var Writable = class { - constructor() {} - write() { return true; } - end() { return this; } - on() { return this; } - once() { return this; } - emit() { return false; } - removeListener() { return this; } -}; -var _console, _ignoreErrors, _stderr, _stdout, log, info, trace, debug, table, error, warn, createTask, clear, count, countReset, dir, dirxml, group, groupEnd, groupCollapsed, profile, profileEnd, time, timeEnd, timeLog, timeStamp, Console, _times, _stdoutErrorHandler, _stderrErrorHandler; -var init_console = __esm({ - "node_modules/unenv/dist/runtime/node/console.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - init_noop(); - init_utils(); - _console = globalThis.console; - _ignoreErrors = true; - _stderr = new Writable(); - _stdout = new Writable(); - log = _console?.log ?? noop_default; - info = _console?.info ?? log; - trace = _console?.trace ?? info; - debug = _console?.debug ?? log; - table = _console?.table ?? log; - error = _console?.error ?? log; - warn = _console?.warn ?? error; - createTask = _console?.createTask ?? /* @__PURE__ */ notImplemented("console.createTask"); - clear = _console?.clear ?? noop_default; - count = _console?.count ?? noop_default; - countReset = _console?.countReset ?? noop_default; - dir = _console?.dir ?? noop_default; - dirxml = _console?.dirxml ?? noop_default; - group = _console?.group ?? noop_default; - groupEnd = _console?.groupEnd ?? noop_default; - groupCollapsed = _console?.groupCollapsed ?? noop_default; - profile = _console?.profile ?? noop_default; - profileEnd = _console?.profileEnd ?? noop_default; - time = _console?.time ?? noop_default; - timeEnd = _console?.timeEnd ?? noop_default; - timeLog = _console?.timeLog ?? noop_default; - timeStamp = _console?.timeStamp ?? noop_default; - Console = _console?.Console ?? /* @__PURE__ */ notImplementedClass("console.Console"); - _times = /* @__PURE__ */ new Map(); - _stdoutErrorHandler = noop_default; - _stderrErrorHandler = noop_default; - } -}); - -// node_modules/@cloudflare/unenv-preset/dist/runtime/node/console.mjs -var workerdConsole, assert, clear2, context, count2, countReset2, createTask2, debug2, dir2, dirxml2, error2, group2, groupCollapsed2, groupEnd2, info2, log2, profile2, profileEnd2, table2, time2, timeEnd2, timeLog2, timeStamp2, trace2, warn2, console_default; -var init_console2 = __esm({ - "node_modules/@cloudflare/unenv-preset/dist/runtime/node/console.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - init_console(); - workerdConsole = globalThis["console"]; - ({ - assert, - clear: clear2, - context: ( - // @ts-expect-error undocumented public API - context - ), - count: count2, - countReset: countReset2, - createTask: ( - // @ts-expect-error undocumented public API - createTask2 - ), - debug: debug2, - dir: dir2, - dirxml: dirxml2, - error: error2, - group: group2, - groupCollapsed: groupCollapsed2, - groupEnd: groupEnd2, - info: info2, - log: log2, - profile: profile2, - profileEnd: profileEnd2, - table: table2, - time: time2, - timeEnd: timeEnd2, - timeLog: timeLog2, - timeStamp: timeStamp2, - trace: trace2, - warn: warn2 - } = workerdConsole); - Object.assign(workerdConsole, { - Console, - _ignoreErrors, - _stderr, - _stderrErrorHandler, - _stdout, - _stdoutErrorHandler, - _times - }); - console_default = workerdConsole; - } -}); - -// node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-console -var init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console = __esm({ - "node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-console"() { - init_console2(); - globalThis.console = console_default; - } -}); - -// node_modules/unenv/dist/runtime/node/internal/process/hrtime.mjs -var hrtime; -var init_hrtime = __esm({ - "node_modules/unenv/dist/runtime/node/internal/process/hrtime.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - hrtime = /* @__PURE__ */ Object.assign(/* @__PURE__ */ __name(function hrtime2(startTime) { - const now = Date.now(); - const seconds = Math.trunc(now / 1e3); - const nanos = now % 1e3 * 1e6; - if (startTime) { - let diffSeconds = seconds - startTime[0]; - let diffNanos = nanos - startTime[0]; - if (diffNanos < 0) { - diffSeconds = diffSeconds - 1; - diffNanos = 1e9 + diffNanos; - } - return [diffSeconds, diffNanos]; - } - return [seconds, nanos]; - }, "hrtime"), { bigint: /* @__PURE__ */ __name(function bigint() { - return BigInt(Date.now() * 1e6); - }, "bigint") }); - } -}); - -// node_modules/unenv/dist/runtime/node/internal/tty/read-stream.mjs -var ReadStream; -var init_read_stream = __esm({ - "node_modules/unenv/dist/runtime/node/internal/tty/read-stream.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - ReadStream = class { - static { - __name(this, "ReadStream"); - } - fd; - isRaw = false; - isTTY = false; - constructor(fd) { - this.fd = fd; - } - setRawMode(mode) { - this.isRaw = mode; - return this; - } - }; - } -}); - -// node_modules/unenv/dist/runtime/node/internal/tty/write-stream.mjs -var WriteStream; -var init_write_stream = __esm({ - "node_modules/unenv/dist/runtime/node/internal/tty/write-stream.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - WriteStream = class { - static { - __name(this, "WriteStream"); - } - fd; - columns = 80; - rows = 24; - isTTY = false; - constructor(fd) { - this.fd = fd; - } - clearLine(dir3, callback) { - callback && callback(); - return false; - } - clearScreenDown(callback) { - callback && callback(); - return false; - } - cursorTo(x, y, callback) { - callback && typeof callback === "function" && callback(); - return false; - } - moveCursor(dx, dy, callback) { - callback && callback(); - return false; - } - getColorDepth(env2) { - return 1; - } - hasColors(count3, env2) { - return false; - } - getWindowSize() { - return [this.columns, this.rows]; - } - write(str, encoding, cb) { - if (str instanceof Uint8Array) { - str = new TextDecoder().decode(str); - } - try { - console.log(str); - } catch { - } - cb && typeof cb === "function" && cb(); - return false; - } - }; - } -}); - -// node_modules/unenv/dist/runtime/node/tty.mjs -var init_tty = __esm({ - "node_modules/unenv/dist/runtime/node/tty.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - init_read_stream(); - init_write_stream(); - } -}); - -// node_modules/unenv/dist/runtime/node/internal/process/node-version.mjs -var NODE_VERSION; -var init_node_version = __esm({ - "node_modules/unenv/dist/runtime/node/internal/process/node-version.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - NODE_VERSION = "22.14.0"; - } -}); - -// node_modules/unenv/dist/runtime/node/internal/process/process.mjs -// node:events polyfill - EventEmitter class for unenv -var EventEmitter = class { - constructor() {} - on() { return this; } - once() { return this; } - emit() { return false; } - removeListener() { return this; } - addListener() { return this; } -}; -var Process; -var init_process = __esm({ - "node_modules/unenv/dist/runtime/node/internal/process/process.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - init_tty(); - init_utils(); - init_node_version(); - Process = class _Process extends EventEmitter { - static { - __name(this, "Process"); - } - env; - hrtime; - nextTick; - constructor(impl) { - super(); - this.env = impl.env; - this.hrtime = impl.hrtime; - this.nextTick = impl.nextTick; - for (const prop of [...Object.getOwnPropertyNames(_Process.prototype), ...Object.getOwnPropertyNames(EventEmitter.prototype)]) { - const value = this[prop]; - if (typeof value === "function") { - this[prop] = value.bind(this); - } - } - } - // --- event emitter --- - emitWarning(warning, type, code) { - console.warn(`${code ? `[${code}] ` : ""}${type ? `${type}: ` : ""}${warning}`); - } - emit(...args) { - return super.emit(...args); - } - listeners(eventName) { - return super.listeners(eventName); - } - // --- stdio (lazy initializers) --- - #stdin; - #stdout; - #stderr; - get stdin() { - return this.#stdin ??= new ReadStream(0); - } - get stdout() { - return this.#stdout ??= new WriteStream(1); - } - get stderr() { - return this.#stderr ??= new WriteStream(2); - } - // --- cwd --- - #cwd = "/"; - chdir(cwd2) { - this.#cwd = cwd2; - } - cwd() { - return this.#cwd; - } - // --- dummy props and getters --- - arch = ""; - platform = ""; - argv = []; - argv0 = ""; - execArgv = []; - execPath = ""; - title = ""; - pid = 200; - ppid = 100; - get version() { - return `v${NODE_VERSION}`; - } - get versions() { - return { node: NODE_VERSION }; - } - get allowedNodeEnvironmentFlags() { - return /* @__PURE__ */ new Set(); - } - get sourceMapsEnabled() { - return false; - } - get debugPort() { - return 0; - } - get throwDeprecation() { - return false; - } - get traceDeprecation() { - return false; - } - get features() { - return {}; - } - get release() { - return {}; - } - get connected() { - return false; - } - get config() { - return {}; - } - get moduleLoadList() { - return []; - } - constrainedMemory() { - return 0; - } - availableMemory() { - return 0; - } - uptime() { - return 0; - } - resourceUsage() { - return {}; - } - // --- noop methods --- - ref() { - } - unref() { - } - // --- unimplemented methods --- - umask() { - throw createNotImplementedError("process.umask"); - } - getBuiltinModule() { - return void 0; - } - getActiveResourcesInfo() { - throw createNotImplementedError("process.getActiveResourcesInfo"); - } - exit() { - throw createNotImplementedError("process.exit"); - } - reallyExit() { - throw createNotImplementedError("process.reallyExit"); - } - kill() { - throw createNotImplementedError("process.kill"); - } - abort() { - throw createNotImplementedError("process.abort"); - } - dlopen() { - throw createNotImplementedError("process.dlopen"); - } - setSourceMapsEnabled() { - throw createNotImplementedError("process.setSourceMapsEnabled"); - } - loadEnvFile() { - throw createNotImplementedError("process.loadEnvFile"); - } - disconnect() { - throw createNotImplementedError("process.disconnect"); - } - cpuUsage() { - throw createNotImplementedError("process.cpuUsage"); - } - setUncaughtExceptionCaptureCallback() { - throw createNotImplementedError("process.setUncaughtExceptionCaptureCallback"); - } - hasUncaughtExceptionCaptureCallback() { - throw createNotImplementedError("process.hasUncaughtExceptionCaptureCallback"); - } - initgroups() { - throw createNotImplementedError("process.initgroups"); - } - openStdin() { - throw createNotImplementedError("process.openStdin"); - } - assert() { - throw createNotImplementedError("process.assert"); - } - binding() { - throw createNotImplementedError("process.binding"); - } - // --- attached interfaces --- - permission = { has: /* @__PURE__ */ notImplemented("process.permission.has") }; - report = { - directory: "", - filename: "", - signal: "SIGUSR2", - compact: false, - reportOnFatalError: false, - reportOnSignal: false, - reportOnUncaughtException: false, - getReport: /* @__PURE__ */ notImplemented("process.report.getReport"), - writeReport: /* @__PURE__ */ notImplemented("process.report.writeReport") - }; - finalization = { - register: /* @__PURE__ */ notImplemented("process.finalization.register"), - unregister: /* @__PURE__ */ notImplemented("process.finalization.unregister"), - registerBeforeExit: /* @__PURE__ */ notImplemented("process.finalization.registerBeforeExit") - }; - memoryUsage = Object.assign(() => ({ - arrayBuffers: 0, - rss: 0, - external: 0, - heapTotal: 0, - heapUsed: 0 - }), { rss: /* @__PURE__ */ __name(() => 0, "rss") }); - // --- undefined props --- - mainModule = void 0; - domain = void 0; - // optional - send = void 0; - exitCode = void 0; - channel = void 0; - getegid = void 0; - geteuid = void 0; - getgid = void 0; - getgroups = void 0; - getuid = void 0; - setegid = void 0; - seteuid = void 0; - setgid = void 0; - setgroups = void 0; - setuid = void 0; - // internals - _events = void 0; - _eventsCount = void 0; - _exiting = void 0; - _maxListeners = void 0; - _debugEnd = void 0; - _debugProcess = void 0; - _fatalException = void 0; - _getActiveHandles = void 0; - _getActiveRequests = void 0; - _kill = void 0; - _preload_modules = void 0; - _rawDebug = void 0; - _startProfilerIdleNotifier = void 0; - _stopProfilerIdleNotifier = void 0; - _tickCallback = void 0; - _disconnect = void 0; - _handleQueue = void 0; - _pendingMessage = void 0; - _channel = void 0; - _send = void 0; - _linkedBinding = void 0; - }; - } -}); - -// node_modules/@cloudflare/unenv-preset/dist/runtime/node/process.mjs -var globalProcess, getBuiltinModule, workerdProcess, isWorkerdProcessV2, unenvProcess, exit, features, platform, env, hrtime3, nextTick, _channel, _disconnect, _events, _eventsCount, _handleQueue, _maxListeners, _pendingMessage, _send, assert2, disconnect, mainModule, _debugEnd, _debugProcess, _exiting, _fatalException, _getActiveHandles, _getActiveRequests, _kill, _linkedBinding, _preload_modules, _rawDebug, _startProfilerIdleNotifier, _stopProfilerIdleNotifier, _tickCallback, abort, addListener, allowedNodeEnvironmentFlags, arch, argv, argv0, availableMemory, binding, channel, chdir, config, connected, constrainedMemory, cpuUsage, cwd, debugPort, dlopen, domain, emit, emitWarning, eventNames, execArgv, execPath, exitCode, finalization, getActiveResourcesInfo, getegid, geteuid, getgid, getgroups, getMaxListeners, getuid, hasUncaughtExceptionCaptureCallback, initgroups, kill, listenerCount, listeners, loadEnvFile, memoryUsage, moduleLoadList, off, on, once, openStdin, permission, pid, ppid, prependListener, prependOnceListener, rawListeners, reallyExit, ref, release, removeAllListeners, removeListener, report, resourceUsage, send, setegid, seteuid, setgid, setgroups, setMaxListeners, setSourceMapsEnabled, setuid, setUncaughtExceptionCaptureCallback, sourceMapsEnabled, stderr, stdin, stdout, throwDeprecation, title, traceDeprecation, umask, unref, uptime, version, versions, _process, process_default; -var init_process2 = __esm({ - "node_modules/@cloudflare/unenv-preset/dist/runtime/node/process.mjs"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - init_hrtime(); - init_process(); - globalProcess = globalThis["process"]; - getBuiltinModule = globalProcess.getBuiltinModule; - workerdProcess = getBuiltinModule("node:process"); - isWorkerdProcessV2 = globalThis.Cloudflare.compatibilityFlags.enable_nodejs_process_v2; - unenvProcess = new Process({ - env: globalProcess.env, - // `hrtime` is only available from workerd process v2 - hrtime: isWorkerdProcessV2 ? workerdProcess.hrtime : hrtime, - // `nextTick` is available from workerd process v1 - nextTick: workerdProcess.nextTick - }); - ({ exit, features, platform } = workerdProcess); - ({ - env: ( - // Always implemented by workerd - env - ), - hrtime: ( - // Only implemented in workerd v2 - hrtime3 - ), - nextTick: ( - // Always implemented by workerd - nextTick - ) - } = unenvProcess); - ({ - _channel, - _disconnect, - _events, - _eventsCount, - _handleQueue, - _maxListeners, - _pendingMessage, - _send, - assert: assert2, - disconnect, - mainModule - } = unenvProcess); - ({ - _debugEnd: ( - // @ts-expect-error `_debugEnd` is missing typings - _debugEnd - ), - _debugProcess: ( - // @ts-expect-error `_debugProcess` is missing typings - _debugProcess - ), - _exiting: ( - // @ts-expect-error `_exiting` is missing typings - _exiting - ), - _fatalException: ( - // @ts-expect-error `_fatalException` is missing typings - _fatalException - ), - _getActiveHandles: ( - // @ts-expect-error `_getActiveHandles` is missing typings - _getActiveHandles - ), - _getActiveRequests: ( - // @ts-expect-error `_getActiveRequests` is missing typings - _getActiveRequests - ), - _kill: ( - // @ts-expect-error `_kill` is missing typings - _kill - ), - _linkedBinding: ( - // @ts-expect-error `_linkedBinding` is missing typings - _linkedBinding - ), - _preload_modules: ( - // @ts-expect-error `_preload_modules` is missing typings - _preload_modules - ), - _rawDebug: ( - // @ts-expect-error `_rawDebug` is missing typings - _rawDebug - ), - _startProfilerIdleNotifier: ( - // @ts-expect-error `_startProfilerIdleNotifier` is missing typings - _startProfilerIdleNotifier - ), - _stopProfilerIdleNotifier: ( - // @ts-expect-error `_stopProfilerIdleNotifier` is missing typings - _stopProfilerIdleNotifier - ), - _tickCallback: ( - // @ts-expect-error `_tickCallback` is missing typings - _tickCallback - ), - abort, - addListener, - allowedNodeEnvironmentFlags, - arch, - argv, - argv0, - availableMemory, - binding: ( - // @ts-expect-error `binding` is missing typings - binding - ), - channel, - chdir, - config, - connected, - constrainedMemory, - cpuUsage, - cwd, - debugPort, - dlopen, - domain: ( - // @ts-expect-error `domain` is missing typings - domain - ), - emit, - emitWarning, - eventNames, - execArgv, - execPath, - exitCode, - finalization, - getActiveResourcesInfo, - getegid, - geteuid, - getgid, - getgroups, - getMaxListeners, - getuid, - hasUncaughtExceptionCaptureCallback, - initgroups: ( - // @ts-expect-error `initgroups` is missing typings - initgroups - ), - kill, - listenerCount, - listeners, - loadEnvFile, - memoryUsage, - moduleLoadList: ( - // @ts-expect-error `moduleLoadList` is missing typings - moduleLoadList - ), - off, - on, - once, - openStdin: ( - // @ts-expect-error `openStdin` is missing typings - openStdin - ), - permission, - pid, - ppid, - prependListener, - prependOnceListener, - rawListeners, - reallyExit: ( - // @ts-expect-error `reallyExit` is missing typings - reallyExit - ), - ref, - release, - removeAllListeners, - removeListener, - report, - resourceUsage, - send, - setegid, - seteuid, - setgid, - setgroups, - setMaxListeners, - setSourceMapsEnabled, - setuid, - setUncaughtExceptionCaptureCallback, - sourceMapsEnabled, - stderr, - stdin, - stdout, - throwDeprecation, - title, - traceDeprecation, - umask, - unref, - uptime, - version, - versions - } = isWorkerdProcessV2 ? workerdProcess : unenvProcess); - _process = { - abort, - addListener, - allowedNodeEnvironmentFlags, - hasUncaughtExceptionCaptureCallback, - setUncaughtExceptionCaptureCallback, - loadEnvFile, - sourceMapsEnabled, - arch, - argv, - argv0, - chdir, - config, - connected, - constrainedMemory, - availableMemory, - cpuUsage, - cwd, - debugPort, - dlopen, - disconnect, - emit, - emitWarning, - env, - eventNames, - execArgv, - execPath, - exit, - finalization, - features, - getBuiltinModule, - getActiveResourcesInfo, - getMaxListeners, - hrtime: hrtime3, - kill, - listeners, - listenerCount, - memoryUsage, - nextTick, - on, - off, - once, - pid, - platform, - ppid, - prependListener, - prependOnceListener, - rawListeners, - release, - removeAllListeners, - removeListener, - report, - resourceUsage, - setMaxListeners, - setSourceMapsEnabled, - stderr, - stdin, - stdout, - title, - throwDeprecation, - traceDeprecation, - umask, - uptime, - version, - versions, - // @ts-expect-error old API - domain, - initgroups, - moduleLoadList, - reallyExit, - openStdin, - assert: assert2, - binding, - send, - exitCode, - channel, - getegid, - geteuid, - getgid, - getgroups, - getuid, - setegid, - seteuid, - setgid, - setgroups, - setuid, - permission, - mainModule, - _events, - _eventsCount, - _exiting, - _maxListeners, - _debugEnd, - _debugProcess, - _fatalException, - _getActiveHandles, - _getActiveRequests, - _kill, - _preload_modules, - _rawDebug, - _startProfilerIdleNotifier, - _stopProfilerIdleNotifier, - _tickCallback, - _disconnect, - _handleQueue, - _pendingMessage, - _channel, - _send, - _linkedBinding - }; - process_default = _process; - } -}); - -// node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-process -var init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process = __esm({ - "node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-process"() { - init_process2(); - globalThis.process = process_default; - } -}); - -// node_modules/es-errors/type.js -var require_type = __commonJS({ - "node_modules/es-errors/type.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = TypeError; - } -}); - -// (disabled):node_modules/object-inspect/util.inspect -var require_util = __commonJS({ - "(disabled):node_modules/object-inspect/util.inspect"() { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - } -}); - -// node_modules/object-inspect/index.js -var require_object_inspect = __commonJS({ - "node_modules/object-inspect/index.js"(exports, module) { - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var hasMap = typeof Map === "function" && Map.prototype; - var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, "size") : null; - var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === "function" ? mapSizeDescriptor.get : null; - var mapForEach = hasMap && Map.prototype.forEach; - var hasSet = typeof Set === "function" && Set.prototype; - var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, "size") : null; - var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === "function" ? setSizeDescriptor.get : null; - var setForEach = hasSet && Set.prototype.forEach; - var hasWeakMap = typeof WeakMap === "function" && WeakMap.prototype; - var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null; - var hasWeakSet = typeof WeakSet === "function" && WeakSet.prototype; - var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null; - var hasWeakRef = typeof WeakRef === "function" && WeakRef.prototype; - var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null; - var booleanValueOf = Boolean.prototype.valueOf; - var objectToString = Object.prototype.toString; - var functionToString = Function.prototype.toString; - var $match = String.prototype.match; - var $slice = String.prototype.slice; - var $replace = String.prototype.replace; - var $toUpperCase = String.prototype.toUpperCase; - var $toLowerCase = String.prototype.toLowerCase; - var $test = RegExp.prototype.test; - var $concat = Array.prototype.concat; - var $join = Array.prototype.join; - var $arrSlice = Array.prototype.slice; - var $floor = Math.floor; - var bigIntValueOf = typeof BigInt === "function" ? BigInt.prototype.valueOf : null; - var gOPS = Object.getOwnPropertySymbols; - var symToString = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? Symbol.prototype.toString : null; - var hasShammedSymbols = typeof Symbol === "function" && typeof Symbol.iterator === "object"; - var toStringTag = typeof Symbol === "function" && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? "object" : "symbol") ? Symbol.toStringTag : null; - var isEnumerable = Object.prototype.propertyIsEnumerable; - var gPO = (typeof Reflect === "function" ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function(O) { - return O.__proto__; - } : null); - function addNumericSeparator(num, str) { - if (num === Infinity || num === -Infinity || num !== num || num && num > -1e3 && num < 1e3 || $test.call(/e/, str)) { - return str; - } - var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g; - if (typeof num === "number") { - var int = num < 0 ? -$floor(-num) : $floor(num); - if (int !== num) { - var intStr = String(int); - var dec = $slice.call(str, intStr.length + 1); - return $replace.call(intStr, sepRegex, "$&_") + "." + $replace.call($replace.call(dec, /([0-9]{3})/g, "$&_"), /_$/, ""); - } - } - return $replace.call(str, sepRegex, "$&_"); - } - __name(addNumericSeparator, "addNumericSeparator"); - var utilInspect = require_util(); - var inspectCustom = utilInspect.custom; - var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null; - var quotes = { - __proto__: null, - "double": '"', - single: "'" - }; - var quoteREs = { - __proto__: null, - "double": /(["\\])/g, - single: /(['\\])/g - }; - module.exports = /* @__PURE__ */ __name(function inspect_(obj, options, depth, seen) { - var opts = options || {}; - if (has(opts, "quoteStyle") && !has(quotes, opts.quoteStyle)) { - throw new TypeError('option "quoteStyle" must be "single" or "double"'); - } - if (has(opts, "maxStringLength") && (typeof opts.maxStringLength === "number" ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity : opts.maxStringLength !== null)) { - throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`'); - } - var customInspect = has(opts, "customInspect") ? opts.customInspect : true; - if (typeof customInspect !== "boolean" && customInspect !== "symbol") { - throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`"); - } - if (has(opts, "indent") && opts.indent !== null && opts.indent !== " " && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)) { - throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`'); - } - if (has(opts, "numericSeparator") && typeof opts.numericSeparator !== "boolean") { - throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`'); - } - var numericSeparator = opts.numericSeparator; - if (typeof obj === "undefined") { - return "undefined"; - } - if (obj === null) { - return "null"; - } - if (typeof obj === "boolean") { - return obj ? "true" : "false"; - } - if (typeof obj === "string") { - return inspectString(obj, opts); - } - if (typeof obj === "number") { - if (obj === 0) { - return Infinity / obj > 0 ? "0" : "-0"; - } - var str = String(obj); - return numericSeparator ? addNumericSeparator(obj, str) : str; - } - if (typeof obj === "bigint") { - var bigIntStr = String(obj) + "n"; - return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr; - } - var maxDepth = typeof opts.depth === "undefined" ? 5 : opts.depth; - if (typeof depth === "undefined") { - depth = 0; - } - if (depth >= maxDepth && maxDepth > 0 && typeof obj === "object") { - return isArray(obj) ? "[Array]" : "[Object]"; - } - var indent = getIndent(opts, depth); - if (typeof seen === "undefined") { - seen = []; - } else if (indexOf(seen, obj) >= 0) { - return "[Circular]"; - } - function inspect(value, from, noIndent) { - if (from) { - seen = $arrSlice.call(seen); - seen.push(from); - } - if (noIndent) { - var newOpts = { - depth: opts.depth - }; - if (has(opts, "quoteStyle")) { - newOpts.quoteStyle = opts.quoteStyle; - } - return inspect_(value, newOpts, depth + 1, seen); - } - return inspect_(value, opts, depth + 1, seen); - } - __name(inspect, "inspect"); - if (typeof obj === "function" && !isRegExp(obj)) { - var name = nameOf(obj); - var keys = arrObjKeys(obj, inspect); - return "[Function" + (name ? ": " + name : " (anonymous)") + "]" + (keys.length > 0 ? " { " + $join.call(keys, ", ") + " }" : ""); - } - if (isSymbol(obj)) { - var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, "$1") : symToString.call(obj); - return typeof obj === "object" && !hasShammedSymbols ? markBoxed(symString) : symString; - } - if (isElement(obj)) { - var s = "<" + $toLowerCase.call(String(obj.nodeName)); - var attrs = obj.attributes || []; - for (var i = 0; i < attrs.length; i++) { - s += " " + attrs[i].name + "=" + wrapQuotes(quote(attrs[i].value), "double", opts); - } - s += ">"; - if (obj.childNodes && obj.childNodes.length) { - s += "..."; - } - s += ""; - return s; - } - if (isArray(obj)) { - if (obj.length === 0) { - return "[]"; - } - var xs = arrObjKeys(obj, inspect); - if (indent && !singleLineValues(xs)) { - return "[" + indentedJoin(xs, indent) + "]"; - } - return "[ " + $join.call(xs, ", ") + " ]"; - } - if (isError(obj)) { - var parts = arrObjKeys(obj, inspect); - if (!("cause" in Error.prototype) && "cause" in obj && !isEnumerable.call(obj, "cause")) { - return "{ [" + String(obj) + "] " + $join.call($concat.call("[cause]: " + inspect(obj.cause), parts), ", ") + " }"; - } - if (parts.length === 0) { - return "[" + String(obj) + "]"; - } - return "{ [" + String(obj) + "] " + $join.call(parts, ", ") + " }"; - } - if (typeof obj === "object" && customInspect) { - if (inspectSymbol && typeof obj[inspectSymbol] === "function" && utilInspect) { - return utilInspect(obj, { depth: maxDepth - depth }); - } else if (customInspect !== "symbol" && typeof obj.inspect === "function") { - return obj.inspect(); - } - } - if (isMap(obj)) { - var mapParts = []; - if (mapForEach) { - mapForEach.call(obj, function(value, key) { - mapParts.push(inspect(key, obj, true) + " => " + inspect(value, obj)); - }); - } - return collectionOf("Map", mapSize.call(obj), mapParts, indent); - } - if (isSet(obj)) { - var setParts = []; - if (setForEach) { - setForEach.call(obj, function(value) { - setParts.push(inspect(value, obj)); - }); - } - return collectionOf("Set", setSize.call(obj), setParts, indent); - } - if (isWeakMap(obj)) { - return weakCollectionOf("WeakMap"); - } - if (isWeakSet(obj)) { - return weakCollectionOf("WeakSet"); - } - if (isWeakRef(obj)) { - return weakCollectionOf("WeakRef"); - } - if (isNumber(obj)) { - return markBoxed(inspect(Number(obj))); - } - if (isBigInt(obj)) { - return markBoxed(inspect(bigIntValueOf.call(obj))); - } - if (isBoolean(obj)) { - return markBoxed(booleanValueOf.call(obj)); - } - if (isString(obj)) { - return markBoxed(inspect(String(obj))); - } - if (typeof window !== "undefined" && obj === window) { - return "{ [object Window] }"; - } - if (typeof globalThis !== "undefined" && obj === globalThis || typeof global !== "undefined" && obj === global) { - return "{ [object globalThis] }"; - } - if (!isDate(obj) && !isRegExp(obj)) { - var ys = arrObjKeys(obj, inspect); - var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object; - var protoTag = obj instanceof Object ? "" : "null prototype"; - var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : ""; - var constructorTag = isPlainObject || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : ""; - var tag = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat.call([], stringTag || [], protoTag || []), ": ") + "] " : ""); - if (ys.length === 0) { - return tag + "{}"; - } - if (indent) { - return tag + "{" + indentedJoin(ys, indent) + "}"; - } - return tag + "{ " + $join.call(ys, ", ") + " }"; - } - return String(obj); - }, "inspect_"); - function wrapQuotes(s, defaultStyle, opts) { - var style = opts.quoteStyle || defaultStyle; - var quoteChar = quotes[style]; - return quoteChar + s + quoteChar; - } - __name(wrapQuotes, "wrapQuotes"); - function quote(s) { - return $replace.call(String(s), /"/g, """); - } - __name(quote, "quote"); - function canTrustToString(obj) { - return !toStringTag || !(typeof obj === "object" && (toStringTag in obj || typeof obj[toStringTag] !== "undefined")); - } - __name(canTrustToString, "canTrustToString"); - function isArray(obj) { - return toStr(obj) === "[object Array]" && canTrustToString(obj); - } - __name(isArray, "isArray"); - function isDate(obj) { - return toStr(obj) === "[object Date]" && canTrustToString(obj); - } - __name(isDate, "isDate"); - function isRegExp(obj) { - return toStr(obj) === "[object RegExp]" && canTrustToString(obj); - } - __name(isRegExp, "isRegExp"); - function isError(obj) { - return toStr(obj) === "[object Error]" && canTrustToString(obj); - } - __name(isError, "isError"); - function isString(obj) { - return toStr(obj) === "[object String]" && canTrustToString(obj); - } - __name(isString, "isString"); - function isNumber(obj) { - return toStr(obj) === "[object Number]" && canTrustToString(obj); - } - __name(isNumber, "isNumber"); - function isBoolean(obj) { - return toStr(obj) === "[object Boolean]" && canTrustToString(obj); - } - __name(isBoolean, "isBoolean"); - function isSymbol(obj) { - if (hasShammedSymbols) { - return obj && typeof obj === "object" && obj instanceof Symbol; - } - if (typeof obj === "symbol") { - return true; - } - if (!obj || typeof obj !== "object" || !symToString) { - return false; - } - try { - symToString.call(obj); - return true; - } catch (e) { - } - return false; - } - __name(isSymbol, "isSymbol"); - function isBigInt(obj) { - if (!obj || typeof obj !== "object" || !bigIntValueOf) { - return false; - } - try { - bigIntValueOf.call(obj); - return true; - } catch (e) { - } - return false; - } - __name(isBigInt, "isBigInt"); - var hasOwn = Object.prototype.hasOwnProperty || function(key) { - return key in this; - }; - function has(obj, key) { - return hasOwn.call(obj, key); - } - __name(has, "has"); - function toStr(obj) { - return objectToString.call(obj); - } - __name(toStr, "toStr"); - function nameOf(f) { - if (f.name) { - return f.name; - } - var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/); - if (m) { - return m[1]; - } - return null; - } - __name(nameOf, "nameOf"); - function indexOf(xs, x) { - if (xs.indexOf) { - return xs.indexOf(x); - } - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) { - return i; - } - } - return -1; - } - __name(indexOf, "indexOf"); - function isMap(x) { - if (!mapSize || !x || typeof x !== "object") { - return false; - } - try { - mapSize.call(x); - try { - setSize.call(x); - } catch (s) { - return true; - } - return x instanceof Map; - } catch (e) { - } - return false; - } - __name(isMap, "isMap"); - function isWeakMap(x) { - if (!weakMapHas || !x || typeof x !== "object") { - return false; - } - try { - weakMapHas.call(x, weakMapHas); - try { - weakSetHas.call(x, weakSetHas); - } catch (s) { - return true; - } - return x instanceof WeakMap; - } catch (e) { - } - return false; - } - __name(isWeakMap, "isWeakMap"); - function isWeakRef(x) { - if (!weakRefDeref || !x || typeof x !== "object") { - return false; - } - try { - weakRefDeref.call(x); - return true; - } catch (e) { - } - return false; - } - __name(isWeakRef, "isWeakRef"); - function isSet(x) { - if (!setSize || !x || typeof x !== "object") { - return false; - } - try { - setSize.call(x); - try { - mapSize.call(x); - } catch (m) { - return true; - } - return x instanceof Set; - } catch (e) { - } - return false; - } - __name(isSet, "isSet"); - function isWeakSet(x) { - if (!weakSetHas || !x || typeof x !== "object") { - return false; - } - try { - weakSetHas.call(x, weakSetHas); - try { - weakMapHas.call(x, weakMapHas); - } catch (s) { - return true; - } - return x instanceof WeakSet; - } catch (e) { - } - return false; - } - __name(isWeakSet, "isWeakSet"); - function isElement(x) { - if (!x || typeof x !== "object") { - return false; - } - if (typeof HTMLElement !== "undefined" && x instanceof HTMLElement) { - return true; - } - return typeof x.nodeName === "string" && typeof x.getAttribute === "function"; - } - __name(isElement, "isElement"); - function inspectString(str, opts) { - if (str.length > opts.maxStringLength) { - var remaining = str.length - opts.maxStringLength; - var trailer = "... " + remaining + " more character" + (remaining > 1 ? "s" : ""); - return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer; - } - var quoteRE = quoteREs[opts.quoteStyle || "single"]; - quoteRE.lastIndex = 0; - var s = $replace.call($replace.call(str, quoteRE, "\\$1"), /[\x00-\x1f]/g, lowbyte); - return wrapQuotes(s, "single", opts); - } - __name(inspectString, "inspectString"); - function lowbyte(c) { - var n = c.charCodeAt(0); - var x = { - 8: "b", - 9: "t", - 10: "n", - 12: "f", - 13: "r" - }[n]; - if (x) { - return "\\" + x; - } - return "\\x" + (n < 16 ? "0" : "") + $toUpperCase.call(n.toString(16)); - } - __name(lowbyte, "lowbyte"); - function markBoxed(str) { - return "Object(" + str + ")"; - } - __name(markBoxed, "markBoxed"); - function weakCollectionOf(type) { - return type + " { ? }"; - } - __name(weakCollectionOf, "weakCollectionOf"); - function collectionOf(type, size, entries, indent) { - var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ", "); - return type + " (" + size + ") {" + joinedEntries + "}"; - } - __name(collectionOf, "collectionOf"); - function singleLineValues(xs) { - for (var i = 0; i < xs.length; i++) { - if (indexOf(xs[i], "\n") >= 0) { - return false; - } - } - return true; - } - __name(singleLineValues, "singleLineValues"); - function getIndent(opts, depth) { - var baseIndent; - if (opts.indent === " ") { - baseIndent = " "; - } else if (typeof opts.indent === "number" && opts.indent > 0) { - baseIndent = $join.call(Array(opts.indent + 1), " "); - } else { - return null; - } - return { - base: baseIndent, - prev: $join.call(Array(depth + 1), baseIndent) - }; - } - __name(getIndent, "getIndent"); - function indentedJoin(xs, indent) { - if (xs.length === 0) { - return ""; - } - var lineJoiner = "\n" + indent.prev + indent.base; - return lineJoiner + $join.call(xs, "," + lineJoiner) + "\n" + indent.prev; - } - __name(indentedJoin, "indentedJoin"); - function arrObjKeys(obj, inspect) { - var isArr = isArray(obj); - var xs = []; - if (isArr) { - xs.length = obj.length; - for (var i = 0; i < obj.length; i++) { - xs[i] = has(obj, i) ? inspect(obj[i], obj) : ""; - } - } - var syms = typeof gOPS === "function" ? gOPS(obj) : []; - var symMap; - if (hasShammedSymbols) { - symMap = {}; - for (var k = 0; k < syms.length; k++) { - symMap["$" + syms[k]] = syms[k]; - } - } - for (var key in obj) { - if (!has(obj, key)) { - continue; - } - if (isArr && String(Number(key)) === key && key < obj.length) { - continue; - } - if (hasShammedSymbols && symMap["$" + key] instanceof Symbol) { - continue; - } else if ($test.call(/[^\w$]/, key)) { - xs.push(inspect(key, obj) + ": " + inspect(obj[key], obj)); - } else { - xs.push(key + ": " + inspect(obj[key], obj)); - } - } - if (typeof gOPS === "function") { - for (var j = 0; j < syms.length; j++) { - if (isEnumerable.call(obj, syms[j])) { - xs.push("[" + inspect(syms[j]) + "]: " + inspect(obj[syms[j]], obj)); - } - } - } - return xs; - } - __name(arrObjKeys, "arrObjKeys"); - } -}); - -// node_modules/side-channel-list/index.js -var require_side_channel_list = __commonJS({ - "node_modules/side-channel-list/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var inspect = require_object_inspect(); - var $TypeError = require_type(); - var listGetNode = /* @__PURE__ */ __name(function(list, key, isDelete) { - var prev = list; - var curr; - for (; (curr = prev.next) != null; prev = curr) { - if (curr.key === key) { - prev.next = curr.next; - if (!isDelete) { - curr.next = /** @type {NonNullable} */ - list.next; - list.next = curr; - } - return curr; - } - } - }, "listGetNode"); - var listGet = /* @__PURE__ */ __name(function(objects, key) { - if (!objects) { - return void 0; - } - var node = listGetNode(objects, key); - return node && node.value; - }, "listGet"); - var listSet = /* @__PURE__ */ __name(function(objects, key, value) { - var node = listGetNode(objects, key); - if (node) { - node.value = value; - } else { - objects.next = /** @type {import('./list.d.ts').ListNode} */ - { - // eslint-disable-line no-param-reassign, no-extra-parens - key, - next: objects.next, - value - }; - } - }, "listSet"); - var listHas = /* @__PURE__ */ __name(function(objects, key) { - if (!objects) { - return false; - } - return !!listGetNode(objects, key); - }, "listHas"); - var listDelete = /* @__PURE__ */ __name(function(objects, key) { - if (objects) { - return listGetNode(objects, key, true); - } - }, "listDelete"); - module.exports = /* @__PURE__ */ __name(function getSideChannelList() { - var $o; - var channel2 = { - assert: /* @__PURE__ */ __name(function(key) { - if (!channel2.has(key)) { - throw new $TypeError("Side channel does not contain " + inspect(key)); - } - }, "assert"), - "delete": /* @__PURE__ */ __name(function(key) { - var root = $o && $o.next; - var deletedNode = listDelete($o, key); - if (deletedNode && root && root === deletedNode) { - $o = void 0; - } - return !!deletedNode; - }, "delete"), - get: /* @__PURE__ */ __name(function(key) { - return listGet($o, key); - }, "get"), - has: /* @__PURE__ */ __name(function(key) { - return listHas($o, key); - }, "has"), - set: /* @__PURE__ */ __name(function(key, value) { - if (!$o) { - $o = { - next: void 0 - }; - } - listSet( - /** @type {NonNullable} */ - $o, - key, - value - ); - }, "set") - }; - return channel2; - }, "getSideChannelList"); - } -}); - -// node_modules/es-object-atoms/index.js -var require_es_object_atoms = __commonJS({ - "node_modules/es-object-atoms/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Object; - } -}); - -// node_modules/es-errors/index.js -var require_es_errors = __commonJS({ - "node_modules/es-errors/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Error; - } -}); - -// node_modules/es-errors/eval.js -var require_eval = __commonJS({ - "node_modules/es-errors/eval.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = EvalError; - } -}); - -// node_modules/es-errors/range.js -var require_range = __commonJS({ - "node_modules/es-errors/range.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = RangeError; - } -}); - -// node_modules/es-errors/ref.js -var require_ref = __commonJS({ - "node_modules/es-errors/ref.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = ReferenceError; - } -}); - -// node_modules/es-errors/syntax.js -var require_syntax = __commonJS({ - "node_modules/es-errors/syntax.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = SyntaxError; - } -}); - -// node_modules/es-errors/uri.js -var require_uri = __commonJS({ - "node_modules/es-errors/uri.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = URIError; - } -}); - -// node_modules/math-intrinsics/abs.js -var require_abs = __commonJS({ - "node_modules/math-intrinsics/abs.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Math.abs; - } -}); - -// node_modules/math-intrinsics/floor.js -var require_floor = __commonJS({ - "node_modules/math-intrinsics/floor.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Math.floor; - } -}); - -// node_modules/math-intrinsics/max.js -var require_max = __commonJS({ - "node_modules/math-intrinsics/max.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Math.max; - } -}); - -// node_modules/math-intrinsics/min.js -var require_min = __commonJS({ - "node_modules/math-intrinsics/min.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Math.min; - } -}); - -// node_modules/math-intrinsics/pow.js -var require_pow = __commonJS({ - "node_modules/math-intrinsics/pow.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Math.pow; - } -}); - -// node_modules/math-intrinsics/round.js -var require_round = __commonJS({ - "node_modules/math-intrinsics/round.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Math.round; - } -}); - -// node_modules/math-intrinsics/isNaN.js -var require_isNaN = __commonJS({ - "node_modules/math-intrinsics/isNaN.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Number.isNaN || /* @__PURE__ */ __name(function isNaN2(a) { - return a !== a; - }, "isNaN"); - } -}); - -// node_modules/math-intrinsics/sign.js -var require_sign = __commonJS({ - "node_modules/math-intrinsics/sign.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var $isNaN = require_isNaN(); - module.exports = /* @__PURE__ */ __name(function sign(number) { - if ($isNaN(number) || number === 0) { - return number; - } - return number < 0 ? -1 : 1; - }, "sign"); - } -}); - -// node_modules/gopd/gOPD.js -var require_gOPD = __commonJS({ - "node_modules/gopd/gOPD.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Object.getOwnPropertyDescriptor; - } -}); - -// node_modules/gopd/index.js -var require_gopd = __commonJS({ - "node_modules/gopd/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var $gOPD = require_gOPD(); - if ($gOPD) { - try { - $gOPD([], "length"); - } catch (e) { - $gOPD = null; - } - } - module.exports = $gOPD; - } -}); - -// node_modules/es-define-property/index.js -var require_es_define_property = __commonJS({ - "node_modules/es-define-property/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var $defineProperty = Object.defineProperty || false; - if ($defineProperty) { - try { - $defineProperty({}, "a", { value: 1 }); - } catch (e) { - $defineProperty = false; - } - } - module.exports = $defineProperty; - } -}); - -// node_modules/has-symbols/shams.js -var require_shams = __commonJS({ - "node_modules/has-symbols/shams.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = /* @__PURE__ */ __name(function hasSymbols() { - if (typeof Symbol !== "function" || typeof Object.getOwnPropertySymbols !== "function") { - return false; - } - if (typeof Symbol.iterator === "symbol") { - return true; - } - var obj = {}; - var sym = Symbol("test"); - var symObj = Object(sym); - if (typeof sym === "string") { - return false; - } - if (Object.prototype.toString.call(sym) !== "[object Symbol]") { - return false; - } - if (Object.prototype.toString.call(symObj) !== "[object Symbol]") { - return false; - } - var symVal = 42; - obj[sym] = symVal; - for (var _ in obj) { - return false; - } - if (typeof Object.keys === "function" && Object.keys(obj).length !== 0) { - return false; - } - if (typeof Object.getOwnPropertyNames === "function" && Object.getOwnPropertyNames(obj).length !== 0) { - return false; - } - var syms = Object.getOwnPropertySymbols(obj); - if (syms.length !== 1 || syms[0] !== sym) { - return false; - } - if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { - return false; - } - if (typeof Object.getOwnPropertyDescriptor === "function") { - var descriptor = ( - /** @type {PropertyDescriptor} */ - Object.getOwnPropertyDescriptor(obj, sym) - ); - if (descriptor.value !== symVal || descriptor.enumerable !== true) { - return false; - } - } - return true; - }, "hasSymbols"); - } -}); - -// node_modules/has-symbols/index.js -var require_has_symbols = __commonJS({ - "node_modules/has-symbols/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var origSymbol = typeof Symbol !== "undefined" && Symbol; - var hasSymbolSham = require_shams(); - module.exports = /* @__PURE__ */ __name(function hasNativeSymbols() { - if (typeof origSymbol !== "function") { - return false; - } - if (typeof Symbol !== "function") { - return false; - } - if (typeof origSymbol("foo") !== "symbol") { - return false; - } - if (typeof Symbol("bar") !== "symbol") { - return false; - } - return hasSymbolSham(); - }, "hasNativeSymbols"); - } -}); - -// node_modules/get-proto/Reflect.getPrototypeOf.js -var require_Reflect_getPrototypeOf = __commonJS({ - "node_modules/get-proto/Reflect.getPrototypeOf.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = typeof Reflect !== "undefined" && Reflect.getPrototypeOf || null; - } -}); - -// node_modules/get-proto/Object.getPrototypeOf.js -var require_Object_getPrototypeOf = __commonJS({ - "node_modules/get-proto/Object.getPrototypeOf.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var $Object = require_es_object_atoms(); - module.exports = $Object.getPrototypeOf || null; - } -}); - -// node_modules/function-bind/implementation.js -var require_implementation = __commonJS({ - "node_modules/function-bind/implementation.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var ERROR_MESSAGE = "Function.prototype.bind called on incompatible "; - var toStr = Object.prototype.toString; - var max = Math.max; - var funcType = "[object Function]"; - var concatty = /* @__PURE__ */ __name(function concatty2(a, b) { - var arr = []; - for (var i = 0; i < a.length; i += 1) { - arr[i] = a[i]; - } - for (var j = 0; j < b.length; j += 1) { - arr[j + a.length] = b[j]; - } - return arr; - }, "concatty"); - var slicy = /* @__PURE__ */ __name(function slicy2(arrLike, offset) { - var arr = []; - for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) { - arr[j] = arrLike[i]; - } - return arr; - }, "slicy"); - var joiny = /* @__PURE__ */ __name(function(arr, joiner) { - var str = ""; - for (var i = 0; i < arr.length; i += 1) { - str += arr[i]; - if (i + 1 < arr.length) { - str += joiner; - } - } - return str; - }, "joiny"); - module.exports = /* @__PURE__ */ __name(function bind(that) { - var target = this; - if (typeof target !== "function" || toStr.apply(target) !== funcType) { - throw new TypeError(ERROR_MESSAGE + target); - } - var args = slicy(arguments, 1); - var bound; - var binder = /* @__PURE__ */ __name(function() { - if (this instanceof bound) { - var result = target.apply( - this, - concatty(args, arguments) - ); - if (Object(result) === result) { - return result; - } - return this; - } - return target.apply( - that, - concatty(args, arguments) - ); - }, "binder"); - var boundLength = max(0, target.length - args.length); - var boundArgs = []; - for (var i = 0; i < boundLength; i++) { - boundArgs[i] = "$" + i; - } - bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder); - if (target.prototype) { - var Empty = /* @__PURE__ */ __name(function Empty2() { - }, "Empty"); - Empty.prototype = target.prototype; - bound.prototype = new Empty(); - Empty.prototype = null; - } - return bound; - }, "bind"); - } -}); - -// node_modules/function-bind/index.js -var require_function_bind = __commonJS({ - "node_modules/function-bind/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var implementation = require_implementation(); - module.exports = Function.prototype.bind || implementation; - } -}); - -// node_modules/call-bind-apply-helpers/functionCall.js -var require_functionCall = __commonJS({ - "node_modules/call-bind-apply-helpers/functionCall.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Function.prototype.call; - } -}); - -// node_modules/call-bind-apply-helpers/functionApply.js -var require_functionApply = __commonJS({ - "node_modules/call-bind-apply-helpers/functionApply.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = Function.prototype.apply; - } -}); - -// node_modules/call-bind-apply-helpers/reflectApply.js -var require_reflectApply = __commonJS({ - "node_modules/call-bind-apply-helpers/reflectApply.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - module.exports = typeof Reflect !== "undefined" && Reflect && Reflect.apply; - } -}); - -// node_modules/call-bind-apply-helpers/actualApply.js -var require_actualApply = __commonJS({ - "node_modules/call-bind-apply-helpers/actualApply.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var bind = require_function_bind(); - var $apply = require_functionApply(); - var $call = require_functionCall(); - var $reflectApply = require_reflectApply(); - module.exports = $reflectApply || bind.call($call, $apply); - } -}); - -// node_modules/call-bind-apply-helpers/index.js -var require_call_bind_apply_helpers = __commonJS({ - "node_modules/call-bind-apply-helpers/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var bind = require_function_bind(); - var $TypeError = require_type(); - var $call = require_functionCall(); - var $actualApply = require_actualApply(); - module.exports = /* @__PURE__ */ __name(function callBindBasic(args) { - if (args.length < 1 || typeof args[0] !== "function") { - throw new $TypeError("a function is required"); - } - return $actualApply(bind, $call, args); - }, "callBindBasic"); - } -}); - -// node_modules/dunder-proto/get.js -var require_get = __commonJS({ - "node_modules/dunder-proto/get.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var callBind = require_call_bind_apply_helpers(); - var gOPD = require_gopd(); - var hasProtoAccessor; - try { - hasProtoAccessor = /** @type {{ __proto__?: typeof Array.prototype }} */ - [].__proto__ === Array.prototype; - } catch (e) { - if (!e || typeof e !== "object" || !("code" in e) || e.code !== "ERR_PROTO_ACCESS") { - throw e; - } - } - var desc = !!hasProtoAccessor && gOPD && gOPD( - Object.prototype, - /** @type {keyof typeof Object.prototype} */ - "__proto__" - ); - var $Object = Object; - var $getPrototypeOf = $Object.getPrototypeOf; - module.exports = desc && typeof desc.get === "function" ? callBind([desc.get]) : typeof $getPrototypeOf === "function" ? ( - /** @type {import('./get')} */ - /* @__PURE__ */ __name(function getDunder(value) { - return $getPrototypeOf(value == null ? value : $Object(value)); - }, "getDunder") - ) : false; - } -}); - -// node_modules/get-proto/index.js -var require_get_proto = __commonJS({ - "node_modules/get-proto/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var reflectGetProto = require_Reflect_getPrototypeOf(); - var originalGetProto = require_Object_getPrototypeOf(); - var getDunderProto = require_get(); - module.exports = reflectGetProto ? /* @__PURE__ */ __name(function getProto(O) { - return reflectGetProto(O); - }, "getProto") : originalGetProto ? /* @__PURE__ */ __name(function getProto(O) { - if (!O || typeof O !== "object" && typeof O !== "function") { - throw new TypeError("getProto: not an object"); - } - return originalGetProto(O); - }, "getProto") : getDunderProto ? /* @__PURE__ */ __name(function getProto(O) { - return getDunderProto(O); - }, "getProto") : null; - } -}); - -// node_modules/hasown/index.js -var require_hasown = __commonJS({ - "node_modules/hasown/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var call = Function.prototype.call; - var $hasOwn = Object.prototype.hasOwnProperty; - var bind = require_function_bind(); - module.exports = bind.call(call, $hasOwn); - } -}); - -// node_modules/get-intrinsic/index.js -var require_get_intrinsic = __commonJS({ - "node_modules/get-intrinsic/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var undefined2; - var $Object = require_es_object_atoms(); - var $Error = require_es_errors(); - var $EvalError = require_eval(); - var $RangeError = require_range(); - var $ReferenceError = require_ref(); - var $SyntaxError = require_syntax(); - var $TypeError = require_type(); - var $URIError = require_uri(); - var abs = require_abs(); - var floor = require_floor(); - var max = require_max(); - var min = require_min(); - var pow = require_pow(); - var round = require_round(); - var sign = require_sign(); - var $Function = Function; - var getEvalledConstructor = /* @__PURE__ */ __name(function(expressionSyntax) { - try { - return $Function('"use strict"; return (' + expressionSyntax + ").constructor;")(); - } catch (e) { - } - }, "getEvalledConstructor"); - var $gOPD = require_gopd(); - var $defineProperty = require_es_define_property(); - var throwTypeError = /* @__PURE__ */ __name(function() { - throw new $TypeError(); - }, "throwTypeError"); - var ThrowTypeError = $gOPD ? function() { - try { - arguments.callee; - return throwTypeError; - } catch (calleeThrows) { - try { - return $gOPD(arguments, "callee").get; - } catch (gOPDthrows) { - return throwTypeError; - } - } - }() : throwTypeError; - var hasSymbols = require_has_symbols()(); - var getProto = require_get_proto(); - var $ObjectGPO = require_Object_getPrototypeOf(); - var $ReflectGPO = require_Reflect_getPrototypeOf(); - var $apply = require_functionApply(); - var $call = require_functionCall(); - var needsEval = {}; - var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined2 : getProto(Uint8Array); - var INTRINSICS = { - __proto__: null, - "%AggregateError%": typeof AggregateError === "undefined" ? undefined2 : AggregateError, - "%Array%": Array, - "%ArrayBuffer%": typeof ArrayBuffer === "undefined" ? undefined2 : ArrayBuffer, - "%ArrayIteratorPrototype%": hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined2, - "%AsyncFromSyncIteratorPrototype%": undefined2, - "%AsyncFunction%": needsEval, - "%AsyncGenerator%": needsEval, - "%AsyncGeneratorFunction%": needsEval, - "%AsyncIteratorPrototype%": needsEval, - "%Atomics%": typeof Atomics === "undefined" ? undefined2 : Atomics, - "%BigInt%": typeof BigInt === "undefined" ? undefined2 : BigInt, - "%BigInt64Array%": typeof BigInt64Array === "undefined" ? undefined2 : BigInt64Array, - "%BigUint64Array%": typeof BigUint64Array === "undefined" ? undefined2 : BigUint64Array, - "%Boolean%": Boolean, - "%DataView%": typeof DataView === "undefined" ? undefined2 : DataView, - "%Date%": Date, - "%decodeURI%": decodeURI, - "%decodeURIComponent%": decodeURIComponent, - "%encodeURI%": encodeURI, - "%encodeURIComponent%": encodeURIComponent, - "%Error%": $Error, - "%eval%": eval, - // eslint-disable-line no-eval - "%EvalError%": $EvalError, - "%Float16Array%": typeof Float16Array === "undefined" ? undefined2 : Float16Array, - "%Float32Array%": typeof Float32Array === "undefined" ? undefined2 : Float32Array, - "%Float64Array%": typeof Float64Array === "undefined" ? undefined2 : Float64Array, - "%FinalizationRegistry%": typeof FinalizationRegistry === "undefined" ? undefined2 : FinalizationRegistry, - "%Function%": $Function, - "%GeneratorFunction%": needsEval, - "%Int8Array%": typeof Int8Array === "undefined" ? undefined2 : Int8Array, - "%Int16Array%": typeof Int16Array === "undefined" ? undefined2 : Int16Array, - "%Int32Array%": typeof Int32Array === "undefined" ? undefined2 : Int32Array, - "%isFinite%": isFinite, - "%isNaN%": isNaN, - "%IteratorPrototype%": hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined2, - "%JSON%": typeof JSON === "object" ? JSON : undefined2, - "%Map%": typeof Map === "undefined" ? undefined2 : Map, - "%MapIteratorPrototype%": typeof Map === "undefined" || !hasSymbols || !getProto ? undefined2 : getProto((/* @__PURE__ */ new Map())[Symbol.iterator]()), - "%Math%": Math, - "%Number%": Number, - "%Object%": $Object, - "%Object.getOwnPropertyDescriptor%": $gOPD, - "%parseFloat%": parseFloat, - "%parseInt%": parseInt, - "%Promise%": typeof Promise === "undefined" ? undefined2 : Promise, - "%Proxy%": typeof Proxy === "undefined" ? undefined2 : Proxy, - "%RangeError%": $RangeError, - "%ReferenceError%": $ReferenceError, - "%Reflect%": typeof Reflect === "undefined" ? undefined2 : Reflect, - "%RegExp%": RegExp, - "%Set%": typeof Set === "undefined" ? undefined2 : Set, - "%SetIteratorPrototype%": typeof Set === "undefined" || !hasSymbols || !getProto ? undefined2 : getProto((/* @__PURE__ */ new Set())[Symbol.iterator]()), - "%SharedArrayBuffer%": typeof SharedArrayBuffer === "undefined" ? undefined2 : SharedArrayBuffer, - "%String%": String, - "%StringIteratorPrototype%": hasSymbols && getProto ? getProto(""[Symbol.iterator]()) : undefined2, - "%Symbol%": hasSymbols ? Symbol : undefined2, - "%SyntaxError%": $SyntaxError, - "%ThrowTypeError%": ThrowTypeError, - "%TypedArray%": TypedArray, - "%TypeError%": $TypeError, - "%Uint8Array%": typeof Uint8Array === "undefined" ? undefined2 : Uint8Array, - "%Uint8ClampedArray%": typeof Uint8ClampedArray === "undefined" ? undefined2 : Uint8ClampedArray, - "%Uint16Array%": typeof Uint16Array === "undefined" ? undefined2 : Uint16Array, - "%Uint32Array%": typeof Uint32Array === "undefined" ? undefined2 : Uint32Array, - "%URIError%": $URIError, - "%WeakMap%": typeof WeakMap === "undefined" ? undefined2 : WeakMap, - "%WeakRef%": typeof WeakRef === "undefined" ? undefined2 : WeakRef, - "%WeakSet%": typeof WeakSet === "undefined" ? undefined2 : WeakSet, - "%Function.prototype.call%": $call, - "%Function.prototype.apply%": $apply, - "%Object.defineProperty%": $defineProperty, - "%Object.getPrototypeOf%": $ObjectGPO, - "%Math.abs%": abs, - "%Math.floor%": floor, - "%Math.max%": max, - "%Math.min%": min, - "%Math.pow%": pow, - "%Math.round%": round, - "%Math.sign%": sign, - "%Reflect.getPrototypeOf%": $ReflectGPO - }; - if (getProto) { - try { - null.error; - } catch (e) { - errorProto = getProto(getProto(e)); - INTRINSICS["%Error.prototype%"] = errorProto; - } - } - var errorProto; - var doEval = /* @__PURE__ */ __name(function doEval2(name) { - var value; - if (name === "%AsyncFunction%") { - value = getEvalledConstructor("async function () {}"); - } else if (name === "%GeneratorFunction%") { - value = getEvalledConstructor("function* () {}"); - } else if (name === "%AsyncGeneratorFunction%") { - value = getEvalledConstructor("async function* () {}"); - } else if (name === "%AsyncGenerator%") { - var fn = doEval2("%AsyncGeneratorFunction%"); - if (fn) { - value = fn.prototype; - } - } else if (name === "%AsyncIteratorPrototype%") { - var gen = doEval2("%AsyncGenerator%"); - if (gen && getProto) { - value = getProto(gen.prototype); - } - } - INTRINSICS[name] = value; - return value; - }, "doEval"); - var LEGACY_ALIASES = { - __proto__: null, - "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"], - "%ArrayPrototype%": ["Array", "prototype"], - "%ArrayProto_entries%": ["Array", "prototype", "entries"], - "%ArrayProto_forEach%": ["Array", "prototype", "forEach"], - "%ArrayProto_keys%": ["Array", "prototype", "keys"], - "%ArrayProto_values%": ["Array", "prototype", "values"], - "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"], - "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"], - "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"], - "%BooleanPrototype%": ["Boolean", "prototype"], - "%DataViewPrototype%": ["DataView", "prototype"], - "%DatePrototype%": ["Date", "prototype"], - "%ErrorPrototype%": ["Error", "prototype"], - "%EvalErrorPrototype%": ["EvalError", "prototype"], - "%Float32ArrayPrototype%": ["Float32Array", "prototype"], - "%Float64ArrayPrototype%": ["Float64Array", "prototype"], - "%FunctionPrototype%": ["Function", "prototype"], - "%Generator%": ["GeneratorFunction", "prototype"], - "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"], - "%Int8ArrayPrototype%": ["Int8Array", "prototype"], - "%Int16ArrayPrototype%": ["Int16Array", "prototype"], - "%Int32ArrayPrototype%": ["Int32Array", "prototype"], - "%JSONParse%": ["JSON", "parse"], - "%JSONStringify%": ["JSON", "stringify"], - "%MapPrototype%": ["Map", "prototype"], - "%NumberPrototype%": ["Number", "prototype"], - "%ObjectPrototype%": ["Object", "prototype"], - "%ObjProto_toString%": ["Object", "prototype", "toString"], - "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"], - "%PromisePrototype%": ["Promise", "prototype"], - "%PromiseProto_then%": ["Promise", "prototype", "then"], - "%Promise_all%": ["Promise", "all"], - "%Promise_reject%": ["Promise", "reject"], - "%Promise_resolve%": ["Promise", "resolve"], - "%RangeErrorPrototype%": ["RangeError", "prototype"], - "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"], - "%RegExpPrototype%": ["RegExp", "prototype"], - "%SetPrototype%": ["Set", "prototype"], - "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"], - "%StringPrototype%": ["String", "prototype"], - "%SymbolPrototype%": ["Symbol", "prototype"], - "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"], - "%TypedArrayPrototype%": ["TypedArray", "prototype"], - "%TypeErrorPrototype%": ["TypeError", "prototype"], - "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"], - "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"], - "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"], - "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"], - "%URIErrorPrototype%": ["URIError", "prototype"], - "%WeakMapPrototype%": ["WeakMap", "prototype"], - "%WeakSetPrototype%": ["WeakSet", "prototype"] - }; - var bind = require_function_bind(); - var hasOwn = require_hasown(); - var $concat = bind.call($call, Array.prototype.concat); - var $spliceApply = bind.call($apply, Array.prototype.splice); - var $replace = bind.call($call, String.prototype.replace); - var $strSlice = bind.call($call, String.prototype.slice); - var $exec = bind.call($call, RegExp.prototype.exec); - var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g; - var reEscapeChar = /\\(\\)?/g; - var stringToPath = /* @__PURE__ */ __name(function stringToPath2(string) { - var first = $strSlice(string, 0, 1); - var last = $strSlice(string, -1); - if (first === "%" && last !== "%") { - throw new $SyntaxError("invalid intrinsic syntax, expected closing `%`"); - } else if (last === "%" && first !== "%") { - throw new $SyntaxError("invalid intrinsic syntax, expected opening `%`"); - } - var result = []; - $replace(string, rePropName, function(match, number, quote, subString) { - result[result.length] = quote ? $replace(subString, reEscapeChar, "$1") : number || match; - }); - return result; - }, "stringToPath"); - var getBaseIntrinsic = /* @__PURE__ */ __name(function getBaseIntrinsic2(name, allowMissing) { - var intrinsicName = name; - var alias; - if (hasOwn(LEGACY_ALIASES, intrinsicName)) { - alias = LEGACY_ALIASES[intrinsicName]; - intrinsicName = "%" + alias[0] + "%"; - } - if (hasOwn(INTRINSICS, intrinsicName)) { - var value = INTRINSICS[intrinsicName]; - if (value === needsEval) { - value = doEval(intrinsicName); - } - if (typeof value === "undefined" && !allowMissing) { - throw new $TypeError("intrinsic " + name + " exists, but is not available. Please file an issue!"); - } - return { - alias, - name: intrinsicName, - value - }; - } - throw new $SyntaxError("intrinsic " + name + " does not exist!"); - }, "getBaseIntrinsic"); - module.exports = /* @__PURE__ */ __name(function GetIntrinsic(name, allowMissing) { - if (typeof name !== "string" || name.length === 0) { - throw new $TypeError("intrinsic name must be a non-empty string"); - } - if (arguments.length > 1 && typeof allowMissing !== "boolean") { - throw new $TypeError('"allowMissing" argument must be a boolean'); - } - if ($exec(/^%?[^%]*%?$/, name) === null) { - throw new $SyntaxError("`%` may not be present anywhere but at the beginning and end of the intrinsic name"); - } - var parts = stringToPath(name); - var intrinsicBaseName = parts.length > 0 ? parts[0] : ""; - var intrinsic = getBaseIntrinsic("%" + intrinsicBaseName + "%", allowMissing); - var intrinsicRealName = intrinsic.name; - var value = intrinsic.value; - var skipFurtherCaching = false; - var alias = intrinsic.alias; - if (alias) { - intrinsicBaseName = alias[0]; - $spliceApply(parts, $concat([0, 1], alias)); - } - for (var i = 1, isOwn = true; i < parts.length; i += 1) { - var part = parts[i]; - var first = $strSlice(part, 0, 1); - var last = $strSlice(part, -1); - if ((first === '"' || first === "'" || first === "`" || (last === '"' || last === "'" || last === "`")) && first !== last) { - throw new $SyntaxError("property names with quotes must have matching quotes"); - } - if (part === "constructor" || !isOwn) { - skipFurtherCaching = true; - } - intrinsicBaseName += "." + part; - intrinsicRealName = "%" + intrinsicBaseName + "%"; - if (hasOwn(INTRINSICS, intrinsicRealName)) { - value = INTRINSICS[intrinsicRealName]; - } else if (value != null) { - if (!(part in value)) { - if (!allowMissing) { - throw new $TypeError("base intrinsic for " + name + " exists, but the property is not available."); - } - return void undefined2; - } - if ($gOPD && i + 1 >= parts.length) { - var desc = $gOPD(value, part); - isOwn = !!desc; - if (isOwn && "get" in desc && !("originalValue" in desc.get)) { - value = desc.get; - } else { - value = value[part]; - } - } else { - isOwn = hasOwn(value, part); - value = value[part]; - } - if (isOwn && !skipFurtherCaching) { - INTRINSICS[intrinsicRealName] = value; - } - } - } - return value; - }, "GetIntrinsic"); - } -}); - -// node_modules/call-bound/index.js -var require_call_bound = __commonJS({ - "node_modules/call-bound/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var GetIntrinsic = require_get_intrinsic(); - var callBindBasic = require_call_bind_apply_helpers(); - var $indexOf = callBindBasic([GetIntrinsic("%String.prototype.indexOf%")]); - module.exports = /* @__PURE__ */ __name(function callBoundIntrinsic(name, allowMissing) { - var intrinsic = ( - /** @type {(this: unknown, ...args: unknown[]) => unknown} */ - GetIntrinsic(name, !!allowMissing) - ); - if (typeof intrinsic === "function" && $indexOf(name, ".prototype.") > -1) { - return callBindBasic( - /** @type {const} */ - [intrinsic] - ); - } - return intrinsic; - }, "callBoundIntrinsic"); - } -}); - -// node_modules/side-channel-map/index.js -var require_side_channel_map = __commonJS({ - "node_modules/side-channel-map/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var GetIntrinsic = require_get_intrinsic(); - var callBound = require_call_bound(); - var inspect = require_object_inspect(); - var $TypeError = require_type(); - var $Map = GetIntrinsic("%Map%", true); - var $mapGet = callBound("Map.prototype.get", true); - var $mapSet = callBound("Map.prototype.set", true); - var $mapHas = callBound("Map.prototype.has", true); - var $mapDelete = callBound("Map.prototype.delete", true); - var $mapSize = callBound("Map.prototype.size", true); - module.exports = !!$Map && /** @type {Exclude} */ - /* @__PURE__ */ __name(function getSideChannelMap() { - var $m; - var channel2 = { - assert: /* @__PURE__ */ __name(function(key) { - if (!channel2.has(key)) { - throw new $TypeError("Side channel does not contain " + inspect(key)); - } - }, "assert"), - "delete": /* @__PURE__ */ __name(function(key) { - if ($m) { - var result = $mapDelete($m, key); - if ($mapSize($m) === 0) { - $m = void 0; - } - return result; - } - return false; - }, "delete"), - get: /* @__PURE__ */ __name(function(key) { - if ($m) { - return $mapGet($m, key); - } - }, "get"), - has: /* @__PURE__ */ __name(function(key) { - if ($m) { - return $mapHas($m, key); - } - return false; - }, "has"), - set: /* @__PURE__ */ __name(function(key, value) { - if (!$m) { - $m = new $Map(); - } - $mapSet($m, key, value); - }, "set") - }; - return channel2; - }, "getSideChannelMap"); - } -}); - -// node_modules/side-channel-weakmap/index.js -var require_side_channel_weakmap = __commonJS({ - "node_modules/side-channel-weakmap/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var GetIntrinsic = require_get_intrinsic(); - var callBound = require_call_bound(); - var inspect = require_object_inspect(); - var getSideChannelMap = require_side_channel_map(); - var $TypeError = require_type(); - var $WeakMap = GetIntrinsic("%WeakMap%", true); - var $weakMapGet = callBound("WeakMap.prototype.get", true); - var $weakMapSet = callBound("WeakMap.prototype.set", true); - var $weakMapHas = callBound("WeakMap.prototype.has", true); - var $weakMapDelete = callBound("WeakMap.prototype.delete", true); - module.exports = $WeakMap ? ( - /** @type {Exclude} */ - /* @__PURE__ */ __name(function getSideChannelWeakMap() { - var $wm; - var $m; - var channel2 = { - assert: /* @__PURE__ */ __name(function(key) { - if (!channel2.has(key)) { - throw new $TypeError("Side channel does not contain " + inspect(key)); - } - }, "assert"), - "delete": /* @__PURE__ */ __name(function(key) { - if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) { - if ($wm) { - return $weakMapDelete($wm, key); - } - } else if (getSideChannelMap) { - if ($m) { - return $m["delete"](key); - } - } - return false; - }, "delete"), - get: /* @__PURE__ */ __name(function(key) { - if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) { - if ($wm) { - return $weakMapGet($wm, key); - } - } - return $m && $m.get(key); - }, "get"), - has: /* @__PURE__ */ __name(function(key) { - if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) { - if ($wm) { - return $weakMapHas($wm, key); - } - } - return !!$m && $m.has(key); - }, "has"), - set: /* @__PURE__ */ __name(function(key, value) { - if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) { - if (!$wm) { - $wm = new $WeakMap(); - } - $weakMapSet($wm, key, value); - } else if (getSideChannelMap) { - if (!$m) { - $m = getSideChannelMap(); - } - $m.set(key, value); - } - }, "set") - }; - return channel2; - }, "getSideChannelWeakMap") - ) : getSideChannelMap; - } -}); - -// node_modules/side-channel/index.js -var require_side_channel = __commonJS({ - "node_modules/side-channel/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var $TypeError = require_type(); - var inspect = require_object_inspect(); - var getSideChannelList = require_side_channel_list(); - var getSideChannelMap = require_side_channel_map(); - var getSideChannelWeakMap = require_side_channel_weakmap(); - var makeChannel = getSideChannelWeakMap || getSideChannelMap || getSideChannelList; - module.exports = /* @__PURE__ */ __name(function getSideChannel() { - var $channelData; - var channel2 = { - assert: /* @__PURE__ */ __name(function(key) { - if (!channel2.has(key)) { - throw new $TypeError("Side channel does not contain " + inspect(key)); - } - }, "assert"), - "delete": /* @__PURE__ */ __name(function(key) { - return !!$channelData && $channelData["delete"](key); - }, "delete"), - get: /* @__PURE__ */ __name(function(key) { - return $channelData && $channelData.get(key); - }, "get"), - has: /* @__PURE__ */ __name(function(key) { - return !!$channelData && $channelData.has(key); - }, "has"), - set: /* @__PURE__ */ __name(function(key, value) { - if (!$channelData) { - $channelData = makeChannel(); - } - $channelData.set(key, value); - }, "set") - }; - return channel2; - }, "getSideChannel"); - } -}); - -// node_modules/qs/lib/formats.js -var require_formats = __commonJS({ - "node_modules/qs/lib/formats.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var replace = String.prototype.replace; - var percentTwenties = /%20/g; - var Format = { - RFC1738: "RFC1738", - RFC3986: "RFC3986" - }; - module.exports = { - "default": Format.RFC3986, - formatters: { - RFC1738: /* @__PURE__ */ __name(function(value) { - return replace.call(value, percentTwenties, "+"); - }, "RFC1738"), - RFC3986: /* @__PURE__ */ __name(function(value) { - return String(value); - }, "RFC3986") - }, - RFC1738: Format.RFC1738, - RFC3986: Format.RFC3986 - }; - } -}); - -// node_modules/qs/lib/utils.js -var require_utils = __commonJS({ - "node_modules/qs/lib/utils.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var formats = require_formats(); - var has = Object.prototype.hasOwnProperty; - var isArray = Array.isArray; - var hexTable = function() { - var array = []; - for (var i = 0; i < 256; ++i) { - array.push("%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase()); - } - return array; - }(); - var compactQueue = /* @__PURE__ */ __name(function compactQueue2(queue) { - while (queue.length > 1) { - var item = queue.pop(); - var obj = item.obj[item.prop]; - if (isArray(obj)) { - var compacted = []; - for (var j = 0; j < obj.length; ++j) { - if (typeof obj[j] !== "undefined") { - compacted.push(obj[j]); - } - } - item.obj[item.prop] = compacted; - } - } - }, "compactQueue"); - var arrayToObject = /* @__PURE__ */ __name(function arrayToObject2(source, options) { - var obj = options && options.plainObjects ? { __proto__: null } : {}; - for (var i = 0; i < source.length; ++i) { - if (typeof source[i] !== "undefined") { - obj[i] = source[i]; - } - } - return obj; - }, "arrayToObject"); - var merge = /* @__PURE__ */ __name(function merge2(target, source, options) { - if (!source) { - return target; - } - if (typeof source !== "object" && typeof source !== "function") { - if (isArray(target)) { - target.push(source); - } else if (target && typeof target === "object") { - if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) { - target[source] = true; - } - } else { - return [target, source]; - } - return target; - } - if (!target || typeof target !== "object") { - return [target].concat(source); - } - var mergeTarget = target; - if (isArray(target) && !isArray(source)) { - mergeTarget = arrayToObject(target, options); - } - if (isArray(target) && isArray(source)) { - source.forEach(function(item, i) { - if (has.call(target, i)) { - var targetItem = target[i]; - if (targetItem && typeof targetItem === "object" && item && typeof item === "object") { - target[i] = merge2(targetItem, item, options); - } else { - target.push(item); - } - } else { - target[i] = item; - } - }); - return target; - } - return Object.keys(source).reduce(function(acc, key) { - var value = source[key]; - if (has.call(acc, key)) { - acc[key] = merge2(acc[key], value, options); - } else { - acc[key] = value; - } - return acc; - }, mergeTarget); - }, "merge"); - var assign = /* @__PURE__ */ __name(function assignSingleSource(target, source) { - return Object.keys(source).reduce(function(acc, key) { - acc[key] = source[key]; - return acc; - }, target); - }, "assignSingleSource"); - var decode = /* @__PURE__ */ __name(function(str, defaultDecoder, charset) { - var strWithoutPlus = str.replace(/\+/g, " "); - if (charset === "iso-8859-1") { - return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); - } - try { - return decodeURIComponent(strWithoutPlus); - } catch (e) { - return strWithoutPlus; - } - }, "decode"); - var limit = 1024; - var encode = /* @__PURE__ */ __name(function encode2(str, defaultEncoder, charset, kind, format) { - if (str.length === 0) { - return str; - } - var string = str; - if (typeof str === "symbol") { - string = Symbol.prototype.toString.call(str); - } else if (typeof str !== "string") { - string = String(str); - } - if (charset === "iso-8859-1") { - return escape(string).replace(/%u[0-9a-f]{4}/gi, function($0) { - return "%26%23" + parseInt($0.slice(2), 16) + "%3B"; - }); - } - var out = ""; - for (var j = 0; j < string.length; j += limit) { - var segment = string.length >= limit ? string.slice(j, j + limit) : string; - var arr = []; - for (var i = 0; i < segment.length; ++i) { - var c = segment.charCodeAt(i); - if (c === 45 || c === 46 || c === 95 || c === 126 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || format === formats.RFC1738 && (c === 40 || c === 41)) { - arr[arr.length] = segment.charAt(i); - continue; - } - if (c < 128) { - arr[arr.length] = hexTable[c]; - continue; - } - if (c < 2048) { - arr[arr.length] = hexTable[192 | c >> 6] + hexTable[128 | c & 63]; - continue; - } - if (c < 55296 || c >= 57344) { - arr[arr.length] = hexTable[224 | c >> 12] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63]; - continue; - } - i += 1; - c = 65536 + ((c & 1023) << 10 | segment.charCodeAt(i) & 1023); - arr[arr.length] = hexTable[240 | c >> 18] + hexTable[128 | c >> 12 & 63] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63]; - } - out += arr.join(""); - } - return out; - }, "encode"); - var compact = /* @__PURE__ */ __name(function compact2(value) { - var queue = [{ obj: { o: value }, prop: "o" }]; - var refs = []; - for (var i = 0; i < queue.length; ++i) { - var item = queue[i]; - var obj = item.obj[item.prop]; - var keys = Object.keys(obj); - for (var j = 0; j < keys.length; ++j) { - var key = keys[j]; - var val = obj[key]; - if (typeof val === "object" && val !== null && refs.indexOf(val) === -1) { - queue.push({ obj, prop: key }); - refs.push(val); - } - } - } - compactQueue(queue); - return value; - }, "compact"); - var isRegExp = /* @__PURE__ */ __name(function isRegExp2(obj) { - return Object.prototype.toString.call(obj) === "[object RegExp]"; - }, "isRegExp"); - var isBuffer = /* @__PURE__ */ __name(function isBuffer2(obj) { - if (!obj || typeof obj !== "object") { - return false; - } - return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); - }, "isBuffer"); - var combine = /* @__PURE__ */ __name(function combine2(a, b) { - return [].concat(a, b); - }, "combine"); - var maybeMap = /* @__PURE__ */ __name(function maybeMap2(val, fn) { - if (isArray(val)) { - var mapped = []; - for (var i = 0; i < val.length; i += 1) { - mapped.push(fn(val[i])); - } - return mapped; - } - return fn(val); - }, "maybeMap"); - module.exports = { - arrayToObject, - assign, - combine, - compact, - decode, - encode, - isBuffer, - isRegExp, - maybeMap, - merge - }; - } -}); - -// node_modules/qs/lib/stringify.js -var require_stringify = __commonJS({ - "node_modules/qs/lib/stringify.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var getSideChannel = require_side_channel(); - var utils = require_utils(); - var formats = require_formats(); - var has = Object.prototype.hasOwnProperty; - var arrayPrefixGenerators = { - brackets: /* @__PURE__ */ __name(function brackets(prefix) { - return prefix + "[]"; - }, "brackets"), - comma: "comma", - indices: /* @__PURE__ */ __name(function indices(prefix, key) { - return prefix + "[" + key + "]"; - }, "indices"), - repeat: /* @__PURE__ */ __name(function repeat(prefix) { - return prefix; - }, "repeat") - }; - var isArray = Array.isArray; - var push = Array.prototype.push; - var pushToArray = /* @__PURE__ */ __name(function(arr, valueOrArray) { - push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]); - }, "pushToArray"); - var toISO = Date.prototype.toISOString; - var defaultFormat = formats["default"]; - var defaults = { - addQueryPrefix: false, - allowDots: false, - allowEmptyArrays: false, - arrayFormat: "indices", - charset: "utf-8", - charsetSentinel: false, - commaRoundTrip: false, - delimiter: "&", - encode: true, - encodeDotInKeys: false, - encoder: utils.encode, - encodeValuesOnly: false, - filter: void 0, - format: defaultFormat, - formatter: formats.formatters[defaultFormat], - // deprecated - indices: false, - serializeDate: /* @__PURE__ */ __name(function serializeDate(date) { - return toISO.call(date); - }, "serializeDate"), - skipNulls: false, - strictNullHandling: false - }; - var isNonNullishPrimitive = /* @__PURE__ */ __name(function isNonNullishPrimitive2(v) { - return typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "bigint"; - }, "isNonNullishPrimitive"); - var sentinel = {}; - var stringify2 = /* @__PURE__ */ __name(function stringify3(object, prefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) { - var obj = object; - var tmpSc = sideChannel; - var step = 0; - var findFlag = false; - while ((tmpSc = tmpSc.get(sentinel)) !== void 0 && !findFlag) { - var pos = tmpSc.get(object); - step += 1; - if (typeof pos !== "undefined") { - if (pos === step) { - throw new RangeError("Cyclic object value"); - } else { - findFlag = true; - } - } - if (typeof tmpSc.get(sentinel) === "undefined") { - step = 0; - } - } - if (typeof filter === "function") { - obj = filter(prefix, obj); - } else if (obj instanceof Date) { - obj = serializeDate(obj); - } else if (generateArrayPrefix === "comma" && isArray(obj)) { - obj = utils.maybeMap(obj, function(value2) { - if (value2 instanceof Date) { - return serializeDate(value2); - } - return value2; - }); - } - if (obj === null) { - if (strictNullHandling) { - return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, "key", format) : prefix; - } - obj = ""; - } - if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) { - if (encoder) { - var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, "key", format); - return [formatter(keyValue) + "=" + formatter(encoder(obj, defaults.encoder, charset, "value", format))]; - } - return [formatter(prefix) + "=" + formatter(String(obj))]; - } - var values = []; - if (typeof obj === "undefined") { - return values; - } - var objKeys; - if (generateArrayPrefix === "comma" && isArray(obj)) { - if (encodeValuesOnly && encoder) { - obj = utils.maybeMap(obj, encoder); - } - objKeys = [{ value: obj.length > 0 ? obj.join(",") || null : void 0 }]; - } else if (isArray(filter)) { - objKeys = filter; - } else { - var keys = Object.keys(obj); - objKeys = sort ? keys.sort(sort) : keys; - } - var encodedPrefix = encodeDotInKeys ? String(prefix).replace(/\./g, "%2E") : String(prefix); - var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? encodedPrefix + "[]" : encodedPrefix; - if (allowEmptyArrays && isArray(obj) && obj.length === 0) { - return adjustedPrefix + "[]"; - } - for (var j = 0; j < objKeys.length; ++j) { - var key = objKeys[j]; - var value = typeof key === "object" && key && typeof key.value !== "undefined" ? key.value : obj[key]; - if (skipNulls && value === null) { - continue; - } - var encodedKey = allowDots && encodeDotInKeys ? String(key).replace(/\./g, "%2E") : String(key); - var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === "function" ? generateArrayPrefix(adjustedPrefix, encodedKey) : adjustedPrefix : adjustedPrefix + (allowDots ? "." + encodedKey : "[" + encodedKey + "]"); - sideChannel.set(object, step); - var valueSideChannel = getSideChannel(); - valueSideChannel.set(sentinel, sideChannel); - pushToArray(values, stringify3( - value, - keyPrefix, - generateArrayPrefix, - commaRoundTrip, - allowEmptyArrays, - strictNullHandling, - skipNulls, - encodeDotInKeys, - generateArrayPrefix === "comma" && encodeValuesOnly && isArray(obj) ? null : encoder, - filter, - sort, - allowDots, - serializeDate, - format, - formatter, - encodeValuesOnly, - charset, - valueSideChannel - )); - } - return values; - }, "stringify"); - var normalizeStringifyOptions = /* @__PURE__ */ __name(function normalizeStringifyOptions2(opts) { - if (!opts) { - return defaults; - } - if (typeof opts.allowEmptyArrays !== "undefined" && typeof opts.allowEmptyArrays !== "boolean") { - throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided"); - } - if (typeof opts.encodeDotInKeys !== "undefined" && typeof opts.encodeDotInKeys !== "boolean") { - throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided"); - } - if (opts.encoder !== null && typeof opts.encoder !== "undefined" && typeof opts.encoder !== "function") { - throw new TypeError("Encoder has to be a function."); - } - var charset = opts.charset || defaults.charset; - if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") { - throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined"); - } - var format = formats["default"]; - if (typeof opts.format !== "undefined") { - if (!has.call(formats.formatters, opts.format)) { - throw new TypeError("Unknown format option provided."); - } - format = opts.format; - } - var formatter = formats.formatters[format]; - var filter = defaults.filter; - if (typeof opts.filter === "function" || isArray(opts.filter)) { - filter = opts.filter; - } - var arrayFormat; - if (opts.arrayFormat in arrayPrefixGenerators) { - arrayFormat = opts.arrayFormat; - } else if ("indices" in opts) { - arrayFormat = opts.indices ? "indices" : "repeat"; - } else { - arrayFormat = defaults.arrayFormat; - } - if ("commaRoundTrip" in opts && typeof opts.commaRoundTrip !== "boolean") { - throw new TypeError("`commaRoundTrip` must be a boolean, or absent"); - } - var allowDots = typeof opts.allowDots === "undefined" ? opts.encodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots; - return { - addQueryPrefix: typeof opts.addQueryPrefix === "boolean" ? opts.addQueryPrefix : defaults.addQueryPrefix, - allowDots, - allowEmptyArrays: typeof opts.allowEmptyArrays === "boolean" ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays, - arrayFormat, - charset, - charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults.charsetSentinel, - commaRoundTrip: !!opts.commaRoundTrip, - delimiter: typeof opts.delimiter === "undefined" ? defaults.delimiter : opts.delimiter, - encode: typeof opts.encode === "boolean" ? opts.encode : defaults.encode, - encodeDotInKeys: typeof opts.encodeDotInKeys === "boolean" ? opts.encodeDotInKeys : defaults.encodeDotInKeys, - encoder: typeof opts.encoder === "function" ? opts.encoder : defaults.encoder, - encodeValuesOnly: typeof opts.encodeValuesOnly === "boolean" ? opts.encodeValuesOnly : defaults.encodeValuesOnly, - filter, - format, - formatter, - serializeDate: typeof opts.serializeDate === "function" ? opts.serializeDate : defaults.serializeDate, - skipNulls: typeof opts.skipNulls === "boolean" ? opts.skipNulls : defaults.skipNulls, - sort: typeof opts.sort === "function" ? opts.sort : null, - strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults.strictNullHandling - }; - }, "normalizeStringifyOptions"); - module.exports = function(object, opts) { - var obj = object; - var options = normalizeStringifyOptions(opts); - var objKeys; - var filter; - if (typeof options.filter === "function") { - filter = options.filter; - obj = filter("", obj); - } else if (isArray(options.filter)) { - filter = options.filter; - objKeys = filter; - } - var keys = []; - if (typeof obj !== "object" || obj === null) { - return ""; - } - var generateArrayPrefix = arrayPrefixGenerators[options.arrayFormat]; - var commaRoundTrip = generateArrayPrefix === "comma" && options.commaRoundTrip; - if (!objKeys) { - objKeys = Object.keys(obj); - } - if (options.sort) { - objKeys.sort(options.sort); - } - var sideChannel = getSideChannel(); - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; - var value = obj[key]; - if (options.skipNulls && value === null) { - continue; - } - pushToArray(keys, stringify2( - value, - key, - generateArrayPrefix, - commaRoundTrip, - options.allowEmptyArrays, - options.strictNullHandling, - options.skipNulls, - options.encodeDotInKeys, - options.encode ? options.encoder : null, - options.filter, - options.sort, - options.allowDots, - options.serializeDate, - options.format, - options.formatter, - options.encodeValuesOnly, - options.charset, - sideChannel - )); - } - var joined = keys.join(options.delimiter); - var prefix = options.addQueryPrefix === true ? "?" : ""; - if (options.charsetSentinel) { - if (options.charset === "iso-8859-1") { - prefix += "utf8=%26%2310003%3B&"; - } else { - prefix += "utf8=%E2%9C%93&"; - } - } - return joined.length > 0 ? prefix + joined : ""; - }; - } -}); - -// node_modules/qs/lib/parse.js -var require_parse = __commonJS({ - "node_modules/qs/lib/parse.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var utils = require_utils(); - var has = Object.prototype.hasOwnProperty; - var isArray = Array.isArray; - var defaults = { - allowDots: false, - allowEmptyArrays: false, - allowPrototypes: false, - allowSparse: false, - arrayLimit: 20, - charset: "utf-8", - charsetSentinel: false, - comma: false, - decodeDotInKeys: false, - decoder: utils.decode, - delimiter: "&", - depth: 5, - duplicates: "combine", - ignoreQueryPrefix: false, - interpretNumericEntities: false, - parameterLimit: 1e3, - parseArrays: true, - plainObjects: false, - strictDepth: false, - strictNullHandling: false, - throwOnLimitExceeded: false - }; - var interpretNumericEntities = /* @__PURE__ */ __name(function(str) { - return str.replace(/&#(\d+);/g, function($0, numberStr) { - return String.fromCharCode(parseInt(numberStr, 10)); - }); - }, "interpretNumericEntities"); - var parseArrayValue = /* @__PURE__ */ __name(function(val, options, currentArrayLength) { - if (val && typeof val === "string" && options.comma && val.indexOf(",") > -1) { - return val.split(","); - } - if (options.throwOnLimitExceeded && currentArrayLength >= options.arrayLimit) { - throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array."); - } - return val; - }, "parseArrayValue"); - var isoSentinel = "utf8=%26%2310003%3B"; - var charsetSentinel = "utf8=%E2%9C%93"; - var parseValues = /* @__PURE__ */ __name(function parseQueryStringValues(str, options) { - var obj = { __proto__: null }; - var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, "") : str; - cleanStr = cleanStr.replace(/%5B/gi, "[").replace(/%5D/gi, "]"); - var limit = options.parameterLimit === Infinity ? void 0 : options.parameterLimit; - var parts = cleanStr.split( - options.delimiter, - options.throwOnLimitExceeded ? limit + 1 : limit - ); - if (options.throwOnLimitExceeded && parts.length > limit) { - throw new RangeError("Parameter limit exceeded. Only " + limit + " parameter" + (limit === 1 ? "" : "s") + " allowed."); - } - var skipIndex = -1; - var i; - var charset = options.charset; - if (options.charsetSentinel) { - for (i = 0; i < parts.length; ++i) { - if (parts[i].indexOf("utf8=") === 0) { - if (parts[i] === charsetSentinel) { - charset = "utf-8"; - } else if (parts[i] === isoSentinel) { - charset = "iso-8859-1"; - } - skipIndex = i; - i = parts.length; - } - } - } - for (i = 0; i < parts.length; ++i) { - if (i === skipIndex) { - continue; - } - var part = parts[i]; - var bracketEqualsPos = part.indexOf("]="); - var pos = bracketEqualsPos === -1 ? part.indexOf("=") : bracketEqualsPos + 1; - var key; - var val; - if (pos === -1) { - key = options.decoder(part, defaults.decoder, charset, "key"); - val = options.strictNullHandling ? null : ""; - } else { - key = options.decoder(part.slice(0, pos), defaults.decoder, charset, "key"); - val = utils.maybeMap( - parseArrayValue( - part.slice(pos + 1), - options, - isArray(obj[key]) ? obj[key].length : 0 - ), - function(encodedVal) { - return options.decoder(encodedVal, defaults.decoder, charset, "value"); - } - ); - } - if (val && options.interpretNumericEntities && charset === "iso-8859-1") { - val = interpretNumericEntities(String(val)); - } - if (part.indexOf("[]=") > -1) { - val = isArray(val) ? [val] : val; - } - var existing = has.call(obj, key); - if (existing && options.duplicates === "combine") { - obj[key] = utils.combine(obj[key], val); - } else if (!existing || options.duplicates === "last") { - obj[key] = val; - } - } - return obj; - }, "parseQueryStringValues"); - var parseObject = /* @__PURE__ */ __name(function(chain, val, options, valuesParsed) { - var currentArrayLength = 0; - if (chain.length > 0 && chain[chain.length - 1] === "[]") { - var parentKey = chain.slice(0, -1).join(""); - currentArrayLength = Array.isArray(val) && val[parentKey] ? val[parentKey].length : 0; - } - var leaf = valuesParsed ? val : parseArrayValue(val, options, currentArrayLength); - for (var i = chain.length - 1; i >= 0; --i) { - var obj; - var root = chain[i]; - if (root === "[]" && options.parseArrays) { - obj = options.allowEmptyArrays && (leaf === "" || options.strictNullHandling && leaf === null) ? [] : utils.combine([], leaf); - } else { - obj = options.plainObjects ? { __proto__: null } : {}; - var cleanRoot = root.charAt(0) === "[" && root.charAt(root.length - 1) === "]" ? root.slice(1, -1) : root; - var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, ".") : cleanRoot; - var index = parseInt(decodedRoot, 10); - if (!options.parseArrays && decodedRoot === "") { - obj = { 0: leaf }; - } else if (!isNaN(index) && root !== decodedRoot && String(index) === decodedRoot && index >= 0 && (options.parseArrays && index <= options.arrayLimit)) { - obj = []; - obj[index] = leaf; - } else if (decodedRoot !== "__proto__") { - obj[decodedRoot] = leaf; - } - } - leaf = obj; - } - return leaf; - }, "parseObject"); - var parseKeys = /* @__PURE__ */ __name(function parseQueryStringKeys(givenKey, val, options, valuesParsed) { - if (!givenKey) { - return; - } - var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, "[$1]") : givenKey; - var brackets = /(\[[^[\]]*])/; - var child = /(\[[^[\]]*])/g; - var segment = options.depth > 0 && brackets.exec(key); - var parent = segment ? key.slice(0, segment.index) : key; - var keys = []; - if (parent) { - if (!options.plainObjects && has.call(Object.prototype, parent)) { - if (!options.allowPrototypes) { - return; - } - } - keys.push(parent); - } - var i = 0; - while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) { - i += 1; - if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { - if (!options.allowPrototypes) { - return; - } - } - keys.push(segment[1]); - } - if (segment) { - if (options.strictDepth === true) { - throw new RangeError("Input depth exceeded depth option of " + options.depth + " and strictDepth is true"); - } - keys.push("[" + key.slice(segment.index) + "]"); - } - return parseObject(keys, val, options, valuesParsed); - }, "parseQueryStringKeys"); - var normalizeParseOptions = /* @__PURE__ */ __name(function normalizeParseOptions2(opts) { - if (!opts) { - return defaults; - } - if (typeof opts.allowEmptyArrays !== "undefined" && typeof opts.allowEmptyArrays !== "boolean") { - throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided"); - } - if (typeof opts.decodeDotInKeys !== "undefined" && typeof opts.decodeDotInKeys !== "boolean") { - throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided"); - } - if (opts.decoder !== null && typeof opts.decoder !== "undefined" && typeof opts.decoder !== "function") { - throw new TypeError("Decoder has to be a function."); - } - if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") { - throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined"); - } - if (typeof opts.throwOnLimitExceeded !== "undefined" && typeof opts.throwOnLimitExceeded !== "boolean") { - throw new TypeError("`throwOnLimitExceeded` option must be a boolean"); - } - var charset = typeof opts.charset === "undefined" ? defaults.charset : opts.charset; - var duplicates = typeof opts.duplicates === "undefined" ? defaults.duplicates : opts.duplicates; - if (duplicates !== "combine" && duplicates !== "first" && duplicates !== "last") { - throw new TypeError("The duplicates option must be either combine, first, or last"); - } - var allowDots = typeof opts.allowDots === "undefined" ? opts.decodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots; - return { - allowDots, - allowEmptyArrays: typeof opts.allowEmptyArrays === "boolean" ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays, - allowPrototypes: typeof opts.allowPrototypes === "boolean" ? opts.allowPrototypes : defaults.allowPrototypes, - allowSparse: typeof opts.allowSparse === "boolean" ? opts.allowSparse : defaults.allowSparse, - arrayLimit: typeof opts.arrayLimit === "number" ? opts.arrayLimit : defaults.arrayLimit, - charset, - charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults.charsetSentinel, - comma: typeof opts.comma === "boolean" ? opts.comma : defaults.comma, - decodeDotInKeys: typeof opts.decodeDotInKeys === "boolean" ? opts.decodeDotInKeys : defaults.decodeDotInKeys, - decoder: typeof opts.decoder === "function" ? opts.decoder : defaults.decoder, - delimiter: typeof opts.delimiter === "string" || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter, - // eslint-disable-next-line no-implicit-coercion, no-extra-parens - depth: typeof opts.depth === "number" || opts.depth === false ? +opts.depth : defaults.depth, - duplicates, - ignoreQueryPrefix: opts.ignoreQueryPrefix === true, - interpretNumericEntities: typeof opts.interpretNumericEntities === "boolean" ? opts.interpretNumericEntities : defaults.interpretNumericEntities, - parameterLimit: typeof opts.parameterLimit === "number" ? opts.parameterLimit : defaults.parameterLimit, - parseArrays: opts.parseArrays !== false, - plainObjects: typeof opts.plainObjects === "boolean" ? opts.plainObjects : defaults.plainObjects, - strictDepth: typeof opts.strictDepth === "boolean" ? !!opts.strictDepth : defaults.strictDepth, - strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults.strictNullHandling, - throwOnLimitExceeded: typeof opts.throwOnLimitExceeded === "boolean" ? opts.throwOnLimitExceeded : false - }; - }, "normalizeParseOptions"); - module.exports = function(str, opts) { - var options = normalizeParseOptions(opts); - if (str === "" || str === null || typeof str === "undefined") { - return options.plainObjects ? { __proto__: null } : {}; - } - var tempObj = typeof str === "string" ? parseValues(str, options) : str; - var obj = options.plainObjects ? { __proto__: null } : {}; - var keys = Object.keys(tempObj); - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; - var newObj = parseKeys(key, tempObj[key], options, typeof str === "string"); - obj = utils.merge(obj, newObj, options); - } - if (options.allowSparse === true) { - return obj; - } - return utils.compact(obj); - }; - } -}); - -// node_modules/qs/lib/index.js -var require_lib = __commonJS({ - "node_modules/qs/lib/index.js"(exports, module) { - "use strict"; - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); - init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); - init_performance2(); - var stringify2 = require_stringify(); - var parse = require_parse(); - var formats = require_formats(); - module.exports = { - formats, - parse, - stringify: stringify2 - }; - } -}); - -// src/worker.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/index.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/hono.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/hono-base.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/compose.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var compose = /* @__PURE__ */ __name((middleware, onError, onNotFound) => { - return (context2, next) => { - let index = -1; - return dispatch(0); - async function dispatch(i) { - if (i <= index) { - throw new Error("next() called multiple times"); - } - index = i; - let res; - let isError = false; - let handler; - if (middleware[i]) { - handler = middleware[i][0][0]; - context2.req.routeIndex = i; - } else { - handler = i === middleware.length && next || void 0; - } - if (handler) { - try { - res = await handler(context2, () => dispatch(i + 1)); - } catch (err) { - if (err instanceof Error && onError) { - context2.error = err; - res = await onError(err, context2); - isError = true; - } else { - throw err; - } - } - } else { - if (context2.finalized === false && onNotFound) { - res = await onNotFound(context2); - } - } - if (res && (context2.finalized === false || isError)) { - context2.res = res; - } - return context2; - } - __name(dispatch, "dispatch"); - }; -}, "compose"); - -// node_modules/hono/dist/context.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/request.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/request/constants.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var GET_MATCH_RESULT = Symbol(); - -// node_modules/hono/dist/utils/body.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var parseBody = /* @__PURE__ */ __name(async (request, options = /* @__PURE__ */ Object.create(null)) => { - const { all = false, dot = false } = options; - const headers = request instanceof HonoRequest ? request.raw.headers : request.headers; - const contentType = headers.get("Content-Type"); - if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) { - return parseFormData(request, { all, dot }); - } - return {}; -}, "parseBody"); -async function parseFormData(request, options) { - const formData = await request.formData(); - if (formData) { - return convertFormDataToBodyData(formData, options); - } - return {}; -} -__name(parseFormData, "parseFormData"); -function convertFormDataToBodyData(formData, options) { - const form = /* @__PURE__ */ Object.create(null); - formData.forEach((value, key) => { - const shouldParseAllValues = options.all || key.endsWith("[]"); - if (!shouldParseAllValues) { - form[key] = value; - } else { - handleParsingAllValues(form, key, value); - } - }); - if (options.dot) { - Object.entries(form).forEach(([key, value]) => { - const shouldParseDotValues = key.includes("."); - if (shouldParseDotValues) { - handleParsingNestedValues(form, key, value); - delete form[key]; - } - }); - } - return form; -} -__name(convertFormDataToBodyData, "convertFormDataToBodyData"); -var handleParsingAllValues = /* @__PURE__ */ __name((form, key, value) => { - if (form[key] !== void 0) { - if (Array.isArray(form[key])) { - ; - form[key].push(value); - } else { - form[key] = [form[key], value]; - } - } else { - if (!key.endsWith("[]")) { - form[key] = value; - } else { - form[key] = [value]; - } - } -}, "handleParsingAllValues"); -var handleParsingNestedValues = /* @__PURE__ */ __name((form, key, value) => { - let nestedForm = form; - const keys = key.split("."); - keys.forEach((key2, index) => { - if (index === keys.length - 1) { - nestedForm[key2] = value; - } else { - if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) { - nestedForm[key2] = /* @__PURE__ */ Object.create(null); - } - nestedForm = nestedForm[key2]; - } - }); -}, "handleParsingNestedValues"); - -// node_modules/hono/dist/utils/url.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var splitPath = /* @__PURE__ */ __name((path) => { - const paths = path.split("/"); - if (paths[0] === "") { - paths.shift(); - } - return paths; -}, "splitPath"); -var splitRoutingPath = /* @__PURE__ */ __name((routePath) => { - const { groups, path } = extractGroupsFromPath(routePath); - const paths = splitPath(path); - return replaceGroupMarks(paths, groups); -}, "splitRoutingPath"); -var extractGroupsFromPath = /* @__PURE__ */ __name((path) => { - const groups = []; - path = path.replace(/\{[^}]+\}/g, (match, index) => { - const mark = `@${index}`; - groups.push([mark, match]); - return mark; - }); - return { groups, path }; -}, "extractGroupsFromPath"); -var replaceGroupMarks = /* @__PURE__ */ __name((paths, groups) => { - for (let i = groups.length - 1; i >= 0; i--) { - const [mark] = groups[i]; - for (let j = paths.length - 1; j >= 0; j--) { - if (paths[j].includes(mark)) { - paths[j] = paths[j].replace(mark, groups[i][1]); - break; - } - } - } - return paths; -}, "replaceGroupMarks"); -var patternCache = {}; -var getPattern = /* @__PURE__ */ __name((label, next) => { - if (label === "*") { - return "*"; - } - const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/); - if (match) { - const cacheKey = `${label}#${next}`; - if (!patternCache[cacheKey]) { - if (match[2]) { - patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [cacheKey, match[1], new RegExp(`^${match[2]}(?=/${next})`)] : [label, match[1], new RegExp(`^${match[2]}$`)]; - } else { - patternCache[cacheKey] = [label, match[1], true]; - } - } - return patternCache[cacheKey]; - } - return null; -}, "getPattern"); -var tryDecode = /* @__PURE__ */ __name((str, decoder) => { - try { - return decoder(str); - } catch { - return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => { - try { - return decoder(match); - } catch { - return match; - } - }); - } -}, "tryDecode"); -var tryDecodeURI = /* @__PURE__ */ __name((str) => tryDecode(str, decodeURI), "tryDecodeURI"); -var getPath = /* @__PURE__ */ __name((request) => { - const url = request.url; - const start = url.indexOf("/", url.indexOf(":") + 4); - let i = start; - for (; i < url.length; i++) { - const charCode = url.charCodeAt(i); - if (charCode === 37) { - const queryIndex = url.indexOf("?", i); - const path = url.slice(start, queryIndex === -1 ? void 0 : queryIndex); - return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path); - } else if (charCode === 63) { - break; - } - } - return url.slice(start, i); -}, "getPath"); -var getPathNoStrict = /* @__PURE__ */ __name((request) => { - const result = getPath(request); - return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result; -}, "getPathNoStrict"); -var mergePath = /* @__PURE__ */ __name((base, sub, ...rest) => { - if (rest.length) { - sub = mergePath(sub, ...rest); - } - return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`; -}, "mergePath"); -var checkOptionalParameter = /* @__PURE__ */ __name((path) => { - if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) { - return null; - } - const segments = path.split("/"); - const results = []; - let basePath = ""; - segments.forEach((segment) => { - if (segment !== "" && !/\:/.test(segment)) { - basePath += "/" + segment; - } else if (/\:/.test(segment)) { - if (/\?/.test(segment)) { - if (results.length === 0 && basePath === "") { - results.push("/"); - } else { - results.push(basePath); - } - const optionalSegment = segment.replace("?", ""); - basePath += "/" + optionalSegment; - results.push(basePath); - } else { - basePath += "/" + segment; - } - } - }); - return results.filter((v, i, a) => a.indexOf(v) === i); -}, "checkOptionalParameter"); -var _decodeURI = /* @__PURE__ */ __name((value) => { - if (!/[%+]/.test(value)) { - return value; - } - if (value.indexOf("+") !== -1) { - value = value.replace(/\+/g, " "); - } - return value.indexOf("%") !== -1 ? tryDecode(value, decodeURIComponent_) : value; -}, "_decodeURI"); -var _getQueryParam = /* @__PURE__ */ __name((url, key, multiple) => { - let encoded; - if (!multiple && key && !/[%+]/.test(key)) { - let keyIndex2 = url.indexOf(`?${key}`, 8); - if (keyIndex2 === -1) { - keyIndex2 = url.indexOf(`&${key}`, 8); - } - while (keyIndex2 !== -1) { - const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1); - if (trailingKeyCode === 61) { - const valueIndex = keyIndex2 + key.length + 2; - const endIndex = url.indexOf("&", valueIndex); - return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex)); - } else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) { - return ""; - } - keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1); - } - encoded = /[%+]/.test(url); - if (!encoded) { - return void 0; - } - } - const results = {}; - encoded ??= /[%+]/.test(url); - let keyIndex = url.indexOf("?", 8); - while (keyIndex !== -1) { - const nextKeyIndex = url.indexOf("&", keyIndex + 1); - let valueIndex = url.indexOf("=", keyIndex); - if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) { - valueIndex = -1; - } - let name = url.slice( - keyIndex + 1, - valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex - ); - if (encoded) { - name = _decodeURI(name); - } - keyIndex = nextKeyIndex; - if (name === "") { - continue; - } - let value; - if (valueIndex === -1) { - value = ""; - } else { - value = url.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex); - if (encoded) { - value = _decodeURI(value); - } - } - if (multiple) { - if (!(results[name] && Array.isArray(results[name]))) { - results[name] = []; - } - ; - results[name].push(value); - } else { - results[name] ??= value; - } - } - return key ? results[key] : results; -}, "_getQueryParam"); -var getQueryParam = _getQueryParam; -var getQueryParams = /* @__PURE__ */ __name((url, key) => { - return _getQueryParam(url, key, true); -}, "getQueryParams"); -var decodeURIComponent_ = decodeURIComponent; - -// node_modules/hono/dist/request.js -var tryDecodeURIComponent = /* @__PURE__ */ __name((str) => tryDecode(str, decodeURIComponent_), "tryDecodeURIComponent"); -var HonoRequest = class { - static { - __name(this, "HonoRequest"); - } - raw; - #validatedData; - #matchResult; - routeIndex = 0; - path; - bodyCache = {}; - constructor(request, path = "/", matchResult = [[]]) { - this.raw = request; - this.path = path; - this.#matchResult = matchResult; - this.#validatedData = {}; - } - param(key) { - return key ? this.#getDecodedParam(key) : this.#getAllDecodedParams(); - } - #getDecodedParam(key) { - const paramKey = this.#matchResult[0][this.routeIndex][1][key]; - const param = this.#getParamValue(paramKey); - return param ? /\%/.test(param) ? tryDecodeURIComponent(param) : param : void 0; - } - #getAllDecodedParams() { - const decoded = {}; - const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]); - for (const key of keys) { - const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]); - if (value && typeof value === "string") { - decoded[key] = /\%/.test(value) ? tryDecodeURIComponent(value) : value; - } - } - return decoded; - } - #getParamValue(paramKey) { - return this.#matchResult[1] ? this.#matchResult[1][paramKey] : paramKey; - } - query(key) { - return getQueryParam(this.url, key); - } - queries(key) { - return getQueryParams(this.url, key); - } - header(name) { - if (name) { - return this.raw.headers.get(name) ?? void 0; - } - const headerData = {}; - this.raw.headers.forEach((value, key) => { - headerData[key] = value; - }); - return headerData; - } - async parseBody(options) { - return this.bodyCache.parsedBody ??= await parseBody(this, options); - } - #cachedBody = /* @__PURE__ */ __name((key) => { - const { bodyCache, raw: raw2 } = this; - const cachedBody = bodyCache[key]; - if (cachedBody) { - return cachedBody; - } - const anyCachedKey = Object.keys(bodyCache)[0]; - if (anyCachedKey) { - return bodyCache[anyCachedKey].then((body) => { - if (anyCachedKey === "json") { - body = JSON.stringify(body); - } - return new Response(body)[key](); - }); - } - return bodyCache[key] = raw2[key](); - }, "#cachedBody"); - json() { - return this.#cachedBody("text").then((text) => JSON.parse(text)); - } - text() { - return this.#cachedBody("text"); - } - arrayBuffer() { - return this.#cachedBody("arrayBuffer"); - } - blob() { - return this.#cachedBody("blob"); - } - formData() { - return this.#cachedBody("formData"); - } - addValidatedData(target, data) { - this.#validatedData[target] = data; - } - valid(target) { - return this.#validatedData[target]; - } - get url() { - return this.raw.url; - } - get method() { - return this.raw.method; - } - get [GET_MATCH_RESULT]() { - return this.#matchResult; - } - get matchedRoutes() { - return this.#matchResult[0].map(([[, route]]) => route); - } - get routePath() { - return this.#matchResult[0].map(([[, route]]) => route)[this.routeIndex].path; - } -}; - -// node_modules/hono/dist/utils/html.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var HtmlEscapedCallbackPhase = { - Stringify: 1, - BeforeStream: 2, - Stream: 3 -}; -var raw = /* @__PURE__ */ __name((value, callbacks) => { - const escapedString = new String(value); - escapedString.isEscaped = true; - escapedString.callbacks = callbacks; - return escapedString; -}, "raw"); -var resolveCallback = /* @__PURE__ */ __name(async (str, phase, preserveCallbacks, context2, buffer) => { - if (typeof str === "object" && !(str instanceof String)) { - if (!(str instanceof Promise)) { - str = str.toString(); - } - if (str instanceof Promise) { - str = await str; - } - } - const callbacks = str.callbacks; - if (!callbacks?.length) { - return Promise.resolve(str); - } - if (buffer) { - buffer[0] += str; - } else { - buffer = [str]; - } - const resStr = Promise.all(callbacks.map((c) => c({ phase, buffer, context: context2 }))).then( - (res) => Promise.all( - res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context2, buffer)) - ).then(() => buffer[0]) - ); - if (preserveCallbacks) { - return raw(await resStr, callbacks); - } else { - return resStr; - } -}, "resolveCallback"); - -// node_modules/hono/dist/context.js -var TEXT_PLAIN = "text/plain; charset=UTF-8"; -var setDefaultContentType = /* @__PURE__ */ __name((contentType, headers) => { - return { - "Content-Type": contentType, - ...headers - }; -}, "setDefaultContentType"); -var Context = class { - static { - __name(this, "Context"); - } - #rawRequest; - #req; - env = {}; - #var; - finalized = false; - error; - #status; - #executionCtx; - #res; - #layout; - #renderer; - #notFoundHandler; - #preparedHeaders; - #matchResult; - #path; - constructor(req, options) { - this.#rawRequest = req; - if (options) { - this.#executionCtx = options.executionCtx; - this.env = options.env; - this.#notFoundHandler = options.notFoundHandler; - this.#path = options.path; - this.#matchResult = options.matchResult; - } - } - get req() { - this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult); - return this.#req; - } - get event() { - if (this.#executionCtx && "respondWith" in this.#executionCtx) { - return this.#executionCtx; - } else { - throw Error("This context has no FetchEvent"); - } - } - get executionCtx() { - if (this.#executionCtx) { - return this.#executionCtx; - } else { - throw Error("This context has no ExecutionContext"); - } - } - get res() { - return this.#res ||= new Response(null, { - headers: this.#preparedHeaders ??= new Headers() - }); - } - set res(_res) { - if (this.#res && _res) { - _res = new Response(_res.body, _res); - for (const [k, v] of this.#res.headers.entries()) { - if (k === "content-type") { - continue; - } - if (k === "set-cookie") { - const cookies = this.#res.headers.getSetCookie(); - _res.headers.delete("set-cookie"); - for (const cookie of cookies) { - _res.headers.append("set-cookie", cookie); - } - } else { - _res.headers.set(k, v); - } - } - } - this.#res = _res; - this.finalized = true; - } - render = /* @__PURE__ */ __name((...args) => { - this.#renderer ??= (content) => this.html(content); - return this.#renderer(...args); - }, "render"); - setLayout = /* @__PURE__ */ __name((layout) => this.#layout = layout, "setLayout"); - getLayout = /* @__PURE__ */ __name(() => this.#layout, "getLayout"); - setRenderer = /* @__PURE__ */ __name((renderer) => { - this.#renderer = renderer; - }, "setRenderer"); - header = /* @__PURE__ */ __name((name, value, options) => { - if (this.finalized) { - this.#res = new Response(this.#res.body, this.#res); - } - const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers(); - if (value === void 0) { - headers.delete(name); - } else if (options?.append) { - headers.append(name, value); - } else { - headers.set(name, value); - } - }, "header"); - status = /* @__PURE__ */ __name((status) => { - this.#status = status; - }, "status"); - set = /* @__PURE__ */ __name((key, value) => { - this.#var ??= /* @__PURE__ */ new Map(); - this.#var.set(key, value); - }, "set"); - get = /* @__PURE__ */ __name((key) => { - return this.#var ? this.#var.get(key) : void 0; - }, "get"); - get var() { - if (!this.#var) { - return {}; - } - return Object.fromEntries(this.#var); - } - #newResponse(data, arg, headers) { - const responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders ?? new Headers(); - if (typeof arg === "object" && "headers" in arg) { - const argHeaders = arg.headers instanceof Headers ? arg.headers : new Headers(arg.headers); - for (const [key, value] of argHeaders) { - if (key.toLowerCase() === "set-cookie") { - responseHeaders.append(key, value); - } else { - responseHeaders.set(key, value); - } - } - } - if (headers) { - for (const [k, v] of Object.entries(headers)) { - if (typeof v === "string") { - responseHeaders.set(k, v); - } else { - responseHeaders.delete(k); - for (const v2 of v) { - responseHeaders.append(k, v2); - } - } - } - } - const status = typeof arg === "number" ? arg : arg?.status ?? this.#status; - return new Response(data, { status, headers: responseHeaders }); - } - newResponse = /* @__PURE__ */ __name((...args) => this.#newResponse(...args), "newResponse"); - body = /* @__PURE__ */ __name((data, arg, headers) => this.#newResponse(data, arg, headers), "body"); - text = /* @__PURE__ */ __name((text, arg, headers) => { - return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse( - text, - arg, - setDefaultContentType(TEXT_PLAIN, headers) - ); - }, "text"); - json = /* @__PURE__ */ __name((object, arg, headers) => { - return this.#newResponse( - JSON.stringify(object), - arg, - setDefaultContentType("application/json", headers) - ); - }, "json"); - html = /* @__PURE__ */ __name((html, arg, headers) => { - const res = /* @__PURE__ */ __name((html2) => this.#newResponse(html2, arg, setDefaultContentType("text/html; charset=UTF-8", headers)), "res"); - return typeof html === "object" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html); - }, "html"); - redirect = /* @__PURE__ */ __name((location, status) => { - const locationString = String(location); - this.header( - "Location", - !/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString) - ); - return this.newResponse(null, status ?? 302); - }, "redirect"); - notFound = /* @__PURE__ */ __name(() => { - this.#notFoundHandler ??= () => new Response(); - return this.#notFoundHandler(this); - }, "notFound"); -}; - -// node_modules/hono/dist/router.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var METHOD_NAME_ALL = "ALL"; -var METHOD_NAME_ALL_LOWERCASE = "all"; -var METHODS = ["get", "post", "put", "delete", "options", "patch"]; -var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built."; -var UnsupportedPathError = class extends Error { - static { - __name(this, "UnsupportedPathError"); - } -}; - -// node_modules/hono/dist/utils/constants.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var COMPOSED_HANDLER = "__COMPOSED_HANDLER"; - -// node_modules/hono/dist/hono-base.js -var notFoundHandler = /* @__PURE__ */ __name((c) => { - return c.text("404 Not Found", 404); -}, "notFoundHandler"); -var errorHandler = /* @__PURE__ */ __name((err, c) => { - if ("getResponse" in err) { - const res = err.getResponse(); - return c.newResponse(res.body, res); - } - console.error(err); - return c.text("Internal Server Error", 500); -}, "errorHandler"); -var Hono = class { - static { - __name(this, "Hono"); - } - get; - post; - put; - delete; - options; - patch; - all; - on; - use; - router; - getPath; - _basePath = "/"; - #path = "/"; - routes = []; - constructor(options = {}) { - const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE]; - allMethods.forEach((method) => { - this[method] = (args1, ...args) => { - if (typeof args1 === "string") { - this.#path = args1; - } else { - this.#addRoute(method, this.#path, args1); - } - args.forEach((handler) => { - this.#addRoute(method, this.#path, handler); - }); - return this; - }; - }); - this.on = (method, path, ...handlers) => { - for (const p of [path].flat()) { - this.#path = p; - for (const m of [method].flat()) { - handlers.map((handler) => { - this.#addRoute(m.toUpperCase(), this.#path, handler); - }); - } - } - return this; - }; - this.use = (arg1, ...handlers) => { - if (typeof arg1 === "string") { - this.#path = arg1; - } else { - this.#path = "*"; - handlers.unshift(arg1); - } - handlers.forEach((handler) => { - this.#addRoute(METHOD_NAME_ALL, this.#path, handler); - }); - return this; - }; - const { strict, ...optionsWithoutStrict } = options; - Object.assign(this, optionsWithoutStrict); - this.getPath = strict ?? true ? options.getPath ?? getPath : getPathNoStrict; - } - #clone() { - const clone = new Hono({ - router: this.router, - getPath: this.getPath - }); - clone.errorHandler = this.errorHandler; - clone.#notFoundHandler = this.#notFoundHandler; - clone.routes = this.routes; - return clone; - } - #notFoundHandler = notFoundHandler; - errorHandler = errorHandler; - route(path, app2) { - const subApp = this.basePath(path); - app2.routes.map((r) => { - let handler; - if (app2.errorHandler === errorHandler) { - handler = r.handler; - } else { - handler = /* @__PURE__ */ __name(async (c, next) => (await compose([], app2.errorHandler)(c, () => r.handler(c, next))).res, "handler"); - handler[COMPOSED_HANDLER] = r.handler; - } - subApp.#addRoute(r.method, r.path, handler); - }); - return this; - } - basePath(path) { - const subApp = this.#clone(); - subApp._basePath = mergePath(this._basePath, path); - return subApp; - } - onError = /* @__PURE__ */ __name((handler) => { - this.errorHandler = handler; - return this; - }, "onError"); - notFound = /* @__PURE__ */ __name((handler) => { - this.#notFoundHandler = handler; - return this; - }, "notFound"); - mount(path, applicationHandler, options) { - let replaceRequest; - let optionHandler; - if (options) { - if (typeof options === "function") { - optionHandler = options; - } else { - optionHandler = options.optionHandler; - if (options.replaceRequest === false) { - replaceRequest = /* @__PURE__ */ __name((request) => request, "replaceRequest"); - } else { - replaceRequest = options.replaceRequest; - } - } - } - const getOptions = optionHandler ? (c) => { - const options2 = optionHandler(c); - return Array.isArray(options2) ? options2 : [options2]; - } : (c) => { - let executionContext = void 0; - try { - executionContext = c.executionCtx; - } catch { - } - return [c.env, executionContext]; - }; - replaceRequest ||= (() => { - const mergedPath = mergePath(this._basePath, path); - const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length; - return (request) => { - const url = new URL(request.url); - url.pathname = url.pathname.slice(pathPrefixLength) || "/"; - return new Request(url, request); - }; - })(); - const handler = /* @__PURE__ */ __name(async (c, next) => { - const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c)); - if (res) { - return res; - } - await next(); - }, "handler"); - this.#addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler); - return this; - } - #addRoute(method, path, handler) { - method = method.toUpperCase(); - path = mergePath(this._basePath, path); - const r = { basePath: this._basePath, path, method, handler }; - this.router.add(method, path, [handler, r]); - this.routes.push(r); - } - #handleError(err, c) { - if (err instanceof Error) { - return this.errorHandler(err, c); - } - throw err; - } - #dispatch(request, executionCtx, env2, method) { - if (method === "HEAD") { - return (async () => new Response(null, await this.#dispatch(request, executionCtx, env2, "GET")))(); - } - const path = this.getPath(request, { env: env2 }); - const matchResult = this.router.match(method, path); - const c = new Context(request, { - path, - matchResult, - env: env2, - executionCtx, - notFoundHandler: this.#notFoundHandler - }); - if (matchResult[0].length === 1) { - let res; - try { - res = matchResult[0][0][0][0](c, async () => { - c.res = await this.#notFoundHandler(c); - }); - } catch (err) { - return this.#handleError(err, c); - } - return res instanceof Promise ? res.then( - (resolved) => resolved || (c.finalized ? c.res : this.#notFoundHandler(c)) - ).catch((err) => this.#handleError(err, c)) : res ?? this.#notFoundHandler(c); - } - const composed = compose(matchResult[0], this.errorHandler, this.#notFoundHandler); - return (async () => { - try { - const context2 = await composed(c); - if (!context2.finalized) { - throw new Error( - "Context is not finalized. Did you forget to return a Response object or `await next()`?" - ); - } - return context2.res; - } catch (err) { - return this.#handleError(err, c); - } - })(); - } - fetch = /* @__PURE__ */ __name((request, ...rest) => { - return this.#dispatch(request, rest[1], rest[0], request.method); - }, "fetch"); - request = /* @__PURE__ */ __name((input, requestInit, Env, executionCtx) => { - if (input instanceof Request) { - return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx); - } - input = input.toString(); - return this.fetch( - new Request( - /^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`, - requestInit - ), - Env, - executionCtx - ); - }, "request"); - fire = /* @__PURE__ */ __name(() => { - addEventListener("fetch", (event) => { - event.respondWith(this.#dispatch(event.request, event, void 0, event.request.method)); - }); - }, "fire"); -}; - -// node_modules/hono/dist/router/reg-exp-router/index.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/router/reg-exp-router/router.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/router/reg-exp-router/node.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var LABEL_REG_EXP_STR = "[^/]+"; -var ONLY_WILDCARD_REG_EXP_STR = ".*"; -var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)"; -var PATH_ERROR = Symbol(); -var regExpMetaChars = new Set(".\\+*[^]$()"); -function compareKey(a, b) { - if (a.length === 1) { - return b.length === 1 ? a < b ? -1 : 1 : -1; - } - if (b.length === 1) { - return 1; - } - if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) { - return 1; - } else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) { - return -1; - } - if (a === LABEL_REG_EXP_STR) { - return 1; - } else if (b === LABEL_REG_EXP_STR) { - return -1; - } - return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length; -} -__name(compareKey, "compareKey"); -var Node = class { - static { - __name(this, "Node"); - } - #index; - #varIndex; - #children = /* @__PURE__ */ Object.create(null); - insert(tokens, index, paramMap, context2, pathErrorCheckOnly) { - if (tokens.length === 0) { - if (this.#index !== void 0) { - throw PATH_ERROR; - } - if (pathErrorCheckOnly) { - return; - } - this.#index = index; - return; - } - const [token, ...restTokens] = tokens; - const pattern = token === "*" ? restTokens.length === 0 ? ["", "", ONLY_WILDCARD_REG_EXP_STR] : ["", "", LABEL_REG_EXP_STR] : token === "/*" ? ["", "", TAIL_WILDCARD_REG_EXP_STR] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/); - let node; - if (pattern) { - const name = pattern[1]; - let regexpStr = pattern[2] || LABEL_REG_EXP_STR; - if (name && pattern[2]) { - if (regexpStr === ".*") { - throw PATH_ERROR; - } - regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"); - if (/\((?!\?:)/.test(regexpStr)) { - throw PATH_ERROR; - } - } - node = this.#children[regexpStr]; - if (!node) { - if (Object.keys(this.#children).some( - (k) => k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR - )) { - throw PATH_ERROR; - } - if (pathErrorCheckOnly) { - return; - } - node = this.#children[regexpStr] = new Node(); - if (name !== "") { - node.#varIndex = context2.varIndex++; - } - } - if (!pathErrorCheckOnly && name !== "") { - paramMap.push([name, node.#varIndex]); - } - } else { - node = this.#children[token]; - if (!node) { - if (Object.keys(this.#children).some( - (k) => k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR - )) { - throw PATH_ERROR; - } - if (pathErrorCheckOnly) { - return; - } - node = this.#children[token] = new Node(); - } - } - node.insert(restTokens, index, paramMap, context2, pathErrorCheckOnly); - } - buildRegExpStr() { - const childKeys = Object.keys(this.#children).sort(compareKey); - const strList = childKeys.map((k) => { - const c = this.#children[k]; - return (typeof c.#varIndex === "number" ? `(${k})@${c.#varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr(); - }); - if (typeof this.#index === "number") { - strList.unshift(`#${this.#index}`); - } - if (strList.length === 0) { - return ""; - } - if (strList.length === 1) { - return strList[0]; - } - return "(?:" + strList.join("|") + ")"; - } -}; - -// node_modules/hono/dist/router/reg-exp-router/trie.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var Trie = class { - static { - __name(this, "Trie"); - } - #context = { varIndex: 0 }; - #root = new Node(); - insert(path, index, pathErrorCheckOnly) { - const paramAssoc = []; - const groups = []; - for (let i = 0; ; ) { - let replaced = false; - path = path.replace(/\{[^}]+\}/g, (m) => { - const mark = `@\\${i}`; - groups[i] = [mark, m]; - i++; - replaced = true; - return mark; - }); - if (!replaced) { - break; - } - } - const tokens = path.match(/(?::[^\/]+)|(?:\/\*$)|./g) || []; - for (let i = groups.length - 1; i >= 0; i--) { - const [mark] = groups[i]; - for (let j = tokens.length - 1; j >= 0; j--) { - if (tokens[j].indexOf(mark) !== -1) { - tokens[j] = tokens[j].replace(mark, groups[i][1]); - break; - } - } - } - this.#root.insert(tokens, index, paramAssoc, this.#context, pathErrorCheckOnly); - return paramAssoc; - } - buildRegExp() { - let regexp = this.#root.buildRegExpStr(); - if (regexp === "") { - return [/^$/, [], []]; - } - let captureIndex = 0; - const indexReplacementMap = []; - const paramReplacementMap = []; - regexp = regexp.replace(/#(\d+)|@(\d+)|\.\*\$/g, (_, handlerIndex, paramIndex) => { - if (handlerIndex !== void 0) { - indexReplacementMap[++captureIndex] = Number(handlerIndex); - return "$()"; - } - if (paramIndex !== void 0) { - paramReplacementMap[Number(paramIndex)] = ++captureIndex; - return ""; - } - return ""; - }); - return [new RegExp(`^${regexp}`), indexReplacementMap, paramReplacementMap]; - } -}; - -// node_modules/hono/dist/router/reg-exp-router/router.js -var emptyParam = []; -var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)]; -var wildcardRegExpCache = /* @__PURE__ */ Object.create(null); -function buildWildcardRegExp(path) { - return wildcardRegExpCache[path] ??= new RegExp( - path === "*" ? "" : `^${path.replace( - /\/\*$|([.\\+*[^\]$()])/g, - (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)" - )}$` - ); -} -__name(buildWildcardRegExp, "buildWildcardRegExp"); -function clearWildcardRegExpCache() { - wildcardRegExpCache = /* @__PURE__ */ Object.create(null); -} -__name(clearWildcardRegExpCache, "clearWildcardRegExpCache"); -function buildMatcherFromPreprocessedRoutes(routes) { - const trie = new Trie(); - const handlerData = []; - if (routes.length === 0) { - return nullMatcher; - } - const routesWithStaticPathFlag = routes.map( - (route) => [!/\*|\/:/.test(route[0]), ...route] - ).sort( - ([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length - ); - const staticMap = /* @__PURE__ */ Object.create(null); - for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) { - const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i]; - if (pathErrorCheckOnly) { - staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam]; - } else { - j++; - } - let paramAssoc; - try { - paramAssoc = trie.insert(path, j, pathErrorCheckOnly); - } catch (e) { - throw e === PATH_ERROR ? new UnsupportedPathError(path) : e; - } - if (pathErrorCheckOnly) { - continue; - } - handlerData[j] = handlers.map(([h, paramCount]) => { - const paramIndexMap = /* @__PURE__ */ Object.create(null); - paramCount -= 1; - for (; paramCount >= 0; paramCount--) { - const [key, value] = paramAssoc[paramCount]; - paramIndexMap[key] = value; - } - return [h, paramIndexMap]; - }); - } - const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp(); - for (let i = 0, len = handlerData.length; i < len; i++) { - for (let j = 0, len2 = handlerData[i].length; j < len2; j++) { - const map = handlerData[i][j]?.[1]; - if (!map) { - continue; - } - const keys = Object.keys(map); - for (let k = 0, len3 = keys.length; k < len3; k++) { - map[keys[k]] = paramReplacementMap[map[keys[k]]]; - } - } - } - const handlerMap = []; - for (const i in indexReplacementMap) { - handlerMap[i] = handlerData[indexReplacementMap[i]]; - } - return [regexp, handlerMap, staticMap]; -} -__name(buildMatcherFromPreprocessedRoutes, "buildMatcherFromPreprocessedRoutes"); -function findMiddleware(middleware, path) { - if (!middleware) { - return void 0; - } - for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) { - if (buildWildcardRegExp(k).test(path)) { - return [...middleware[k]]; - } - } - return void 0; -} -__name(findMiddleware, "findMiddleware"); -var RegExpRouter = class { - static { - __name(this, "RegExpRouter"); - } - name = "RegExpRouter"; - #middleware; - #routes; - constructor() { - this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) }; - this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) }; - } - add(method, path, handler) { - const middleware = this.#middleware; - const routes = this.#routes; - if (!middleware || !routes) { - throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT); - } - if (!middleware[method]) { - ; - [middleware, routes].forEach((handlerMap) => { - handlerMap[method] = /* @__PURE__ */ Object.create(null); - Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p) => { - handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]]; - }); - }); - } - if (path === "/*") { - path = "*"; - } - const paramCount = (path.match(/\/:/g) || []).length; - if (/\*$/.test(path)) { - const re = buildWildcardRegExp(path); - if (method === METHOD_NAME_ALL) { - Object.keys(middleware).forEach((m) => { - middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || []; - }); - } else { - middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || []; - } - Object.keys(middleware).forEach((m) => { - if (method === METHOD_NAME_ALL || method === m) { - Object.keys(middleware[m]).forEach((p) => { - re.test(p) && middleware[m][p].push([handler, paramCount]); - }); - } - }); - Object.keys(routes).forEach((m) => { - if (method === METHOD_NAME_ALL || method === m) { - Object.keys(routes[m]).forEach( - (p) => re.test(p) && routes[m][p].push([handler, paramCount]) - ); - } - }); - return; - } - const paths = checkOptionalParameter(path) || [path]; - for (let i = 0, len = paths.length; i < len; i++) { - const path2 = paths[i]; - Object.keys(routes).forEach((m) => { - if (method === METHOD_NAME_ALL || method === m) { - routes[m][path2] ||= [ - ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || [] - ]; - routes[m][path2].push([handler, paramCount - len + i + 1]); - } - }); - } - } - match(method, path) { - clearWildcardRegExpCache(); - const matchers = this.#buildAllMatchers(); - this.match = (method2, path2) => { - const matcher = matchers[method2] || matchers[METHOD_NAME_ALL]; - const staticMatch = matcher[2][path2]; - if (staticMatch) { - return staticMatch; - } - const match = path2.match(matcher[0]); - if (!match) { - return [[], emptyParam]; - } - const index = match.indexOf("", 1); - return [matcher[1][index], match]; - }; - return this.match(method, path); - } - #buildAllMatchers() { - const matchers = /* @__PURE__ */ Object.create(null); - Object.keys(this.#routes).concat(Object.keys(this.#middleware)).forEach((method) => { - matchers[method] ||= this.#buildMatcher(method); - }); - this.#middleware = this.#routes = void 0; - return matchers; - } - #buildMatcher(method) { - const routes = []; - let hasOwnRoute = method === METHOD_NAME_ALL; - [this.#middleware, this.#routes].forEach((r) => { - const ownRoute = r[method] ? Object.keys(r[method]).map((path) => [path, r[method][path]]) : []; - if (ownRoute.length !== 0) { - hasOwnRoute ||= true; - routes.push(...ownRoute); - } else if (method !== METHOD_NAME_ALL) { - routes.push( - ...Object.keys(r[METHOD_NAME_ALL]).map((path) => [path, r[METHOD_NAME_ALL][path]]) - ); - } - }); - if (!hasOwnRoute) { - return null; - } else { - return buildMatcherFromPreprocessedRoutes(routes); - } - } -}; - -// node_modules/hono/dist/router/smart-router/index.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/router/smart-router/router.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var SmartRouter = class { - static { - __name(this, "SmartRouter"); - } - name = "SmartRouter"; - #routers = []; - #routes = []; - constructor(init) { - this.#routers = init.routers; - } - add(method, path, handler) { - if (!this.#routes) { - throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT); - } - this.#routes.push([method, path, handler]); - } - match(method, path) { - if (!this.#routes) { - throw new Error("Fatal error"); - } - const routers = this.#routers; - const routes = this.#routes; - const len = routers.length; - let i = 0; - let res; - for (; i < len; i++) { - const router16 = routers[i]; - try { - for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) { - router16.add(...routes[i2]); - } - res = router16.match(method, path); - } catch (e) { - if (e instanceof UnsupportedPathError) { - continue; - } - throw e; - } - this.match = router16.match.bind(router16); - this.#routers = [router16]; - this.#routes = void 0; - break; - } - if (i === len) { - throw new Error("Fatal error"); - } - this.name = `SmartRouter + ${this.activeRouter.name}`; - return res; - } - get activeRouter() { - if (this.#routes || this.#routers.length !== 1) { - throw new Error("No active router has been determined yet."); - } - return this.#routers[0]; - } -}; - -// node_modules/hono/dist/router/trie-router/index.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/router/trie-router/router.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/router/trie-router/node.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var emptyParams = /* @__PURE__ */ Object.create(null); -var Node2 = class { - static { - __name(this, "Node"); - } - #methods; - #children; - #patterns; - #order = 0; - #params = emptyParams; - constructor(method, handler, children) { - this.#children = children || /* @__PURE__ */ Object.create(null); - this.#methods = []; - if (method && handler) { - const m = /* @__PURE__ */ Object.create(null); - m[method] = { handler, possibleKeys: [], score: 0 }; - this.#methods = [m]; - } - this.#patterns = []; - } - insert(method, path, handler) { - this.#order = ++this.#order; - let curNode = this; - const parts = splitRoutingPath(path); - const possibleKeys = []; - for (let i = 0, len = parts.length; i < len; i++) { - const p = parts[i]; - const nextP = parts[i + 1]; - const pattern = getPattern(p, nextP); - const key = Array.isArray(pattern) ? pattern[0] : p; - if (key in curNode.#children) { - curNode = curNode.#children[key]; - if (pattern) { - possibleKeys.push(pattern[1]); - } - continue; - } - curNode.#children[key] = new Node2(); - if (pattern) { - curNode.#patterns.push(pattern); - possibleKeys.push(pattern[1]); - } - curNode = curNode.#children[key]; - } - curNode.#methods.push({ - [method]: { - handler, - possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i), - score: this.#order - } - }); - return curNode; - } - #getHandlerSets(node, method, nodeParams, params) { - const handlerSets = []; - for (let i = 0, len = node.#methods.length; i < len; i++) { - const m = node.#methods[i]; - const handlerSet = m[method] || m[METHOD_NAME_ALL]; - const processedSet = {}; - if (handlerSet !== void 0) { - handlerSet.params = /* @__PURE__ */ Object.create(null); - handlerSets.push(handlerSet); - if (nodeParams !== emptyParams || params && params !== emptyParams) { - for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) { - const key = handlerSet.possibleKeys[i2]; - const processed = processedSet[handlerSet.score]; - handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key]; - processedSet[handlerSet.score] = true; - } - } - } - } - return handlerSets; - } - search(method, path) { - const handlerSets = []; - this.#params = emptyParams; - const curNode = this; - let curNodes = [curNode]; - const parts = splitPath(path); - const curNodesQueue = []; - for (let i = 0, len = parts.length; i < len; i++) { - const part = parts[i]; - const isLast = i === len - 1; - const tempNodes = []; - for (let j = 0, len2 = curNodes.length; j < len2; j++) { - const node = curNodes[j]; - const nextNode = node.#children[part]; - if (nextNode) { - nextNode.#params = node.#params; - if (isLast) { - if (nextNode.#children["*"]) { - handlerSets.push( - ...this.#getHandlerSets(nextNode.#children["*"], method, node.#params) - ); - } - handlerSets.push(...this.#getHandlerSets(nextNode, method, node.#params)); - } else { - tempNodes.push(nextNode); - } - } - for (let k = 0, len3 = node.#patterns.length; k < len3; k++) { - const pattern = node.#patterns[k]; - const params = node.#params === emptyParams ? {} : { ...node.#params }; - if (pattern === "*") { - const astNode = node.#children["*"]; - if (astNode) { - handlerSets.push(...this.#getHandlerSets(astNode, method, node.#params)); - astNode.#params = params; - tempNodes.push(astNode); - } - continue; - } - const [key, name, matcher] = pattern; - if (!part && !(matcher instanceof RegExp)) { - continue; - } - const child = node.#children[key]; - const restPathString = parts.slice(i).join("/"); - if (matcher instanceof RegExp) { - const m = matcher.exec(restPathString); - if (m) { - params[name] = m[0]; - handlerSets.push(...this.#getHandlerSets(child, method, node.#params, params)); - if (Object.keys(child.#children).length) { - child.#params = params; - const componentCount = m[0].match(/\//)?.length ?? 0; - const targetCurNodes = curNodesQueue[componentCount] ||= []; - targetCurNodes.push(child); - } - continue; - } - } - if (matcher === true || matcher.test(part)) { - params[name] = part; - if (isLast) { - handlerSets.push(...this.#getHandlerSets(child, method, params, node.#params)); - if (child.#children["*"]) { - handlerSets.push( - ...this.#getHandlerSets(child.#children["*"], method, params, node.#params) - ); - } - } else { - child.#params = params; - tempNodes.push(child); - } - } - } - } - curNodes = tempNodes.concat(curNodesQueue.shift() ?? []); - } - if (handlerSets.length > 1) { - handlerSets.sort((a, b) => { - return a.score - b.score; - }); - } - return [handlerSets.map(({ handler, params }) => [handler, params])]; - } -}; - -// node_modules/hono/dist/router/trie-router/router.js -var TrieRouter = class { - static { - __name(this, "TrieRouter"); - } - name = "TrieRouter"; - #node; - constructor() { - this.#node = new Node2(); - } - add(method, path, handler) { - const results = checkOptionalParameter(path); - if (results) { - for (let i = 0, len = results.length; i < len; i++) { - this.#node.insert(method, results[i], handler); - } - return; - } - this.#node.insert(method, path, handler); - } - match(method, path) { - return this.#node.search(method, path); - } -}; - -// node_modules/hono/dist/hono.js -var Hono2 = class extends Hono { - static { - __name(this, "Hono"); - } - constructor(options = {}) { - super(options); - this.router = options.router ?? new SmartRouter({ - routers: [new RegExpRouter(), new TrieRouter()] - }); - } -}; - -// src/middleware/cors.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/hono/dist/middleware/cors/index.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var cors = /* @__PURE__ */ __name((options) => { - const defaults = { - origin: "*", - allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"], - allowHeaders: [], - exposeHeaders: [] - }; - const opts = { - ...defaults, - ...options - }; - const findAllowOrigin = ((optsOrigin) => { - if (typeof optsOrigin === "string") { - if (optsOrigin === "*") { - return () => optsOrigin; - } else { - return (origin) => optsOrigin === origin ? origin : null; - } - } else if (typeof optsOrigin === "function") { - return optsOrigin; - } else { - return (origin) => optsOrigin.includes(origin) ? origin : null; - } - })(opts.origin); - const findAllowMethods = ((optsAllowMethods) => { - if (typeof optsAllowMethods === "function") { - return optsAllowMethods; - } else if (Array.isArray(optsAllowMethods)) { - return () => optsAllowMethods; - } else { - return () => []; - } - })(opts.allowMethods); - return /* @__PURE__ */ __name(async function cors2(c, next) { - function set(key, value) { - c.res.headers.set(key, value); - } - __name(set, "set"); - const allowOrigin = await findAllowOrigin(c.req.header("origin") || "", c); - if (allowOrigin) { - set("Access-Control-Allow-Origin", allowOrigin); - } - if (opts.origin !== "*") { - const existingVary = c.req.header("Vary"); - if (existingVary) { - set("Vary", existingVary); - } else { - set("Vary", "Origin"); - } - } - if (opts.credentials) { - set("Access-Control-Allow-Credentials", "true"); - } - if (opts.exposeHeaders?.length) { - set("Access-Control-Expose-Headers", opts.exposeHeaders.join(",")); - } - if (c.req.method === "OPTIONS") { - if (opts.maxAge != null) { - set("Access-Control-Max-Age", opts.maxAge.toString()); - } - const allowMethods = await findAllowMethods(c.req.header("origin") || "", c); - if (allowMethods.length) { - set("Access-Control-Allow-Methods", allowMethods.join(",")); - } - let headers = opts.allowHeaders; - if (!headers?.length) { - const requestHeaders = c.req.header("Access-Control-Request-Headers"); - if (requestHeaders) { - headers = requestHeaders.split(/\s*,\s*/); - } - } - if (headers?.length) { - set("Access-Control-Allow-Headers", headers.join(",")); - c.res.headers.append("Vary", "Access-Control-Request-Headers"); - } - c.res.headers.delete("Content-Length"); - c.res.headers.delete("Content-Type"); - return new Response(null, { - headers: c.res.headers, - status: 204, - statusText: "No Content" - }); - } - await next(); - }, "cors2"); -}, "cors"); - -// src/config/index.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/config/constants.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -function getCorsOrigins(env2) { - if (env2.CORS_ORIGINS) { - return env2.CORS_ORIGINS.split(",").map((origin) => origin.trim()); - } - if (env2.SITE_URL) { - return [env2.SITE_URL]; - } - return ["*"]; -} -__name(getCorsOrigins, "getCorsOrigins"); -var CORS_ALLOWED_METHODS = ["GET", "POST", "PUT", "DELETE", "OPTIONS"]; -var CORS_ALLOWED_HEADERS = ["Content-Type", "X-Admin-Token"]; -var SHIPPING_COUNTRIES = [ - "US", - "CA", - "GB", - "AU", - "DE", - "FR", - "IT", - "ES", - "NL", - "BE", - "AT", - "CH", - "SE", - "NO", - "DK", - "FI", - "IE", - "PT", - "PL", - "CZ", - "HU", - "GR", - "RO", - "BG", - "HR", - "SI", - "SK", - "EE", - "LV", - "LT", - "LU", - "MT", - "CY" -]; -var ALLOWED_DRIVE_HOSTS = [ - "drive.google.com", - "drive.usercontent.google.com", - "lh3.googleusercontent.com" -]; -var ADMIN_TOKEN_TTL = 86400; -var ADMIN_TOKEN_TTL_MS = 864e5; -var KV_KEYS = { - PRODUCTS_LIST: "products:all", - COLLECTIONS_LIST: "collections:all", - MEDIA_LIST: "media:all", - STORE_SETTINGS: "store:settings", - DRIVE_TOKEN: "drive:oauth:tokens", - DRIVE_FOLDER_PREFIX: "drive:folder", - ADMIN_TOKEN_PREFIX: "admin_token:" -}; -var THEME_COLOR_KEYS = ["primary", "secondary", "accent", "text", "background", "card"]; -var THEME_RADIUS_MULTIPLIER_MIN = 0; -var THEME_RADIUS_MULTIPLIER_MAX = 4; - -// src/config/env.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/middleware/cors.js -function createCorsMiddleware(env2 = {}) { - const origins = getCorsOrigins(env2); - const originConfig = origins.length === 1 && origins[0] === "*" ? "*" : (origin) => { - const requestOrigin = origin; - if (origins.includes("*") || origins.includes(requestOrigin)) { - return requestOrigin; - } - return origins[0]; - }; - return cors({ - origin: originConfig, - allowMethods: CORS_ALLOWED_METHODS, - allowHeaders: CORS_ALLOWED_HEADERS, - credentials: true - }); -} -__name(createCorsMiddleware, "createCorsMiddleware"); - -// src/middleware/errorHandler.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/utils/errors.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var APIError = class extends Error { - static { - __name(this, "APIError"); - } - constructor(message, statusCode = 500, details = null) { - super(message); - this.name = "APIError"; - this.statusCode = statusCode; - this.details = details; - } - toJSON() { - return { - error: this.message, - status: this.statusCode, - ...this.details && { details: this.details } - }; - } -}; -var ValidationError = class extends APIError { - static { - __name(this, "ValidationError"); - } - constructor(message, details = null) { - super(message, 400, details); - this.name = "ValidationError"; - } -}; -var AuthenticationError = class extends APIError { - static { - __name(this, "AuthenticationError"); - } - constructor(message = "Authentication required") { - super(message, 401); - this.name = "AuthenticationError"; - } -}; -var NotFoundError = class extends APIError { - static { - __name(this, "NotFoundError"); - } - constructor(message = "Resource not found") { - super(message, 404); - this.name = "NotFoundError"; - } -}; - -// src/middleware/errorHandler.js -function errorHandler2(error3, c) { - console.error("Error in request handler:", error3); - if (error3 instanceof APIError) { - return c.json(error3.toJSON(), error3.statusCode); - } - if (error3.name === "ValidationError" || error3.status === 400) { - return c.json({ - error: error3.message || "Validation error", - status: 400 - }, 400); - } - if (error3.name === "AuthenticationError" || error3.status === 401) { - return c.json({ - error: error3.message || "Authentication required", - status: 401 - }, 401); - } - if (error3.name === "NotFoundError" || error3.status === 404) { - return c.json({ - error: error3.message || "Resource not found", - status: 404 - }, 404); - } - return c.json({ - error: error3.message || "Internal server error", - status: 500 - }, 500); -} -__name(errorHandler2, "errorHandler"); -function asyncHandler(fn) { - return async (c, next) => { - try { - return await fn(c, next); - } catch (error3) { - return errorHandler2(error3, c); - } - }; -} -__name(asyncHandler, "asyncHandler"); - -// src/middleware/auth.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/utils/kv.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -function getKVNamespace(env2) { - if (!env2 || typeof env2 !== "object") { - console.error("getKVNamespace: Invalid environment object"); - return null; - } - const possibleBindings = [ - "OPENSHOP-TEST3_KV", - "OPENSHOP_TEST3_KV", - "OPENSHOP_KV" - ]; - for (const bindingName of possibleBindings) { - if (bindingName in env2 && env2[bindingName]) { - const kvNamespace2 = env2[bindingName]; - if (isKVNamespace(kvNamespace2)) { - console.log(`Found KV namespace via direct access: ${bindingName}`); - return kvNamespace2; - } - } - } - const kvBindingName = Object.keys(env2).find( - (key) => (key.endsWith("_KV") || key.endsWith("-KV") || key.includes("KV")) && isKVNamespace(env2[key]) - ); - if (kvBindingName) { - console.log(`Found KV namespace via search: ${kvBindingName}`); - return env2[kvBindingName]; - } - const kvNamespace = Object.values(env2).find( - (binding2) => isKVNamespace(binding2) - ); - if (kvNamespace) { - console.log("Found KV namespace via fallback"); - return kvNamespace; - } - console.error("No KV namespace found! Available bindings:", Object.keys(env2)); - console.error("Environment value types:", Object.values(env2).map((v) => typeof v)); - return null; -} -__name(getKVNamespace, "getKVNamespace"); -function isKVNamespace(binding2) { - return binding2 && typeof binding2.get === "function" && typeof binding2.put === "function" && typeof binding2.delete === "function" && typeof binding2.list === "function"; -} -__name(isKVNamespace, "isKVNamespace"); - -// src/utils/crypto.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -function getCrypto() { - const cryptoObj = typeof globalThis !== "undefined" ? globalThis.crypto : null; - if (!cryptoObj) { - throw new Error("Web Crypto API is not available in this environment"); - } - return cryptoObj; -} -__name(getCrypto, "getCrypto"); -function randomHex(bytes = 16) { - const cryptoObj = getCrypto(); - if (typeof cryptoObj.getRandomValues !== "function") { - throw new Error("crypto.getRandomValues is not available"); - } - const buffer = new Uint8Array(bytes); - cryptoObj.getRandomValues(buffer); - return Array.from(buffer, (b) => b.toString(16).padStart(2, "0")).join(""); -} -__name(randomHex, "randomHex"); -function generateSessionToken() { - const cryptoObj = getCrypto(); - if (typeof cryptoObj.randomUUID === "function") { - return cryptoObj.randomUUID().replace(/-/g, ""); - } - return randomHex(32); -} -__name(generateSessionToken, "generateSessionToken"); -async function hashToken(token) { - if (typeof token !== "string" || token.length === 0) { - throw new Error("Token must be a non-empty string for hashing"); - } - const cryptoObj = getCrypto(); - if (!cryptoObj.subtle || typeof cryptoObj.subtle.digest !== "function") { - throw new Error("Web Crypto API is not available for hashing tokens"); - } - const encoder = new TextEncoder(); - const data = encoder.encode(token); - const digest = await cryptoObj.subtle.digest("SHA-256", data); - const hashArray = Array.from(new Uint8Array(digest)); - return hashArray.map((b) => b.toString(16).padStart(2, "0")).join(""); -} -__name(hashToken, "hashToken"); -async function hashPassword(password, salt, iterations = 1e5) { - const cryptoObj = getCrypto(); - if (!cryptoObj.subtle) { - throw new Error("Web Crypto API is not available for password hashing"); - } - const encoder = new TextEncoder(); - const passwordData = encoder.encode(password); - const saltBytes = new Uint8Array(salt.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))); - const keyMaterial = await cryptoObj.subtle.importKey( - "raw", - passwordData, - { name: "PBKDF2" }, - false, - ["deriveBits"] - ); - const derivedBits = await cryptoObj.subtle.deriveBits( - { - name: "PBKDF2", - salt: saltBytes, - iterations, - hash: "SHA-256" - }, - keyMaterial, - 256 - // 256 bits = 32 bytes - ); - return Array.from(new Uint8Array(derivedBits)).map((b) => b.toString(16).padStart(2, "0")).join(""); -} -__name(hashPassword, "hashPassword"); -async function verifyPassword(password, hash) { - try { - const [iterationsStr, salt, expectedHash] = hash.split(":"); - const iterations = parseInt(iterationsStr, 10); - if (!iterations || !salt || !expectedHash) { - return false; - } - const computedHash = await hashPassword(password, salt, iterations); - return computedHash === expectedHash; - } catch (error3) { - return false; - } -} -__name(verifyPassword, "verifyPassword"); -function generateSalt(bytes = 16) { - return randomHex(bytes); -} -__name(generateSalt, "generateSalt"); -async function hashPasswordWithSalt(password, iterations = 1e5) { - const salt = generateSalt(16); - const hash = await hashPassword(password, salt, iterations); - return `${iterations}:${salt}:${hash}`; -} -__name(hashPasswordWithSalt, "hashPasswordWithSalt"); - -// src/middleware/auth.js -async function verifyAdminAuth(request, env2) { - let adminToken; - try { - if (request && typeof request.header === "function") { - adminToken = request.header("X-Admin-Token") || request.header("x-admin-token"); - } else if (request && request.headers && typeof request.headers.get === "function") { - adminToken = request.headers.get("X-Admin-Token") || request.headers.get("x-admin-token"); - } else if (request && request.raw && request.raw.headers && typeof request.raw.headers.get === "function") { - adminToken = request.raw.headers.get("X-Admin-Token") || request.raw.headers.get("x-admin-token"); - } - } catch (e) { - console.error("Auth middleware - error reading admin token header:", e); - } - if (!adminToken) { - return { - isValid: false, - error: "Admin authentication required", - status: 401 - }; - } - try { - const kvNamespace = getKVNamespace(env2); - if (!kvNamespace) { - console.error("Auth middleware - KV namespace is undefined"); - return { - isValid: false, - error: "KV namespace not available", - status: 500 - }; - } - const hashedToken = await hashToken(adminToken); - const storageKey = `${KV_KEYS.ADMIN_TOKEN_PREFIX}${hashedToken}`; - const tokenData = await kvNamespace.get(storageKey); - if (!tokenData) { - return { - isValid: false, - error: "Invalid or expired admin token", - status: 401 - }; - } - const tokenTime = parseInt(tokenData); - const now = Date.now(); - if (now - tokenTime > ADMIN_TOKEN_TTL_MS) { - await kvNamespace.delete(storageKey); - return { - isValid: false, - error: "Admin session expired", - status: 401 - }; - } - return { isValid: true }; - } catch (error3) { - console.error("Admin auth verification error:", error3); - return { - isValid: false, - error: "Authentication verification failed", - status: 500 - }; - } -} -__name(verifyAdminAuth, "verifyAdminAuth"); - -// src/middleware/productLimit.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/services/StoreSettingsService.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/lib/kv.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var KVManager = class { - static { - __name(this, "KVManager"); - } - constructor(namespace) { - this.namespace = namespace; - } - // Product operations - async createProduct(product) { - const key = `product:${product.id}`; - const productData = { - ...product, - images: Array.isArray(product.images) ? product.images : product.imageUrl ? [product.imageUrl] : [] - }; - await this.namespace.put(key, JSON.stringify(productData)); - const productIds = await this.namespace.get("products:all"); - const existingIds = productIds ? JSON.parse(productIds) : []; - existingIds.push(product.id); - await this.namespace.put("products:all", JSON.stringify(existingIds)); - return productData; - } - async getProduct(id) { - const key = `product:${id}`; - const product = await this.namespace.get(key); - return product ? JSON.parse(product) : null; - } - async updateProduct(id, updates) { - const existing = await this.getProduct(id); - if (!existing) throw new Error("Product not found"); - const updated = { - ...existing, - ...updates, - // Ensure images is always an array - images: Array.isArray(updates.images) ? updates.images : updates.imageUrl ? [updates.imageUrl] : existing.images || [] - }; - const key = `product:${id}`; - await this.namespace.put(key, JSON.stringify(updated)); - return updated; - } - async deleteProduct(id) { - const key = `product:${id}`; - await this.namespace.delete(key); - const productIds = await this.namespace.get("products:all"); - if (productIds) { - const existingIds = JSON.parse(productIds); - const filtered = existingIds.filter((pid2) => pid2 !== id); - await this.namespace.put("products:all", JSON.stringify(filtered)); - } - } - async getAllProducts() { - const productIds = await this.namespace.get("products:all"); - if (!productIds) return []; - const ids = JSON.parse(productIds); - const products = await Promise.all( - ids.map((id) => this.getProduct(id)) - ); - return products.filter(Boolean); - } - // Collection operations - async createCollection(collection) { - const key = `collection:${collection.id}`; - await this.namespace.put(key, JSON.stringify(collection)); - const collectionIds = await this.namespace.get("collections:all"); - const existingIds = collectionIds ? JSON.parse(collectionIds) : []; - existingIds.push(collection.id); - await this.namespace.put("collections:all", JSON.stringify(existingIds)); - return collection; - } - async getCollection(id) { - const key = `collection:${id}`; - const collection = await this.namespace.get(key); - return collection ? JSON.parse(collection) : null; - } - async updateCollection(id, updates) { - const existing = await this.getCollection(id); - if (!existing) throw new Error("Collection not found"); - const updated = { ...existing, ...updates }; - const key = `collection:${id}`; - await this.namespace.put(key, JSON.stringify(updated)); - return updated; - } - async deleteCollection(id) { - const key = `collection:${id}`; - await this.namespace.delete(key); - const collectionIds = await this.namespace.get("collections:all"); - if (collectionIds) { - const existingIds = JSON.parse(collectionIds); - const filtered = existingIds.filter((cid) => cid !== id); - await this.namespace.put("collections:all", JSON.stringify(filtered)); - } - } - async getAllCollections() { - const collectionIds = await this.namespace.get("collections:all"); - if (!collectionIds) return []; - const ids = JSON.parse(collectionIds); - const collections = await Promise.all( - ids.map((id) => this.getCollection(id)) - ); - return collections.filter(Boolean); - } - async getProductsByCollection(collectionId) { - const allProducts = await this.getAllProducts(); - return allProducts.filter((product) => product.collectionId === collectionId); - } - // Media operations - async createMediaItem(item) { - const id = item.id; - if (!id) throw new Error("Media item missing id"); - const key = `media:${id}`; - const record = { - id, - url: String(item.url || ""), - source: item.source || "unknown", - filename: item.filename || "", - mimeType: item.mimeType || "", - driveFileId: item.driveFileId || "", - createdAt: typeof item.createdAt === "number" ? item.createdAt : Date.now(), - updatedAt: Date.now() - }; - await this.namespace.put(key, JSON.stringify(record)); - const listKey = "media:all"; - const existing = await this.namespace.get(listKey); - const ids = existing ? JSON.parse(existing) : []; - if (!ids.includes(id)) ids.push(id); - await this.namespace.put(listKey, JSON.stringify(ids)); - return record; - } - async getMediaItem(id) { - const key = `media:${id}`; - const raw2 = await this.namespace.get(key); - return raw2 ? JSON.parse(raw2) : null; - } - async deleteMediaItem(id) { - const key = `media:${id}`; - await this.namespace.delete(key); - const listKey = "media:all"; - const existing = await this.namespace.get(listKey); - if (existing) { - const ids = JSON.parse(existing); - const next = ids.filter((mid) => mid !== id); - await this.namespace.put(listKey, JSON.stringify(next)); - } - } - async getAllMediaItems() { - const listKey = "media:all"; - const existing = await this.namespace.get(listKey); - if (!existing) return []; - const ids = JSON.parse(existing); - const items = await Promise.all(ids.map((id) => this.getMediaItem(id))); - return items.filter(Boolean); - } -}; - -// src/services/StoreSettingsService.js -var DEFAULT_SETTINGS = { - logoType: "text", - logoText: "OpenShop", - logoImageUrl: "", - storeName: "OpenShop", - storeDescription: "Your amazing online store", - heroImageUrl: "", - heroTitle: "Welcome to OpenShop", - heroSubtitle: "Discover amazing products at unbeatable prices. Built on Cloudflare for lightning-fast performance.", - contactEmail: "contact@example.com", - businessName: "", - businessAddressLine1: "", - businessAddressLine2: "", - businessCity: "", - businessState: "", - businessPostalCode: "", - businessCountry: "", - productLimit: null -}; -var StoreSettingsService = class { - static { - __name(this, "StoreSettingsService"); - } - constructor(kvNamespace) { - this.kv = new KVManager(kvNamespace); - } - /** - * Get store settings - */ - async getSettings() { - const settings = await this.kv.namespace.get(KV_KEYS.STORE_SETTINGS); - if (settings) { - const parsed = JSON.parse(settings); - return { ...DEFAULT_SETTINGS, ...parsed }; - } - return DEFAULT_SETTINGS; - } - /** - * Update store settings - */ - async updateSettings(settings) { - if (!settings.logoType || !["text", "image"].includes(settings.logoType)) { - throw new Error('Invalid logoType. Must be "text" or "image"'); - } - const updatedSettings = { ...DEFAULT_SETTINGS, ...settings }; - await this.kv.namespace.put(KV_KEYS.STORE_SETTINGS, JSON.stringify(updatedSettings)); - return updatedSettings; - } - /** - * Get contact email - */ - async getContactEmail() { - const settings = await this.getSettings(); - return { email: settings.contactEmail || "contact@example.com" }; - } -}; - -// src/services/ProductService.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var ProductService = class { - static { - __name(this, "ProductService"); - } - constructor(kvNamespace) { - this.kv = new KVManager(kvNamespace); - } - /** - * Get all products (excluding archived) - */ - async getAllProducts() { - const products = await this.kv.getAllProducts(); - return products.filter((p) => !p.archived); - } - /** - * Get all products including archived (for admin) - */ - async getAllProductsAdmin() { - return await this.kv.getAllProducts(); - } - /** - * Get single product by ID - */ - async getProduct(id) { - const product = await this.kv.getProduct(id); - if (!product) { - throw new NotFoundError("Product not found"); - } - return product; - } - /** - * Create a new product - */ - async createProduct(productData) { - return await this.kv.createProduct(productData); - } - /** - * Update an existing product - */ - async updateProduct(id, updates) { - const existing = await this.kv.getProduct(id); - if (!existing) { - throw new NotFoundError("Product not found"); - } - return await this.kv.updateProduct(id, updates); - } - /** - * Delete a product - */ - async deleteProduct(id) { - const existing = await this.kv.getProduct(id); - if (!existing) { - throw new NotFoundError("Product not found"); - } - await this.kv.deleteProduct(id); - } - /** - * Get products by collection ID - */ - async getProductsByCollection(collectionId) { - const products = await this.kv.getProductsByCollection(collectionId); - return products.filter((p) => !p.archived); - } -}; - -// src/middleware/productLimit.js -async function productLimitMiddleware(c, next) { - if (c.req.method !== "POST" || c.req.path !== "/api/admin/products") { - return next(); - } - try { - const kvNamespace = getKVNamespace(c.env); - if (!kvNamespace) { - console.error("Product limit middleware - KV namespace not available"); - return next(); - } - const settingsService = new StoreSettingsService(kvNamespace); - const settings = await settingsService.getSettings(); - let productLimit = settings.productLimit; - if ((productLimit === null || productLimit === void 0 || productLimit === "") && c.env.PRODUCT_LIMIT) { - productLimit = c.env.PRODUCT_LIMIT; - } - if (productLimit === null || productLimit === void 0 || productLimit === "") { - return next(); - } - const limit = parseInt(productLimit, 10); - if (isNaN(limit) || limit <= 0) { - return next(); - } - const productService = new ProductService(kvNamespace); - const allProducts = await productService.getAllProducts(); - const activeProductCount = allProducts.length; - if (activeProductCount >= limit) { - return c.json({ - error: "Product limit reached", - message: `You have reached your product limit of ${limit}. Please delete products or upgrade your plan to add more.`, - limit, - current: activeProductCount - }, 403); - } - return next(); - } catch (error3) { - console.error("Product limit middleware error:", error3); - return next(); - } -} -__name(productLimitMiddleware, "productLimitMiddleware"); - -// src/routes/index.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/routes/public/products.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var router = new Hono2(); -router.get("/", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const productService = new ProductService(kvNamespace); - const products = await productService.getAllProducts(); - return c.json(products); -})); -router.get("/:id", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const productService = new ProductService(kvNamespace); - const product = await productService.getProduct(c.req.param("id")); - return c.json(product); -})); -var products_default = router; - -// src/routes/public/collections.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/services/CollectionService.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var CollectionService = class { - static { - __name(this, "CollectionService"); - } - constructor(kvNamespace) { - this.kv = new KVManager(kvNamespace); - } - /** - * Get all collections (excluding archived) - */ - async getAllCollections() { - const collections = await this.kv.getAllCollections(); - return collections.filter((col) => !col.archived); - } - /** - * Get all collections including archived (for admin) - */ - async getAllCollectionsAdmin() { - return await this.kv.getAllCollections(); - } - /** - * Get single collection by ID - */ - async getCollection(id) { - const collection = await this.kv.getCollection(id); - if (!collection) { - throw new NotFoundError("Collection not found"); - } - return collection; - } - /** - * Create a new collection - */ - async createCollection(collectionData) { - return await this.kv.createCollection(collectionData); - } - /** - * Update an existing collection - */ - async updateCollection(id, updates) { - const existing = await this.kv.getCollection(id); - if (!existing) { - throw new NotFoundError("Collection not found"); - } - return await this.kv.updateCollection(id, updates); - } - /** - * Delete a collection - */ - async deleteCollection(id) { - const existing = await this.kv.getCollection(id); - if (!existing) { - throw new NotFoundError("Collection not found"); - } - await this.kv.deleteCollection(id); - } - /** - * Get products in a collection (with archived check) - */ - async getProductsInCollection(collectionId) { - const collection = await this.kv.getCollection(collectionId); - if (!collection) { - throw new NotFoundError("Collection not found"); - } - const products = await this.kv.getProductsByCollection(collectionId); - if (collection.archived) { - return []; - } - return products.filter((p) => !p.archived); - } -}; - -// src/routes/public/collections.js -var router2 = new Hono2(); -router2.get("/", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const collectionService = new CollectionService(kvNamespace); - const collections = await collectionService.getAllCollections(); - return c.json(collections); -})); -router2.get("/:id", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const collectionService = new CollectionService(kvNamespace); - const collection = await collectionService.getCollection(c.req.param("id")); - return c.json(collection); -})); -router2.get("/:id/products", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const collectionService = new CollectionService(kvNamespace); - const products = await collectionService.getProductsInCollection(c.req.param("id")); - return c.json(products); -})); -var collections_default = router2; - -// src/routes/public/storefront.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/services/ThemeService.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/lib/theme.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var BASE_RADIUS_PX = 12; -var THEME_KV_KEY = "storefront:theme"; -var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/; -var FONT_OPTIONS = [ - { - id: "inter", - label: "Inter", - stack: "'Inter', 'system-ui', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" - }, - { - id: "roboto", - label: "Roboto", - stack: "'Roboto', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" - }, - { - id: "montserrat", - label: "Montserrat", - stack: "'Montserrat', 'Segoe UI', sans-serif" - }, - { - id: "poppins", - label: "Poppins", - stack: "'Poppins', 'Segoe UI', sans-serif" - }, - { - id: "lora", - label: "Lora", - stack: "'Lora', 'Georgia', serif" - } -]; -var FONT_LOOKUP = FONT_OPTIONS.reduce((acc, option) => { - acc[option.id] = option; - return acc; -}, {}); -var DEFAULT_STORE_THEME = { - colors: { - primary: "#1e293b", - secondary: "#475569", - accent: "#3b82f6", - text: "#0f172a", - background: "#f8fafc", - card: "#ffffff" - }, - typography: { - fontId: "inter" - }, - corners: { - enabled: true, - radiusMultiplier: 1 - } -}; -function clamp(value, min, max) { - return Math.min(Math.max(value, min), max); -} -__name(clamp, "clamp"); -function hexToRgb(hex) { - if (!hex) return null; - const normalized = hex.length === 4 ? `#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}` : hex; - const value = normalized.replace("#", ""); - const int = parseInt(value, 16); - if (Number.isNaN(int)) return null; - return { - r: int >> 16 & 255, - g: int >> 8 & 255, - b: int & 255 - }; -} -__name(hexToRgb, "hexToRgb"); -function rgbToHex({ r, g, b }) { - const toHex = /* @__PURE__ */ __name((channel2) => channel2.toString(16).padStart(2, "0"), "toHex"); - return `#${toHex(clamp(Math.round(channelSafe(r)), 0, 255))}${toHex(clamp(Math.round(channelSafe(g)), 0, 255))}${toHex(clamp(Math.round(channelSafe(b)), 0, 255))}`; -} -__name(rgbToHex, "rgbToHex"); -function channelSafe(value) { - return Number.isFinite(value) ? value : 0; -} -__name(channelSafe, "channelSafe"); -function mixChannel(channel2, target, factor) { - return channel2 + (target - channel2) * factor; -} -__name(mixChannel, "mixChannel"); -function lighten(hex, factor = 0.1) { - const rgb = hexToRgb(hex); - if (!rgb) return hex; - return rgbToHex({ - r: mixChannel(rgb.r, 255, factor), - g: mixChannel(rgb.g, 255, factor), - b: mixChannel(rgb.b, 255, factor) - }); -} -__name(lighten, "lighten"); -function darken(hex, factor = 0.1) { - const rgb = hexToRgb(hex); - if (!rgb) return hex; - return rgbToHex({ - r: mixChannel(rgb.r, 0, factor), - g: mixChannel(rgb.g, 0, factor), - b: mixChannel(rgb.b, 0, factor) - }); -} -__name(darken, "darken"); -function getContrastColor(hex) { - const rgb = hexToRgb(hex); - if (!rgb) return "#ffffff"; - const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255; - return luminance > 0.6 ? "#0f172a" : "#ffffff"; -} -__name(getContrastColor, "getContrastColor"); -function ensureHex(color, fallback) { - if (typeof color !== "string") return fallback; - return HEX_COLOR_REGEX.test(color.trim()) ? color.trim() : fallback; -} -__name(ensureHex, "ensureHex"); -function ensureFontId(fontId) { - return FONT_LOOKUP[fontId] ? fontId : DEFAULT_STORE_THEME.typography.fontId; -} -__name(ensureFontId, "ensureFontId"); -function ensureRadiusMultiplier(value) { - if (typeof value === "string" && value.trim() !== "") { - const parsed = Number(value); - if (!Number.isNaN(parsed)) { - value = parsed; - } - } - if (typeof value !== "number" || Number.isNaN(value)) { - value = DEFAULT_STORE_THEME.corners.radiusMultiplier; - } - return clamp(Math.abs(value), 0, 4); -} -__name(ensureRadiusMultiplier, "ensureRadiusMultiplier"); -function sanitizeThemeInput(partialTheme = {}) { - const colors = partialTheme.colors || {}; - const typography = partialTheme.typography || partialTheme.font; - const corners = partialTheme.corners || partialTheme.radius; - const sanitizedColors = { - primary: ensureHex(colors.primary, DEFAULT_STORE_THEME.colors.primary), - secondary: ensureHex(colors.secondary, DEFAULT_STORE_THEME.colors.secondary), - accent: ensureHex(colors.accent, DEFAULT_STORE_THEME.colors.accent), - text: ensureHex(colors.text, DEFAULT_STORE_THEME.colors.text), - background: ensureHex(colors.background, DEFAULT_STORE_THEME.colors.background), - card: ensureHex(colors.card, DEFAULT_STORE_THEME.colors.card) - }; - const sanitizedTypography = { - fontId: ensureFontId(typography?.fontId ?? typography?.font ?? typography?.id) - }; - const sanitizedCorners = { - enabled: corners?.enabled !== void 0 ? Boolean(corners.enabled) : DEFAULT_STORE_THEME.corners.enabled, - radiusMultiplier: ensureRadiusMultiplier(corners?.radiusMultiplier ?? corners?.multiplier ?? corners?.value) - }; - return { - colors: sanitizedColors, - typography: sanitizedTypography, - corners: sanitizedCorners - }; -} -__name(sanitizeThemeInput, "sanitizeThemeInput"); -function deriveThemeDetails(theme) { - const { colors, typography, corners } = theme; - const { fontId } = typography; - const fontOption = FONT_LOOKUP[fontId] || FONT_LOOKUP[DEFAULT_STORE_THEME.typography.fontId]; - const radiusBase = corners.enabled ? corners.radiusMultiplier * BASE_RADIUS_PX : 0; - const derivedColors = { - onPrimary: getContrastColor(colors.primary), - onSecondary: getContrastColor(colors.secondary), - primaryHover: darken(colors.primary, 0.12), - secondaryHover: darken(colors.secondary, 0.12), - accentSoft: lighten(colors.accent, 0.4), - background: colors.background, - surface: "#ffffff", - mutedText: lighten(colors.text, 0.35) - }; - return { - colors: derivedColors, - typography: { - fontFamily: fontOption.stack, - fontLabel: fontOption.label - }, - corners: { - radiusPx: radiusBase, - radiusSm: corners.enabled ? Math.max(radiusBase * 0.5, 2) : 0, - radiusLg: corners.enabled ? radiusBase * 1.5 : 0 - } - }; -} -__name(deriveThemeDetails, "deriveThemeDetails"); -function buildCssVariables(theme) { - const base = sanitizeThemeInput(theme); - const derived = deriveThemeDetails(base); - return { - "--storefront-color-primary": base.colors.primary, - "--storefront-color-primary-hover": derived.colors.primaryHover, - "--storefront-color-primary-contrast": derived.colors.onPrimary, - "--storefront-color-secondary": base.colors.secondary, - "--storefront-color-secondary-hover": derived.colors.secondaryHover, - "--storefront-color-secondary-contrast": derived.colors.onSecondary, - "--storefront-color-accent": base.colors.accent, - "--storefront-color-accent-soft": derived.colors.accentSoft, - "--storefront-color-text": base.colors.text, - "--storefront-color-text-muted": derived.colors.mutedText, - "--storefront-color-background": derived.colors.background, - "--storefront-color-surface": derived.colors.surface, - "--storefront-color-card": base.colors.card, - "--storefront-font-family": derived.typography.fontFamily, - "--storefront-radius-base": `${derived.corners.radiusPx}px`, - "--storefront-radius-sm": `${derived.corners.radiusSm}px`, - "--storefront-radius-lg": `${derived.corners.radiusLg}px` - }; -} -__name(buildCssVariables, "buildCssVariables"); -function resolveStorefrontTheme(partialTheme = {}) { - const sanitized = sanitizeThemeInput(partialTheme.theme ?? partialTheme); - const merged = { - ...DEFAULT_STORE_THEME, - ...sanitized, - colors: { - ...DEFAULT_STORE_THEME.colors, - ...sanitized.colors - }, - typography: { - ...DEFAULT_STORE_THEME.typography, - ...sanitized.typography - }, - corners: { - ...DEFAULT_STORE_THEME.corners, - ...sanitized.corners - } - }; - const { typography, corners } = deriveThemeDetails(merged); - return { - ...merged, - typography: { - ...merged.typography, - fontFamily: typography.fontFamily, - fontLabel: typography.fontLabel - }, - corners: { - ...merged.corners, - radiusPx: corners.radiusPx, - radiusSm: corners.radiusSm, - radiusLg: corners.radiusLg - }, - meta: { - updatedAt: partialTheme.updatedAt ?? null - }, - cssVariables: buildCssVariables(merged) - }; -} -__name(resolveStorefrontTheme, "resolveStorefrontTheme"); - -// src/services/ThemeService.js -var ThemeService = class { - static { - __name(this, "ThemeService"); - } - constructor(env2) { - this.env = env2; - this.kv = getKVNamespace(env2); - } - /** - * Get storefront theme - */ - async getTheme() { - try { - const kvTheme = this.kv ? await this.kv.get(THEME_KV_KEY) : null; - let storedTheme = null; - if (kvTheme) { - try { - storedTheme = JSON.parse(kvTheme); - } catch (parseError) { - console.error("Invalid theme JSON in KV, falling back to defaults:", parseError); - } - } - return resolveStorefrontTheme(storedTheme || DEFAULT_STORE_THEME); - } catch (error3) { - console.error("Error fetching storefront theme:", error3); - return resolveStorefrontTheme(DEFAULT_STORE_THEME); - } - } - /** - * Update storefront theme - */ - async updateTheme(payload) { - if (!this.kv) { - throw new Error("KV namespace unavailable"); - } - const sanitized = sanitizeThemeInput(payload); - const record = { - theme: sanitized, - updatedAt: Date.now() - }; - await this.kv.put(THEME_KV_KEY, JSON.stringify(record)); - return resolveStorefrontTheme(record); - } - /** - * Reset storefront theme to defaults - */ - async resetTheme() { - if (!this.kv) { - throw new Error("KV namespace unavailable"); - } - await this.kv.delete(THEME_KV_KEY); - return resolveStorefrontTheme(DEFAULT_STORE_THEME); - } -}; - -// src/routes/public/storefront.js -var router3 = new Hono2(); -router3.get("/theme", asyncHandler(async (c) => { - const themeService = new ThemeService(c.env); - const theme = await themeService.getTheme(); - return c.json(theme); -})); -var storefront_default = router3; - -// src/routes/public/checkout.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/services/StripeService.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/stripe.esm.worker.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/platform/WebPlatformFunctions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/platform/PlatformFunctions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/net/FetchHttpClient.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/utils.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var qs = __toESM(require_lib(), 1); -var OPTIONS_KEYS = [ - "apiKey", - "idempotencyKey", - "stripeAccount", - "apiVersion", - "maxNetworkRetries", - "timeout", - "host", - "authenticator", - "stripeContext", - "additionalHeaders", - "streaming" -]; -function isOptionsHash(o) { - return o && typeof o === "object" && OPTIONS_KEYS.some((prop) => Object.prototype.hasOwnProperty.call(o, prop)); -} -__name(isOptionsHash, "isOptionsHash"); -function queryStringifyRequestData(data, apiMode) { - return qs.stringify(data, { - serializeDate: /* @__PURE__ */ __name((d) => Math.floor(d.getTime() / 1e3).toString(), "serializeDate"), - arrayFormat: apiMode == "v2" ? "repeat" : "indices" - }).replace(/%5B/g, "[").replace(/%5D/g, "]"); -} -__name(queryStringifyRequestData, "queryStringifyRequestData"); -var makeURLInterpolator = /* @__PURE__ */ (() => { - const rc = { - "\n": "\\n", - '"': '\\"', - "\u2028": "\\u2028", - "\u2029": "\\u2029" - }; - return (str) => { - const cleanString = str.replace(/["\n\r\u2028\u2029]/g, ($0) => rc[$0]); - return (outputs) => { - return cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) => { - const output = outputs[$1]; - if (isValidEncodeUriComponentType(output)) - return encodeURIComponent(output); - return ""; - }); - }; - }; -})(); -function isValidEncodeUriComponentType(value) { - return ["number", "string", "boolean"].includes(typeof value); -} -__name(isValidEncodeUriComponentType, "isValidEncodeUriComponentType"); -function extractUrlParams(path) { - const params = path.match(/\{\w+\}/g); - if (!params) { - return []; - } - return params.map((param) => param.replace(/[{}]/g, "")); -} -__name(extractUrlParams, "extractUrlParams"); -function getDataFromArgs(args) { - if (!Array.isArray(args) || !args[0] || typeof args[0] !== "object") { - return {}; - } - if (!isOptionsHash(args[0])) { - return args.shift(); - } - const argKeys = Object.keys(args[0]); - const optionKeysInArgs = argKeys.filter((key) => OPTIONS_KEYS.includes(key)); - if (optionKeysInArgs.length > 0 && optionKeysInArgs.length !== argKeys.length) { - emitWarning2(`Options found in arguments (${optionKeysInArgs.join(", ")}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.`); - } - return {}; -} -__name(getDataFromArgs, "getDataFromArgs"); -function getOptionsFromArgs(args) { - const opts = { - host: null, - headers: {}, - settings: {}, - streaming: false - }; - if (args.length > 0) { - const arg = args[args.length - 1]; - if (typeof arg === "string") { - opts.authenticator = createApiKeyAuthenticator(args.pop()); - } else if (isOptionsHash(arg)) { - const params = Object.assign({}, args.pop()); - const extraKeys = Object.keys(params).filter((key) => !OPTIONS_KEYS.includes(key)); - if (extraKeys.length) { - emitWarning2(`Invalid options found (${extraKeys.join(", ")}); ignoring.`); - } - if (params.apiKey) { - opts.authenticator = createApiKeyAuthenticator(params.apiKey); - } - if (params.idempotencyKey) { - opts.headers["Idempotency-Key"] = params.idempotencyKey; - } - if (params.stripeAccount) { - opts.headers["Stripe-Account"] = params.stripeAccount; - } - if (params.stripeContext) { - if (opts.headers["Stripe-Account"]) { - throw new Error("Can't specify both stripeAccount and stripeContext."); - } - opts.headers["Stripe-Context"] = params.stripeContext; - } - if (params.apiVersion) { - opts.headers["Stripe-Version"] = params.apiVersion; - } - if (Number.isInteger(params.maxNetworkRetries)) { - opts.settings.maxNetworkRetries = params.maxNetworkRetries; - } - if (Number.isInteger(params.timeout)) { - opts.settings.timeout = params.timeout; - } - if (params.host) { - opts.host = params.host; - } - if (params.authenticator) { - if (params.apiKey) { - throw new Error("Can't specify both apiKey and authenticator."); - } - if (typeof params.authenticator !== "function") { - throw new Error("The authenticator must be a function receiving a request as the first parameter."); - } - opts.authenticator = params.authenticator; - } - if (params.additionalHeaders) { - opts.headers = params.additionalHeaders; - } - if (params.streaming) { - opts.streaming = true; - } - } - } - return opts; -} -__name(getOptionsFromArgs, "getOptionsFromArgs"); -function protoExtend(sub) { - const Super = this; - const Constructor = Object.prototype.hasOwnProperty.call(sub, "constructor") ? sub.constructor : function(...args) { - Super.apply(this, args); - }; - Object.assign(Constructor, Super); - Constructor.prototype = Object.create(Super.prototype); - Object.assign(Constructor.prototype, sub); - return Constructor; -} -__name(protoExtend, "protoExtend"); -function removeNullish(obj) { - if (typeof obj !== "object") { - throw new Error("Argument must be an object"); - } - return Object.keys(obj).reduce((result, key) => { - if (obj[key] != null) { - result[key] = obj[key]; - } - return result; - }, {}); -} -__name(removeNullish, "removeNullish"); -function normalizeHeaders(obj) { - if (!(obj && typeof obj === "object")) { - return obj; - } - return Object.keys(obj).reduce((result, header) => { - result[normalizeHeader(header)] = obj[header]; - return result; - }, {}); -} -__name(normalizeHeaders, "normalizeHeaders"); -function normalizeHeader(header) { - return header.split("-").map((text) => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase()).join("-"); -} -__name(normalizeHeader, "normalizeHeader"); -function callbackifyPromiseWithTimeout(promise, callback) { - if (callback) { - return promise.then((res) => { - setTimeout(() => { - callback(null, res); - }, 0); - }, (err) => { - setTimeout(() => { - callback(err, null); - }, 0); - }); - } - return promise; -} -__name(callbackifyPromiseWithTimeout, "callbackifyPromiseWithTimeout"); -function pascalToCamelCase(name) { - if (name === "OAuth") { - return "oauth"; - } else { - return name[0].toLowerCase() + name.substring(1); - } -} -__name(pascalToCamelCase, "pascalToCamelCase"); -function emitWarning2(warning) { - if (typeof process.emitWarning !== "function") { - return console.warn(`Stripe: ${warning}`); - } - return process.emitWarning(warning, "Stripe"); -} -__name(emitWarning2, "emitWarning"); -function isObject(obj) { - const type = typeof obj; - return (type === "function" || type === "object") && !!obj; -} -__name(isObject, "isObject"); -function flattenAndStringify(data) { - const result = {}; - const step = /* @__PURE__ */ __name((obj, prevKey) => { - Object.entries(obj).forEach(([key, value]) => { - const newKey = prevKey ? `${prevKey}[${key}]` : key; - if (isObject(value)) { - if (!(value instanceof Uint8Array) && !Object.prototype.hasOwnProperty.call(value, "data")) { - return step(value, newKey); - } else { - result[newKey] = value; - } - } else { - result[newKey] = String(value); - } - }); - }, "step"); - step(data, null); - return result; -} -__name(flattenAndStringify, "flattenAndStringify"); -function validateInteger(name, n, defaultVal) { - if (!Number.isInteger(n)) { - if (defaultVal !== void 0) { - return defaultVal; - } else { - throw new Error(`${name} must be an integer`); - } - } - return n; -} -__name(validateInteger, "validateInteger"); -function determineProcessUserAgentProperties() { - return typeof process === "undefined" ? {} : { - lang_version: process.version, - platform: process.platform - }; -} -__name(determineProcessUserAgentProperties, "determineProcessUserAgentProperties"); -function createApiKeyAuthenticator(apiKey) { - const authenticator = /* @__PURE__ */ __name((request) => { - request.headers.Authorization = "Bearer " + apiKey; - return Promise.resolve(); - }, "authenticator"); - authenticator._apiKey = apiKey; - return authenticator; -} -__name(createApiKeyAuthenticator, "createApiKeyAuthenticator"); -function dateTimeReplacer(key, value) { - if (this[key] instanceof Date) { - return Math.floor(this[key].getTime() / 1e3).toString(); - } - return value; -} -__name(dateTimeReplacer, "dateTimeReplacer"); -function jsonStringifyRequestData(data) { - return JSON.stringify(data, dateTimeReplacer); -} -__name(jsonStringifyRequestData, "jsonStringifyRequestData"); -function getAPIMode(path) { - if (!path) { - return "v1"; - } - return path.startsWith("/v2") ? "v2" : "v1"; -} -__name(getAPIMode, "getAPIMode"); -function parseHttpHeaderAsString(header) { - if (Array.isArray(header)) { - return header.join(", "); - } - return String(header); -} -__name(parseHttpHeaderAsString, "parseHttpHeaderAsString"); -function parseHttpHeaderAsNumber(header) { - const number = Array.isArray(header) ? header[0] : header; - return Number(number); -} -__name(parseHttpHeaderAsNumber, "parseHttpHeaderAsNumber"); -function parseHeadersForFetch(headers) { - return Object.entries(headers).map(([key, value]) => { - return [key, parseHttpHeaderAsString(value)]; - }); -} -__name(parseHeadersForFetch, "parseHeadersForFetch"); - -// node_modules/stripe/esm/net/HttpClient.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var HttpClient = class _HttpClient { - static { - __name(this, "HttpClient"); - } - /** The client name used for diagnostics. */ - getClientName() { - throw new Error("getClientName not implemented."); - } - makeRequest(host, port, path, method, headers, requestData, protocol, timeout) { - throw new Error("makeRequest not implemented."); - } - /** Helper to make a consistent timeout error across implementations. */ - static makeTimeoutError() { - const timeoutErr = new TypeError(_HttpClient.TIMEOUT_ERROR_CODE); - timeoutErr.code = _HttpClient.TIMEOUT_ERROR_CODE; - return timeoutErr; - } -}; -HttpClient.CONNECTION_CLOSED_ERROR_CODES = ["ECONNRESET", "EPIPE"]; -HttpClient.TIMEOUT_ERROR_CODE = "ETIMEDOUT"; -var HttpClientResponse = class { - static { - __name(this, "HttpClientResponse"); - } - constructor(statusCode, headers) { - this._statusCode = statusCode; - this._headers = headers; - } - getStatusCode() { - return this._statusCode; - } - getHeaders() { - return this._headers; - } - getRawResponse() { - throw new Error("getRawResponse not implemented."); - } - toStream(streamCompleteCallback) { - throw new Error("toStream not implemented."); - } - toJSON() { - throw new Error("toJSON not implemented."); - } -}; - -// node_modules/stripe/esm/net/FetchHttpClient.js -var FetchHttpClient = class _FetchHttpClient extends HttpClient { - static { - __name(this, "FetchHttpClient"); - } - constructor(fetchFn) { - super(); - if (!fetchFn) { - if (!globalThis.fetch) { - throw new Error("fetch() function not provided and is not defined in the global scope. You must provide a fetch implementation."); - } - fetchFn = globalThis.fetch; - } - if (globalThis.AbortController) { - this._fetchFn = _FetchHttpClient.makeFetchWithAbortTimeout(fetchFn); - } else { - this._fetchFn = _FetchHttpClient.makeFetchWithRaceTimeout(fetchFn); - } - } - static makeFetchWithRaceTimeout(fetchFn) { - return (url, init, timeout) => { - let pendingTimeoutId; - const timeoutPromise = new Promise((_, reject) => { - pendingTimeoutId = setTimeout(() => { - pendingTimeoutId = null; - reject(HttpClient.makeTimeoutError()); - }, timeout); - }); - const fetchPromise = fetchFn(url, init); - return Promise.race([fetchPromise, timeoutPromise]).finally(() => { - if (pendingTimeoutId) { - clearTimeout(pendingTimeoutId); - } - }); - }; - } - static makeFetchWithAbortTimeout(fetchFn) { - return async (url, init, timeout) => { - const abort2 = new AbortController(); - let timeoutId = setTimeout(() => { - timeoutId = null; - abort2.abort(HttpClient.makeTimeoutError()); - }, timeout); - try { - return await fetchFn(url, Object.assign(Object.assign({}, init), { signal: abort2.signal })); - } catch (err) { - if (err.name === "AbortError") { - throw HttpClient.makeTimeoutError(); - } else { - throw err; - } - } finally { - if (timeoutId) { - clearTimeout(timeoutId); - } - } - }; - } - /** @override. */ - getClientName() { - return "fetch"; - } - async makeRequest(host, port, path, method, headers, requestData, protocol, timeout) { - const isInsecureConnection = protocol === "http"; - const url = new URL(path, `${isInsecureConnection ? "http" : "https"}://${host}`); - url.port = port; - const methodHasPayload = method == "POST" || method == "PUT" || method == "PATCH"; - const body = requestData || (methodHasPayload ? "" : void 0); - const res = await this._fetchFn(url.toString(), { - method, - headers: parseHeadersForFetch(headers), - body: typeof body === "object" ? JSON.stringify(body) : body - }, timeout); - return new FetchHttpClientResponse(res); - } -}; -var FetchHttpClientResponse = class _FetchHttpClientResponse extends HttpClientResponse { - static { - __name(this, "FetchHttpClientResponse"); - } - constructor(res) { - super(res.status, _FetchHttpClientResponse._transformHeadersToObject(res.headers)); - this._res = res; - } - getRawResponse() { - return this._res; - } - toStream(streamCompleteCallback) { - streamCompleteCallback(); - return this._res.body; - } - toJSON() { - return this._res.json(); - } - static _transformHeadersToObject(headers) { - const headersObj = {}; - for (const entry of headers) { - if (!Array.isArray(entry) || entry.length != 2) { - throw new Error("Response objects produced by the fetch function given to FetchHttpClient do not have an iterable headers map. Response#headers should be an iterable object."); - } - headersObj[entry[0]] = entry[1]; - } - return headersObj; - } -}; - -// node_modules/stripe/esm/crypto/SubtleCryptoProvider.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/crypto/CryptoProvider.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var CryptoProvider = class { - static { - __name(this, "CryptoProvider"); - } - /** - * Computes a SHA-256 HMAC given a secret and a payload (encoded in UTF-8). - * The output HMAC should be encoded in hexadecimal. - * - * Sample values for implementations: - * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' - * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 - */ - computeHMACSignature(payload, secret) { - throw new Error("computeHMACSignature not implemented."); - } - /** - * Asynchronous version of `computeHMACSignature`. Some implementations may - * only allow support async signature computation. - * - * Computes a SHA-256 HMAC given a secret and a payload (encoded in UTF-8). - * The output HMAC should be encoded in hexadecimal. - * - * Sample values for implementations: - * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' - * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 - */ - computeHMACSignatureAsync(payload, secret) { - throw new Error("computeHMACSignatureAsync not implemented."); - } - /** - * Computes a SHA-256 hash of the data. - */ - computeSHA256Async(data) { - throw new Error("computeSHA256 not implemented."); - } -}; -var CryptoProviderOnlySupportsAsyncError = class extends Error { - static { - __name(this, "CryptoProviderOnlySupportsAsyncError"); - } -}; - -// node_modules/stripe/esm/crypto/SubtleCryptoProvider.js -var SubtleCryptoProvider = class extends CryptoProvider { - static { - __name(this, "SubtleCryptoProvider"); - } - constructor(subtleCrypto) { - super(); - this.subtleCrypto = subtleCrypto || crypto.subtle; - } - /** @override */ - computeHMACSignature(payload, secret) { - throw new CryptoProviderOnlySupportsAsyncError("SubtleCryptoProvider cannot be used in a synchronous context."); - } - /** @override */ - async computeHMACSignatureAsync(payload, secret) { - const encoder = new TextEncoder(); - const key = await this.subtleCrypto.importKey("raw", encoder.encode(secret), { - name: "HMAC", - hash: { name: "SHA-256" } - }, false, ["sign"]); - const signatureBuffer = await this.subtleCrypto.sign("hmac", key, encoder.encode(payload)); - const signatureBytes = new Uint8Array(signatureBuffer); - const signatureHexCodes = new Array(signatureBytes.length); - for (let i = 0; i < signatureBytes.length; i++) { - signatureHexCodes[i] = byteHexMapping[signatureBytes[i]]; - } - return signatureHexCodes.join(""); - } - /** @override */ - async computeSHA256Async(data) { - return new Uint8Array(await this.subtleCrypto.digest("SHA-256", data)); - } -}; -var byteHexMapping = new Array(256); -for (let i = 0; i < byteHexMapping.length; i++) { - byteHexMapping[i] = i.toString(16).padStart(2, "0"); -} - -// node_modules/stripe/esm/platform/PlatformFunctions.js -var PlatformFunctions = class { - static { - __name(this, "PlatformFunctions"); - } - constructor() { - this._fetchFn = null; - this._agent = null; - } - /** - * Gets uname with Node's built-in `exec` function, if available. - */ - getUname() { - throw new Error("getUname not implemented."); - } - /** - * Generates a v4 UUID. See https://stackoverflow.com/a/2117523 - */ - uuid4() { - return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => { - const r = Math.random() * 16 | 0; - const v = c === "x" ? r : r & 3 | 8; - return v.toString(16); - }); - } - /** - * Compares strings in constant time. - */ - secureCompare(a, b) { - if (a.length !== b.length) { - return false; - } - const len = a.length; - let result = 0; - for (let i = 0; i < len; ++i) { - result |= a.charCodeAt(i) ^ b.charCodeAt(i); - } - return result === 0; - } - /** - * Creates an event emitter. - */ - createEmitter() { - throw new Error("createEmitter not implemented."); - } - /** - * Checks if the request data is a stream. If so, read the entire stream - * to a buffer and return the buffer. - */ - tryBufferData(data) { - throw new Error("tryBufferData not implemented."); - } - /** - * Creates an HTTP client which uses the Node `http` and `https` packages - * to issue requests. - */ - createNodeHttpClient(agent) { - throw new Error("createNodeHttpClient not implemented."); - } - /** - * Creates an HTTP client for issuing Stripe API requests which uses the Web - * Fetch API. - * - * A fetch function can optionally be passed in as a parameter. If none is - * passed, will default to the default `fetch` function in the global scope. - */ - createFetchHttpClient(fetchFn) { - return new FetchHttpClient(fetchFn); - } - /** - * Creates an HTTP client using runtime-specific APIs. - */ - createDefaultHttpClient() { - throw new Error("createDefaultHttpClient not implemented."); - } - /** - * Creates a CryptoProvider which uses the Node `crypto` package for its computations. - */ - createNodeCryptoProvider() { - throw new Error("createNodeCryptoProvider not implemented."); - } - /** - * Creates a CryptoProvider which uses the SubtleCrypto interface of the Web Crypto API. - */ - createSubtleCryptoProvider(subtleCrypto) { - return new SubtleCryptoProvider(subtleCrypto); - } - createDefaultCryptoProvider() { - throw new Error("createDefaultCryptoProvider not implemented."); - } -}; - -// node_modules/stripe/esm/StripeEmitter.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var _StripeEvent = class extends Event { - static { - __name(this, "_StripeEvent"); - } - constructor(eventName, data) { - super(eventName); - this.data = data; - } -}; -var StripeEmitter = class { - static { - __name(this, "StripeEmitter"); - } - constructor() { - this.eventTarget = new EventTarget(); - this.listenerMapping = /* @__PURE__ */ new Map(); - } - on(eventName, listener) { - const listenerWrapper = /* @__PURE__ */ __name((event) => { - listener(event.data); - }, "listenerWrapper"); - this.listenerMapping.set(listener, listenerWrapper); - return this.eventTarget.addEventListener(eventName, listenerWrapper); - } - removeListener(eventName, listener) { - const listenerWrapper = this.listenerMapping.get(listener); - this.listenerMapping.delete(listener); - return this.eventTarget.removeEventListener(eventName, listenerWrapper); - } - once(eventName, listener) { - const listenerWrapper = /* @__PURE__ */ __name((event) => { - listener(event.data); - }, "listenerWrapper"); - this.listenerMapping.set(listener, listenerWrapper); - return this.eventTarget.addEventListener(eventName, listenerWrapper, { - once: true - }); - } - emit(eventName, data) { - return this.eventTarget.dispatchEvent(new _StripeEvent(eventName, data)); - } -}; - -// node_modules/stripe/esm/platform/WebPlatformFunctions.js -var WebPlatformFunctions = class extends PlatformFunctions { - static { - __name(this, "WebPlatformFunctions"); - } - /** @override */ - getUname() { - return Promise.resolve(null); - } - /** @override */ - createEmitter() { - return new StripeEmitter(); - } - /** @override */ - tryBufferData(data) { - if (data.file.data instanceof ReadableStream) { - throw new Error("Uploading a file as a stream is not supported in non-Node environments. Please open or upvote an issue at github.com/stripe/stripe-node if you use this, detailing your use-case."); - } - return Promise.resolve(data); - } - /** @override */ - createNodeHttpClient() { - throw new Error("Stripe: `createNodeHttpClient()` is not available in non-Node environments. Please use `createFetchHttpClient()` instead."); - } - /** @override */ - createDefaultHttpClient() { - return super.createFetchHttpClient(); - } - /** @override */ - createNodeCryptoProvider() { - throw new Error("Stripe: `createNodeCryptoProvider()` is not available in non-Node environments. Please use `createSubtleCryptoProvider()` instead."); - } - /** @override */ - createDefaultCryptoProvider() { - return this.createSubtleCryptoProvider(); - } -}; - -// node_modules/stripe/esm/stripe.core.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/Error.js -var Error_exports = {}; -__export(Error_exports, { - StripeAPIError: () => StripeAPIError, - StripeAuthenticationError: () => StripeAuthenticationError, - StripeCardError: () => StripeCardError, - StripeConnectionError: () => StripeConnectionError, - StripeError: () => StripeError, - StripeIdempotencyError: () => StripeIdempotencyError, - StripeInvalidGrantError: () => StripeInvalidGrantError, - StripeInvalidRequestError: () => StripeInvalidRequestError, - StripePermissionError: () => StripePermissionError, - StripeRateLimitError: () => StripeRateLimitError, - StripeSignatureVerificationError: () => StripeSignatureVerificationError, - StripeUnknownError: () => StripeUnknownError, - TemporarySessionExpiredError: () => TemporarySessionExpiredError, - generateV1Error: () => generateV1Error, - generateV2Error: () => generateV2Error -}); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var generateV1Error = /* @__PURE__ */ __name((rawStripeError) => { - switch (rawStripeError.type) { - case "card_error": - return new StripeCardError(rawStripeError); - case "invalid_request_error": - return new StripeInvalidRequestError(rawStripeError); - case "api_error": - return new StripeAPIError(rawStripeError); - case "authentication_error": - return new StripeAuthenticationError(rawStripeError); - case "rate_limit_error": - return new StripeRateLimitError(rawStripeError); - case "idempotency_error": - return new StripeIdempotencyError(rawStripeError); - case "invalid_grant": - return new StripeInvalidGrantError(rawStripeError); - default: - return new StripeUnknownError(rawStripeError); - } -}, "generateV1Error"); -var generateV2Error = /* @__PURE__ */ __name((rawStripeError) => { - switch (rawStripeError.type) { - // switchCases: The beginning of the section generated from our OpenAPI spec - case "temporary_session_expired": - return new TemporarySessionExpiredError(rawStripeError); - } - switch (rawStripeError.code) { - case "invalid_fields": - return new StripeInvalidRequestError(rawStripeError); - } - return generateV1Error(rawStripeError); -}, "generateV2Error"); -var StripeError = class extends Error { - static { - __name(this, "StripeError"); - } - constructor(raw2 = {}, type = null) { - var _a; - super(raw2.message); - this.type = type || this.constructor.name; - this.raw = raw2; - this.rawType = raw2.type; - this.code = raw2.code; - this.doc_url = raw2.doc_url; - this.param = raw2.param; - this.detail = raw2.detail; - this.headers = raw2.headers; - this.requestId = raw2.requestId; - this.statusCode = raw2.statusCode; - this.message = (_a = raw2.message) !== null && _a !== void 0 ? _a : ""; - this.userMessage = raw2.user_message; - this.charge = raw2.charge; - this.decline_code = raw2.decline_code; - this.payment_intent = raw2.payment_intent; - this.payment_method = raw2.payment_method; - this.payment_method_type = raw2.payment_method_type; - this.setup_intent = raw2.setup_intent; - this.source = raw2.source; - } -}; -StripeError.generate = generateV1Error; -var StripeCardError = class extends StripeError { - static { - __name(this, "StripeCardError"); - } - constructor(raw2 = {}) { - super(raw2, "StripeCardError"); - } -}; -var StripeInvalidRequestError = class extends StripeError { - static { - __name(this, "StripeInvalidRequestError"); - } - constructor(raw2 = {}) { - super(raw2, "StripeInvalidRequestError"); - } -}; -var StripeAPIError = class extends StripeError { - static { - __name(this, "StripeAPIError"); - } - constructor(raw2 = {}) { - super(raw2, "StripeAPIError"); - } -}; -var StripeAuthenticationError = class extends StripeError { - static { - __name(this, "StripeAuthenticationError"); - } - constructor(raw2 = {}) { - super(raw2, "StripeAuthenticationError"); - } -}; -var StripePermissionError = class extends StripeError { - static { - __name(this, "StripePermissionError"); - } - constructor(raw2 = {}) { - super(raw2, "StripePermissionError"); - } -}; -var StripeRateLimitError = class extends StripeError { - static { - __name(this, "StripeRateLimitError"); - } - constructor(raw2 = {}) { - super(raw2, "StripeRateLimitError"); - } -}; -var StripeConnectionError = class extends StripeError { - static { - __name(this, "StripeConnectionError"); - } - constructor(raw2 = {}) { - super(raw2, "StripeConnectionError"); - } -}; -var StripeSignatureVerificationError = class extends StripeError { - static { - __name(this, "StripeSignatureVerificationError"); - } - constructor(header, payload, raw2 = {}) { - super(raw2, "StripeSignatureVerificationError"); - this.header = header; - this.payload = payload; - } -}; -var StripeIdempotencyError = class extends StripeError { - static { - __name(this, "StripeIdempotencyError"); - } - constructor(raw2 = {}) { - super(raw2, "StripeIdempotencyError"); - } -}; -var StripeInvalidGrantError = class extends StripeError { - static { - __name(this, "StripeInvalidGrantError"); - } - constructor(raw2 = {}) { - super(raw2, "StripeInvalidGrantError"); - } -}; -var StripeUnknownError = class extends StripeError { - static { - __name(this, "StripeUnknownError"); - } - constructor(raw2 = {}) { - super(raw2, "StripeUnknownError"); - } -}; -var TemporarySessionExpiredError = class extends StripeError { - static { - __name(this, "TemporarySessionExpiredError"); - } - constructor(rawStripeError = {}) { - super(rawStripeError, "TemporarySessionExpiredError"); - } -}; - -// node_modules/stripe/esm/RequestSender.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var MAX_RETRY_AFTER_WAIT = 60; -var RequestSender = class _RequestSender { - static { - __name(this, "RequestSender"); - } - constructor(stripe, maxBufferedRequestMetric) { - this._stripe = stripe; - this._maxBufferedRequestMetric = maxBufferedRequestMetric; - } - _addHeadersDirectlyToObject(obj, headers) { - obj.requestId = headers["request-id"]; - obj.stripeAccount = obj.stripeAccount || headers["stripe-account"]; - obj.apiVersion = obj.apiVersion || headers["stripe-version"]; - obj.idempotencyKey = obj.idempotencyKey || headers["idempotency-key"]; - } - _makeResponseEvent(requestEvent, statusCode, headers) { - const requestEndTime = Date.now(); - const requestDurationMs = requestEndTime - requestEvent.request_start_time; - return removeNullish({ - api_version: headers["stripe-version"], - account: headers["stripe-account"], - idempotency_key: headers["idempotency-key"], - method: requestEvent.method, - path: requestEvent.path, - status: statusCode, - request_id: this._getRequestId(headers), - elapsed: requestDurationMs, - request_start_time: requestEvent.request_start_time, - request_end_time: requestEndTime - }); - } - _getRequestId(headers) { - return headers["request-id"]; - } - /** - * Used by methods with spec.streaming === true. For these methods, we do not - * buffer successful responses into memory or do parse them into stripe - * objects, we delegate that all of that to the user and pass back the raw - * http.Response object to the callback. - * - * (Unsuccessful responses shouldn't make it here, they should - * still be buffered/parsed and handled by _jsonResponseHandler -- see - * makeRequest) - */ - _streamingResponseHandler(requestEvent, usage, callback) { - return (res) => { - const headers = res.getHeaders(); - const streamCompleteCallback = /* @__PURE__ */ __name(() => { - const responseEvent = this._makeResponseEvent(requestEvent, res.getStatusCode(), headers); - this._stripe._emitter.emit("response", responseEvent); - this._recordRequestMetrics(this._getRequestId(headers), responseEvent.elapsed, usage); - }, "streamCompleteCallback"); - const stream = res.toStream(streamCompleteCallback); - this._addHeadersDirectlyToObject(stream, headers); - return callback(null, stream); - }; - } - /** - * Default handler for Stripe responses. Buffers the response into memory, - * parses the JSON and returns it (i.e. passes it to the callback) if there - * is no "error" field. Otherwise constructs/passes an appropriate Error. - */ - _jsonResponseHandler(requestEvent, apiMode, usage, callback) { - return (res) => { - const headers = res.getHeaders(); - const requestId = this._getRequestId(headers); - const statusCode = res.getStatusCode(); - const responseEvent = this._makeResponseEvent(requestEvent, statusCode, headers); - this._stripe._emitter.emit("response", responseEvent); - res.toJSON().then((jsonResponse) => { - if (jsonResponse.error) { - let err; - if (typeof jsonResponse.error === "string") { - jsonResponse.error = { - type: jsonResponse.error, - message: jsonResponse.error_description - }; - } - jsonResponse.error.headers = headers; - jsonResponse.error.statusCode = statusCode; - jsonResponse.error.requestId = requestId; - if (statusCode === 401) { - err = new StripeAuthenticationError(jsonResponse.error); - } else if (statusCode === 403) { - err = new StripePermissionError(jsonResponse.error); - } else if (statusCode === 429) { - err = new StripeRateLimitError(jsonResponse.error); - } else if (apiMode === "v2") { - err = generateV2Error(jsonResponse.error); - } else { - err = generateV1Error(jsonResponse.error); - } - throw err; - } - return jsonResponse; - }, (e) => { - throw new StripeAPIError({ - message: "Invalid JSON received from the Stripe API", - exception: e, - requestId: headers["request-id"] - }); - }).then((jsonResponse) => { - this._recordRequestMetrics(requestId, responseEvent.elapsed, usage); - const rawResponse = res.getRawResponse(); - this._addHeadersDirectlyToObject(rawResponse, headers); - Object.defineProperty(jsonResponse, "lastResponse", { - enumerable: false, - writable: false, - value: rawResponse - }); - callback(null, jsonResponse); - }, (e) => callback(e, null)); - }; - } - static _generateConnectionErrorMessage(requestRetries) { - return `An error occurred with our connection to Stripe.${requestRetries > 0 ? ` Request was retried ${requestRetries} times.` : ""}`; - } - // For more on when and how to retry API requests, see https://stripe.com/docs/error-handling#safely-retrying-requests-with-idempotency - static _shouldRetry(res, numRetries, maxRetries, error3) { - if (error3 && numRetries === 0 && HttpClient.CONNECTION_CLOSED_ERROR_CODES.includes(error3.code)) { - return true; - } - if (numRetries >= maxRetries) { - return false; - } - if (!res) { - return true; - } - if (res.getHeaders()["stripe-should-retry"] === "false") { - return false; - } - if (res.getHeaders()["stripe-should-retry"] === "true") { - return true; - } - if (res.getStatusCode() === 409) { - return true; - } - if (res.getStatusCode() >= 500) { - return true; - } - return false; - } - _getSleepTimeInMS(numRetries, retryAfter = null) { - const initialNetworkRetryDelay = this._stripe.getInitialNetworkRetryDelay(); - const maxNetworkRetryDelay = this._stripe.getMaxNetworkRetryDelay(); - let sleepSeconds = Math.min(initialNetworkRetryDelay * Math.pow(2, numRetries - 1), maxNetworkRetryDelay); - sleepSeconds *= 0.5 * (1 + Math.random()); - sleepSeconds = Math.max(initialNetworkRetryDelay, sleepSeconds); - if (Number.isInteger(retryAfter) && retryAfter <= MAX_RETRY_AFTER_WAIT) { - sleepSeconds = Math.max(sleepSeconds, retryAfter); - } - return sleepSeconds * 1e3; - } - // Max retries can be set on a per request basis. Favor those over the global setting - _getMaxNetworkRetries(settings = {}) { - return settings.maxNetworkRetries !== void 0 && Number.isInteger(settings.maxNetworkRetries) ? settings.maxNetworkRetries : this._stripe.getMaxNetworkRetries(); - } - _defaultIdempotencyKey(method, settings, apiMode) { - const maxRetries = this._getMaxNetworkRetries(settings); - const genKey = /* @__PURE__ */ __name(() => `stripe-node-retry-${this._stripe._platformFunctions.uuid4()}`, "genKey"); - if (apiMode === "v2") { - if (method === "POST" || method === "DELETE") { - return genKey(); - } - } else if (apiMode === "v1") { - if (method === "POST" && maxRetries > 0) { - return genKey(); - } - } - return null; - } - _makeHeaders({ contentType, contentLength, apiVersion, clientUserAgent, method, userSuppliedHeaders, userSuppliedSettings, stripeAccount, stripeContext, apiMode }) { - const defaultHeaders = { - Accept: "application/json", - "Content-Type": contentType, - "User-Agent": this._getUserAgentString(apiMode), - "X-Stripe-Client-User-Agent": clientUserAgent, - "X-Stripe-Client-Telemetry": this._getTelemetryHeader(), - "Stripe-Version": apiVersion, - "Stripe-Account": stripeAccount, - "Stripe-Context": stripeContext, - "Idempotency-Key": this._defaultIdempotencyKey(method, userSuppliedSettings, apiMode) - }; - const methodHasPayload = method == "POST" || method == "PUT" || method == "PATCH"; - if (methodHasPayload || contentLength) { - if (!methodHasPayload) { - emitWarning2(`${method} method had non-zero contentLength but no payload is expected for this verb`); - } - defaultHeaders["Content-Length"] = contentLength; - } - return Object.assign( - removeNullish(defaultHeaders), - // If the user supplied, say 'idempotency-key', override instead of appending by ensuring caps are the same. - normalizeHeaders(userSuppliedHeaders) - ); - } - _getUserAgentString(apiMode) { - const packageVersion = this._stripe.getConstant("PACKAGE_VERSION"); - const appInfo = this._stripe._appInfo ? this._stripe.getAppInfoAsString() : ""; - return `Stripe/${apiMode} NodeBindings/${packageVersion} ${appInfo}`.trim(); - } - _getTelemetryHeader() { - if (this._stripe.getTelemetryEnabled() && this._stripe._prevRequestMetrics.length > 0) { - const metrics = this._stripe._prevRequestMetrics.shift(); - return JSON.stringify({ - last_request_metrics: metrics - }); - } - } - _recordRequestMetrics(requestId, requestDurationMs, usage) { - if (this._stripe.getTelemetryEnabled() && requestId) { - if (this._stripe._prevRequestMetrics.length > this._maxBufferedRequestMetric) { - emitWarning2("Request metrics buffer is full, dropping telemetry message."); - } else { - const m = { - request_id: requestId, - request_duration_ms: requestDurationMs - }; - if (usage && usage.length > 0) { - m.usage = usage; - } - this._stripe._prevRequestMetrics.push(m); - } - } - } - _rawRequest(method, path, params, options) { - const requestPromise = new Promise((resolve, reject) => { - let opts; - try { - const requestMethod = method.toUpperCase(); - if (requestMethod !== "POST" && params && Object.keys(params).length !== 0) { - throw new Error("rawRequest only supports params on POST requests. Please pass null and add your parameters to path."); - } - const args = [].slice.call([params, options]); - const dataFromArgs = getDataFromArgs(args); - const data = requestMethod === "POST" ? Object.assign({}, dataFromArgs) : null; - const calculatedOptions = getOptionsFromArgs(args); - const headers2 = calculatedOptions.headers; - const authenticator2 = calculatedOptions.authenticator; - opts = { - requestMethod, - requestPath: path, - bodyData: data, - queryData: {}, - authenticator: authenticator2, - headers: headers2, - host: calculatedOptions.host, - streaming: !!calculatedOptions.streaming, - settings: {}, - usage: ["raw_request"] - }; - } catch (err) { - reject(err); - return; - } - function requestCallback(err, response) { - if (err) { - reject(err); - } else { - resolve(response); - } - } - __name(requestCallback, "requestCallback"); - const { headers, settings } = opts; - const authenticator = opts.authenticator; - this._request(opts.requestMethod, opts.host, path, opts.bodyData, authenticator, { headers, settings, streaming: opts.streaming }, opts.usage, requestCallback); - }); - return requestPromise; - } - _request(method, host, path, data, authenticator, options, usage = [], callback, requestDataProcessor = null) { - var _a; - let requestData; - authenticator = (_a = authenticator !== null && authenticator !== void 0 ? authenticator : this._stripe._authenticator) !== null && _a !== void 0 ? _a : null; - const apiMode = getAPIMode(path); - const retryRequest = /* @__PURE__ */ __name((requestFn, apiVersion, headers, requestRetries, retryAfter) => { - return setTimeout(requestFn, this._getSleepTimeInMS(requestRetries, retryAfter), apiVersion, headers, requestRetries + 1); - }, "retryRequest"); - const makeRequest = /* @__PURE__ */ __name((apiVersion, headers, numRetries) => { - const timeout = options.settings && options.settings.timeout && Number.isInteger(options.settings.timeout) && options.settings.timeout >= 0 ? options.settings.timeout : this._stripe.getApiField("timeout"); - const request = { - host: host || this._stripe.getApiField("host"), - port: this._stripe.getApiField("port"), - path, - method, - headers: Object.assign({}, headers), - body: requestData, - protocol: this._stripe.getApiField("protocol") - }; - authenticator(request).then(() => { - const req = this._stripe.getApiField("httpClient").makeRequest(request.host, request.port, request.path, request.method, request.headers, request.body, request.protocol, timeout); - const requestStartTime = Date.now(); - const requestEvent = removeNullish({ - api_version: apiVersion, - account: parseHttpHeaderAsString(headers["Stripe-Account"]), - idempotency_key: parseHttpHeaderAsString(headers["Idempotency-Key"]), - method, - path, - request_start_time: requestStartTime - }); - const requestRetries = numRetries || 0; - const maxRetries = this._getMaxNetworkRetries(options.settings || {}); - this._stripe._emitter.emit("request", requestEvent); - req.then((res) => { - if (_RequestSender._shouldRetry(res, requestRetries, maxRetries)) { - return retryRequest(makeRequest, apiVersion, headers, requestRetries, parseHttpHeaderAsNumber(res.getHeaders()["retry-after"])); - } else if (options.streaming && res.getStatusCode() < 400) { - return this._streamingResponseHandler(requestEvent, usage, callback)(res); - } else { - return this._jsonResponseHandler(requestEvent, apiMode, usage, callback)(res); - } - }).catch((error3) => { - if (_RequestSender._shouldRetry(null, requestRetries, maxRetries, error3)) { - return retryRequest(makeRequest, apiVersion, headers, requestRetries, null); - } else { - const isTimeoutError = error3.code && error3.code === HttpClient.TIMEOUT_ERROR_CODE; - return callback(new StripeConnectionError({ - message: isTimeoutError ? `Request aborted due to timeout being reached (${timeout}ms)` : _RequestSender._generateConnectionErrorMessage(requestRetries), - detail: error3 - })); - } - }); - }).catch((e) => { - throw new StripeError({ - message: "Unable to authenticate the request", - exception: e - }); - }); - }, "makeRequest"); - const prepareAndMakeRequest = /* @__PURE__ */ __name((error3, data2) => { - if (error3) { - return callback(error3); - } - requestData = data2; - this._stripe.getClientUserAgent((clientUserAgent) => { - const apiVersion = this._stripe.getApiField("version"); - const headers = this._makeHeaders({ - contentType: apiMode == "v2" ? "application/json" : "application/x-www-form-urlencoded", - contentLength: requestData.length, - apiVersion, - clientUserAgent, - method, - userSuppliedHeaders: options.headers, - userSuppliedSettings: options.settings, - stripeAccount: apiMode == "v2" ? null : this._stripe.getApiField("stripeAccount"), - stripeContext: apiMode == "v2" ? this._stripe.getApiField("stripeContext") : null, - apiMode - }); - makeRequest(apiVersion, headers, 0); - }); - }, "prepareAndMakeRequest"); - if (requestDataProcessor) { - requestDataProcessor(method, data, options.headers, prepareAndMakeRequest); - } else { - let stringifiedData; - if (apiMode == "v2") { - stringifiedData = data ? jsonStringifyRequestData(data) : ""; - } else { - stringifiedData = queryStringifyRequestData(data || {}, apiMode); - } - prepareAndMakeRequest(null, stringifiedData); - } - } -}; - -// node_modules/stripe/esm/StripeResource.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/StripeMethod.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/autoPagination.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var V1Iterator = class { - static { - __name(this, "V1Iterator"); - } - constructor(firstPagePromise, requestArgs, spec, stripeResource) { - this.index = 0; - this.pagePromise = firstPagePromise; - this.promiseCache = { currentPromise: null }; - this.requestArgs = requestArgs; - this.spec = spec; - this.stripeResource = stripeResource; - } - async iterate(pageResult) { - if (!(pageResult && pageResult.data && typeof pageResult.data.length === "number")) { - throw Error("Unexpected: Stripe API response does not have a well-formed `data` array."); - } - const reverseIteration = isReverseIteration(this.requestArgs); - if (this.index < pageResult.data.length) { - const idx = reverseIteration ? pageResult.data.length - 1 - this.index : this.index; - const value = pageResult.data[idx]; - this.index += 1; - return { value, done: false }; - } else if (pageResult.has_more) { - this.index = 0; - this.pagePromise = this.getNextPage(pageResult); - const nextPageResult = await this.pagePromise; - return this.iterate(nextPageResult); - } - return { done: true, value: void 0 }; - } - /** @abstract */ - getNextPage(_pageResult) { - throw new Error("Unimplemented"); - } - async _next() { - return this.iterate(await this.pagePromise); - } - next() { - if (this.promiseCache.currentPromise) { - return this.promiseCache.currentPromise; - } - const nextPromise = (async () => { - const ret = await this._next(); - this.promiseCache.currentPromise = null; - return ret; - })(); - this.promiseCache.currentPromise = nextPromise; - return nextPromise; - } -}; -var V1ListIterator = class extends V1Iterator { - static { - __name(this, "V1ListIterator"); - } - getNextPage(pageResult) { - const reverseIteration = isReverseIteration(this.requestArgs); - const lastId = getLastId(pageResult, reverseIteration); - return this.stripeResource._makeRequest(this.requestArgs, this.spec, { - [reverseIteration ? "ending_before" : "starting_after"]: lastId - }); - } -}; -var V1SearchIterator = class extends V1Iterator { - static { - __name(this, "V1SearchIterator"); - } - getNextPage(pageResult) { - if (!pageResult.next_page) { - throw Error("Unexpected: Stripe API response does not have a well-formed `next_page` field, but `has_more` was true."); - } - return this.stripeResource._makeRequest(this.requestArgs, this.spec, { - page: pageResult.next_page - }); - } -}; -var V2ListIterator = class { - static { - __name(this, "V2ListIterator"); - } - constructor(firstPagePromise, requestArgs, spec, stripeResource) { - this.currentPageIterator = (async () => { - const page = await firstPagePromise; - return page.data[Symbol.iterator](); - })(); - this.nextPageUrl = (async () => { - const page = await firstPagePromise; - return page.next_page_url || null; - })(); - this.requestArgs = requestArgs; - this.spec = spec; - this.stripeResource = stripeResource; - } - async turnPage() { - const nextPageUrl = await this.nextPageUrl; - if (!nextPageUrl) - return null; - this.spec.fullPath = nextPageUrl; - const page = await this.stripeResource._makeRequest([], this.spec, {}); - this.nextPageUrl = Promise.resolve(page.next_page_url); - this.currentPageIterator = Promise.resolve(page.data[Symbol.iterator]()); - return this.currentPageIterator; - } - async next() { - { - const result2 = (await this.currentPageIterator).next(); - if (!result2.done) - return { done: false, value: result2.value }; - } - const nextPageIterator = await this.turnPage(); - if (!nextPageIterator) { - return { done: true, value: void 0 }; - } - const result = nextPageIterator.next(); - if (!result.done) - return { done: false, value: result.value }; - return { done: true, value: void 0 }; - } -}; -var makeAutoPaginationMethods = /* @__PURE__ */ __name((stripeResource, requestArgs, spec, firstPagePromise) => { - const apiMode = getAPIMode(spec.fullPath || spec.path); - if (apiMode !== "v2" && spec.methodType === "search") { - return makeAutoPaginationMethodsFromIterator(new V1SearchIterator(firstPagePromise, requestArgs, spec, stripeResource)); - } - if (apiMode !== "v2" && spec.methodType === "list") { - return makeAutoPaginationMethodsFromIterator(new V1ListIterator(firstPagePromise, requestArgs, spec, stripeResource)); - } - if (apiMode === "v2" && spec.methodType === "list") { - return makeAutoPaginationMethodsFromIterator(new V2ListIterator(firstPagePromise, requestArgs, spec, stripeResource)); - } - return null; -}, "makeAutoPaginationMethods"); -var makeAutoPaginationMethodsFromIterator = /* @__PURE__ */ __name((iterator) => { - const autoPagingEach = makeAutoPagingEach((...args) => iterator.next(...args)); - const autoPagingToArray = makeAutoPagingToArray(autoPagingEach); - const autoPaginationMethods = { - autoPagingEach, - autoPagingToArray, - // Async iterator functions: - next: /* @__PURE__ */ __name(() => iterator.next(), "next"), - return: /* @__PURE__ */ __name(() => { - return {}; - }, "return"), - [getAsyncIteratorSymbol()]: () => { - return autoPaginationMethods; - } - }; - return autoPaginationMethods; -}, "makeAutoPaginationMethodsFromIterator"); -function getAsyncIteratorSymbol() { - if (typeof Symbol !== "undefined" && Symbol.asyncIterator) { - return Symbol.asyncIterator; - } - return "@@asyncIterator"; -} -__name(getAsyncIteratorSymbol, "getAsyncIteratorSymbol"); -function getDoneCallback(args) { - if (args.length < 2) { - return null; - } - const onDone = args[1]; - if (typeof onDone !== "function") { - throw Error(`The second argument to autoPagingEach, if present, must be a callback function; received ${typeof onDone}`); - } - return onDone; -} -__name(getDoneCallback, "getDoneCallback"); -function getItemCallback(args) { - if (args.length === 0) { - return void 0; - } - const onItem = args[0]; - if (typeof onItem !== "function") { - throw Error(`The first argument to autoPagingEach, if present, must be a callback function; received ${typeof onItem}`); - } - if (onItem.length === 2) { - return onItem; - } - if (onItem.length > 2) { - throw Error(`The \`onItem\` callback function passed to autoPagingEach must accept at most two arguments; got ${onItem}`); - } - return /* @__PURE__ */ __name(function _onItem(item, next) { - const shouldContinue = onItem(item); - next(shouldContinue); - }, "_onItem"); -} -__name(getItemCallback, "getItemCallback"); -function getLastId(listResult, reverseIteration) { - const lastIdx = reverseIteration ? 0 : listResult.data.length - 1; - const lastItem = listResult.data[lastIdx]; - const lastId = lastItem && lastItem.id; - if (!lastId) { - throw Error("Unexpected: No `id` found on the last item while auto-paging a list."); - } - return lastId; -} -__name(getLastId, "getLastId"); -function makeAutoPagingEach(asyncIteratorNext) { - return /* @__PURE__ */ __name(function autoPagingEach() { - const args = [].slice.call(arguments); - const onItem = getItemCallback(args); - const onDone = getDoneCallback(args); - if (args.length > 2) { - throw Error(`autoPagingEach takes up to two arguments; received ${args}`); - } - const autoPagePromise = wrapAsyncIteratorWithCallback( - asyncIteratorNext, - // @ts-ignore we might need a null check - onItem - ); - return callbackifyPromiseWithTimeout(autoPagePromise, onDone); - }, "autoPagingEach"); -} -__name(makeAutoPagingEach, "makeAutoPagingEach"); -function makeAutoPagingToArray(autoPagingEach) { - return /* @__PURE__ */ __name(function autoPagingToArray(opts, onDone) { - const limit = opts && opts.limit; - if (!limit) { - throw Error("You must pass a `limit` option to autoPagingToArray, e.g., `autoPagingToArray({limit: 1000});`."); - } - if (limit > 1e4) { - throw Error("You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists."); - } - const promise = new Promise((resolve, reject) => { - const items = []; - autoPagingEach((item) => { - items.push(item); - if (items.length >= limit) { - return false; - } - }).then(() => { - resolve(items); - }).catch(reject); - }); - return callbackifyPromiseWithTimeout(promise, onDone); - }, "autoPagingToArray"); -} -__name(makeAutoPagingToArray, "makeAutoPagingToArray"); -function wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem) { - return new Promise((resolve, reject) => { - function handleIteration(iterResult) { - if (iterResult.done) { - resolve(); - return; - } - const item = iterResult.value; - return new Promise((next) => { - onItem(item, next); - }).then((shouldContinue) => { - if (shouldContinue === false) { - return handleIteration({ done: true, value: void 0 }); - } else { - return asyncIteratorNext().then(handleIteration); - } - }); - } - __name(handleIteration, "handleIteration"); - asyncIteratorNext().then(handleIteration).catch(reject); - }); -} -__name(wrapAsyncIteratorWithCallback, "wrapAsyncIteratorWithCallback"); -function isReverseIteration(requestArgs) { - const args = [].slice.call(requestArgs); - const dataFromArgs = getDataFromArgs(args); - return !!dataFromArgs.ending_before; -} -__name(isReverseIteration, "isReverseIteration"); - -// node_modules/stripe/esm/StripeMethod.js -function stripeMethod(spec) { - if (spec.path !== void 0 && spec.fullPath !== void 0) { - throw new Error(`Method spec specified both a 'path' (${spec.path}) and a 'fullPath' (${spec.fullPath}).`); - } - return function(...args) { - const callback = typeof args[args.length - 1] == "function" && args.pop(); - spec.urlParams = extractUrlParams(spec.fullPath || this.createResourcePathWithSymbols(spec.path || "")); - const requestPromise = callbackifyPromiseWithTimeout(this._makeRequest(args, spec, {}), callback); - Object.assign(requestPromise, makeAutoPaginationMethods(this, args, spec, requestPromise)); - return requestPromise; - }; -} -__name(stripeMethod, "stripeMethod"); - -// node_modules/stripe/esm/StripeResource.js -StripeResource.extend = protoExtend; -StripeResource.method = stripeMethod; -StripeResource.MAX_BUFFERED_REQUEST_METRICS = 100; -function StripeResource(stripe, deprecatedUrlData) { - this._stripe = stripe; - if (deprecatedUrlData) { - throw new Error("Support for curried url params was dropped in stripe-node v7.0.0. Instead, pass two ids."); - } - this.basePath = makeURLInterpolator( - // @ts-ignore changing type of basePath - this.basePath || stripe.getApiField("basePath") - ); - this.resourcePath = this.path; - this.path = makeURLInterpolator(this.path); - this.initialize(...arguments); -} -__name(StripeResource, "StripeResource"); -StripeResource.prototype = { - _stripe: null, - // @ts-ignore the type of path changes in ctor - path: "", - resourcePath: "", - // Methods that don't use the API's default '/v1' path can override it with this setting. - basePath: null, - initialize() { - }, - // Function to override the default data processor. This allows full control - // over how a StripeResource's request data will get converted into an HTTP - // body. This is useful for non-standard HTTP requests. The function should - // take method name, data, and headers as arguments. - requestDataProcessor: null, - // Function to add a validation checks before sending the request, errors should - // be thrown, and they will be passed to the callback/promise. - validateRequest: null, - createFullPath(commandPath, urlData) { - const urlParts = [this.basePath(urlData), this.path(urlData)]; - if (typeof commandPath === "function") { - const computedCommandPath = commandPath(urlData); - if (computedCommandPath) { - urlParts.push(computedCommandPath); - } - } else { - urlParts.push(commandPath); - } - return this._joinUrlParts(urlParts); - }, - // Creates a relative resource path with symbols left in (unlike - // createFullPath which takes some data to replace them with). For example it - // might produce: /invoices/{id} - createResourcePathWithSymbols(pathWithSymbols) { - if (pathWithSymbols) { - return `/${this._joinUrlParts([this.resourcePath, pathWithSymbols])}`; - } else { - return `/${this.resourcePath}`; - } - }, - _joinUrlParts(parts) { - return parts.join("/").replace(/\/{2,}/g, "/"); - }, - _getRequestOpts(requestArgs, spec, overrideData) { - var _a; - const requestMethod = (spec.method || "GET").toUpperCase(); - const usage = spec.usage || []; - const urlParams = spec.urlParams || []; - const encode = spec.encode || ((data2) => data2); - const isUsingFullPath = !!spec.fullPath; - const commandPath = makeURLInterpolator(isUsingFullPath ? spec.fullPath : spec.path || ""); - const path = isUsingFullPath ? spec.fullPath : this.createResourcePathWithSymbols(spec.path); - const args = [].slice.call(requestArgs); - const urlData = urlParams.reduce((urlData2, param) => { - const arg = args.shift(); - if (typeof arg !== "string") { - throw new Error(`Stripe: Argument "${param}" must be a string, but got: ${arg} (on API request to \`${requestMethod} ${path}\`)`); - } - urlData2[param] = arg; - return urlData2; - }, {}); - const dataFromArgs = getDataFromArgs(args); - const data = encode(Object.assign({}, dataFromArgs, overrideData)); - const options = getOptionsFromArgs(args); - const host = options.host || spec.host; - const streaming = !!spec.streaming || !!options.streaming; - if (args.filter((x) => x != null).length) { - throw new Error(`Stripe: Unknown arguments (${args}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to ${requestMethod} \`${path}\`)`); - } - const requestPath = isUsingFullPath ? commandPath(urlData) : this.createFullPath(commandPath, urlData); - const headers = Object.assign(options.headers, spec.headers); - if (spec.validator) { - spec.validator(data, { headers }); - } - const dataInQuery = spec.method === "GET" || spec.method === "DELETE"; - const bodyData = dataInQuery ? null : data; - const queryData = dataInQuery ? data : {}; - return { - requestMethod, - requestPath, - bodyData, - queryData, - authenticator: (_a = options.authenticator) !== null && _a !== void 0 ? _a : null, - headers, - host: host !== null && host !== void 0 ? host : null, - streaming, - settings: options.settings, - usage - }; - }, - _makeRequest(requestArgs, spec, overrideData) { - return new Promise((resolve, reject) => { - var _a; - let opts; - try { - opts = this._getRequestOpts(requestArgs, spec, overrideData); - } catch (err) { - reject(err); - return; - } - function requestCallback(err, response) { - if (err) { - reject(err); - } else { - resolve(spec.transformResponseData ? spec.transformResponseData(response) : response); - } - } - __name(requestCallback, "requestCallback"); - const emptyQuery = Object.keys(opts.queryData).length === 0; - const path = [ - opts.requestPath, - emptyQuery ? "" : "?", - queryStringifyRequestData(opts.queryData, getAPIMode(opts.requestPath)) - ].join(""); - const { headers, settings } = opts; - this._stripe._requestSender._request(opts.requestMethod, opts.host, path, opts.bodyData, opts.authenticator, { - headers, - settings, - streaming: opts.streaming - }, opts.usage, requestCallback, (_a = this.requestDataProcessor) === null || _a === void 0 ? void 0 : _a.bind(this)); - }); - } -}; - -// node_modules/stripe/esm/Webhooks.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -function createWebhooks(platformFunctions) { - const Webhook = { - DEFAULT_TOLERANCE: 300, - signature: null, - constructEvent(payload, header, secret, tolerance, cryptoProvider, receivedAt) { - try { - if (!this.signature) { - throw new Error("ERR: missing signature helper, unable to verify"); - } - this.signature.verifyHeader(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE, cryptoProvider, receivedAt); - } catch (e) { - if (e instanceof CryptoProviderOnlySupportsAsyncError) { - e.message += "\nUse `await constructEventAsync(...)` instead of `constructEvent(...)`"; - } - throw e; - } - const jsonPayload = payload instanceof Uint8Array ? JSON.parse(new TextDecoder("utf8").decode(payload)) : JSON.parse(payload); - return jsonPayload; - }, - async constructEventAsync(payload, header, secret, tolerance, cryptoProvider, receivedAt) { - if (!this.signature) { - throw new Error("ERR: missing signature helper, unable to verify"); - } - await this.signature.verifyHeaderAsync(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE, cryptoProvider, receivedAt); - const jsonPayload = payload instanceof Uint8Array ? JSON.parse(new TextDecoder("utf8").decode(payload)) : JSON.parse(payload); - return jsonPayload; - }, - /** - * Generates a header to be used for webhook mocking - * - * @typedef {object} opts - * @property {number} timestamp - Timestamp of the header. Defaults to Date.now() - * @property {string} payload - JSON stringified payload object, containing the 'id' and 'object' parameters - * @property {string} secret - Stripe webhook secret 'whsec_...' - * @property {string} scheme - Version of API to hit. Defaults to 'v1'. - * @property {string} signature - Computed webhook signature - * @property {CryptoProvider} cryptoProvider - Crypto provider to use for computing the signature if none was provided. Defaults to NodeCryptoProvider. - */ - generateTestHeaderString: /* @__PURE__ */ __name(function(opts) { - const preparedOpts = prepareOptions(opts); - const signature2 = preparedOpts.signature || preparedOpts.cryptoProvider.computeHMACSignature(preparedOpts.payloadString, preparedOpts.secret); - return preparedOpts.generateHeaderString(signature2); - }, "generateTestHeaderString"), - generateTestHeaderStringAsync: /* @__PURE__ */ __name(async function(opts) { - const preparedOpts = prepareOptions(opts); - const signature2 = preparedOpts.signature || await preparedOpts.cryptoProvider.computeHMACSignatureAsync(preparedOpts.payloadString, preparedOpts.secret); - return preparedOpts.generateHeaderString(signature2); - }, "generateTestHeaderStringAsync") - }; - const signature = { - EXPECTED_SCHEME: "v1", - verifyHeader(encodedPayload, encodedHeader, secret, tolerance, cryptoProvider, receivedAt) { - const { decodedHeader: header, decodedPayload: payload, details, suspectPayloadType } = parseEventDetails(encodedPayload, encodedHeader, this.EXPECTED_SCHEME); - const secretContainsWhitespace = /\s/.test(secret); - cryptoProvider = cryptoProvider || getCryptoProvider(); - const expectedSignature = cryptoProvider.computeHMACSignature(makeHMACContent(payload, details), secret); - validateComputedSignature(payload, header, details, expectedSignature, tolerance, suspectPayloadType, secretContainsWhitespace, receivedAt); - return true; - }, - async verifyHeaderAsync(encodedPayload, encodedHeader, secret, tolerance, cryptoProvider, receivedAt) { - const { decodedHeader: header, decodedPayload: payload, details, suspectPayloadType } = parseEventDetails(encodedPayload, encodedHeader, this.EXPECTED_SCHEME); - const secretContainsWhitespace = /\s/.test(secret); - cryptoProvider = cryptoProvider || getCryptoProvider(); - const expectedSignature = await cryptoProvider.computeHMACSignatureAsync(makeHMACContent(payload, details), secret); - return validateComputedSignature(payload, header, details, expectedSignature, tolerance, suspectPayloadType, secretContainsWhitespace, receivedAt); - } - }; - function makeHMACContent(payload, details) { - return `${details.timestamp}.${payload}`; - } - __name(makeHMACContent, "makeHMACContent"); - function parseEventDetails(encodedPayload, encodedHeader, expectedScheme) { - if (!encodedPayload) { - throw new StripeSignatureVerificationError(encodedHeader, encodedPayload, { - message: "No webhook payload was provided." - }); - } - const suspectPayloadType = typeof encodedPayload != "string" && !(encodedPayload instanceof Uint8Array); - const textDecoder = new TextDecoder("utf8"); - const decodedPayload = encodedPayload instanceof Uint8Array ? textDecoder.decode(encodedPayload) : encodedPayload; - if (Array.isArray(encodedHeader)) { - throw new Error("Unexpected: An array was passed as a header, which should not be possible for the stripe-signature header."); - } - if (encodedHeader == null || encodedHeader == "") { - throw new StripeSignatureVerificationError(encodedHeader, encodedPayload, { - message: "No stripe-signature header value was provided." - }); - } - const decodedHeader = encodedHeader instanceof Uint8Array ? textDecoder.decode(encodedHeader) : encodedHeader; - const details = parseHeader(decodedHeader, expectedScheme); - if (!details || details.timestamp === -1) { - throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { - message: "Unable to extract timestamp and signatures from header" - }); - } - if (!details.signatures.length) { - throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { - message: "No signatures found with expected scheme" - }); - } - return { - decodedPayload, - decodedHeader, - details, - suspectPayloadType - }; - } - __name(parseEventDetails, "parseEventDetails"); - function validateComputedSignature(payload, header, details, expectedSignature, tolerance, suspectPayloadType, secretContainsWhitespace, receivedAt) { - const signatureFound = !!details.signatures.filter(platformFunctions.secureCompare.bind(platformFunctions, expectedSignature)).length; - const docsLocation = "\nLearn more about webhook signing and explore webhook integration examples for various frameworks at https://docs.stripe.com/webhooks/signature"; - const whitespaceMessage = secretContainsWhitespace ? "\n\nNote: The provided signing secret contains whitespace. This often indicates an extra newline or space is in the value" : ""; - if (!signatureFound) { - if (suspectPayloadType) { - throw new StripeSignatureVerificationError(header, payload, { - message: "Webhook payload must be provided as a string or a Buffer (https://nodejs.org/api/buffer.html) instance representing the _raw_ request body.Payload was provided as a parsed JavaScript object instead. \nSignature verification is impossible without access to the original signed material. \n" + docsLocation + "\n" + whitespaceMessage - }); - } - throw new StripeSignatureVerificationError(header, payload, { - message: "No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? \n If a webhook request is being forwarded by a third-party tool, ensure that the exact request body, including JSON formatting and new line style, is preserved.\n" + docsLocation + "\n" + whitespaceMessage - }); - } - const timestampAge = Math.floor((typeof receivedAt === "number" ? receivedAt : Date.now()) / 1e3) - details.timestamp; - if (tolerance > 0 && timestampAge > tolerance) { - throw new StripeSignatureVerificationError(header, payload, { - message: "Timestamp outside the tolerance zone" - }); - } - return true; - } - __name(validateComputedSignature, "validateComputedSignature"); - function parseHeader(header, scheme) { - if (typeof header !== "string") { - return null; - } - return header.split(",").reduce((accum, item) => { - const kv = item.split("="); - if (kv[0] === "t") { - accum.timestamp = parseInt(kv[1], 10); - } - if (kv[0] === scheme) { - accum.signatures.push(kv[1]); - } - return accum; - }, { - timestamp: -1, - signatures: [] - }); - } - __name(parseHeader, "parseHeader"); - let webhooksCryptoProviderInstance = null; - function getCryptoProvider() { - if (!webhooksCryptoProviderInstance) { - webhooksCryptoProviderInstance = platformFunctions.createDefaultCryptoProvider(); - } - return webhooksCryptoProviderInstance; - } - __name(getCryptoProvider, "getCryptoProvider"); - function prepareOptions(opts) { - if (!opts) { - throw new StripeError({ - message: "Options are required" - }); - } - const timestamp = Math.floor(opts.timestamp) || Math.floor(Date.now() / 1e3); - const scheme = opts.scheme || signature.EXPECTED_SCHEME; - const cryptoProvider = opts.cryptoProvider || getCryptoProvider(); - const payloadString = `${timestamp}.${opts.payload}`; - const generateHeaderString = /* @__PURE__ */ __name((signature2) => { - return `t=${timestamp},${scheme}=${signature2}`; - }, "generateHeaderString"); - return Object.assign(Object.assign({}, opts), { - timestamp, - scheme, - cryptoProvider, - payloadString, - generateHeaderString - }); - } - __name(prepareOptions, "prepareOptions"); - Webhook.signature = signature; - return Webhook; -} -__name(createWebhooks, "createWebhooks"); - -// node_modules/stripe/esm/apiVersion.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var ApiVersion = "2025-08-27.basil"; - -// node_modules/stripe/esm/resources.js -var resources_exports = {}; -__export(resources_exports, { - Account: () => Accounts2, - AccountLinks: () => AccountLinks, - AccountSessions: () => AccountSessions, - Accounts: () => Accounts2, - ApplePayDomains: () => ApplePayDomains, - ApplicationFees: () => ApplicationFees, - Apps: () => Apps, - Balance: () => Balance, - BalanceTransactions: () => BalanceTransactions, - Billing: () => Billing, - BillingPortal: () => BillingPortal, - Charges: () => Charges, - Checkout: () => Checkout, - Climate: () => Climate, - ConfirmationTokens: () => ConfirmationTokens2, - CountrySpecs: () => CountrySpecs, - Coupons: () => Coupons, - CreditNotes: () => CreditNotes, - CustomerSessions: () => CustomerSessions, - Customers: () => Customers2, - Disputes: () => Disputes2, - Entitlements: () => Entitlements, - EphemeralKeys: () => EphemeralKeys, - Events: () => Events2, - ExchangeRates: () => ExchangeRates, - FileLinks: () => FileLinks, - Files: () => Files, - FinancialConnections: () => FinancialConnections, - Forwarding: () => Forwarding, - Identity: () => Identity, - InvoiceItems: () => InvoiceItems, - InvoicePayments: () => InvoicePayments, - InvoiceRenderingTemplates: () => InvoiceRenderingTemplates, - Invoices: () => Invoices, - Issuing: () => Issuing, - Mandates: () => Mandates, - OAuth: () => OAuth, - PaymentIntents: () => PaymentIntents, - PaymentLinks: () => PaymentLinks, - PaymentMethodConfigurations: () => PaymentMethodConfigurations, - PaymentMethodDomains: () => PaymentMethodDomains, - PaymentMethods: () => PaymentMethods, - Payouts: () => Payouts, - Plans: () => Plans, - Prices: () => Prices, - Products: () => Products2, - PromotionCodes: () => PromotionCodes, - Quotes: () => Quotes, - Radar: () => Radar, - Refunds: () => Refunds2, - Reporting: () => Reporting, - Reviews: () => Reviews, - SetupAttempts: () => SetupAttempts, - SetupIntents: () => SetupIntents, - ShippingRates: () => ShippingRates, - Sigma: () => Sigma, - Sources: () => Sources, - SubscriptionItems: () => SubscriptionItems, - SubscriptionSchedules: () => SubscriptionSchedules, - Subscriptions: () => Subscriptions, - Tax: () => Tax, - TaxCodes: () => TaxCodes, - TaxIds: () => TaxIds, - TaxRates: () => TaxRates, - Terminal: () => Terminal, - TestHelpers: () => TestHelpers, - Tokens: () => Tokens2, - Topups: () => Topups, - Transfers: () => Transfers, - Treasury: () => Treasury, - V2: () => V2, - WebhookEndpoints: () => WebhookEndpoints -}); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/ResourceNamespace.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -function ResourceNamespace(stripe, resources) { - for (const name in resources) { - if (!Object.prototype.hasOwnProperty.call(resources, name)) { - continue; - } - const camelCaseName = name[0].toLowerCase() + name.substring(1); - const resource = new resources[name](stripe); - this[camelCaseName] = resource; - } -} -__name(ResourceNamespace, "ResourceNamespace"); -function resourceNamespace(namespace, resources) { - return function(stripe) { - return new ResourceNamespace(stripe, resources); - }; -} -__name(resourceNamespace, "resourceNamespace"); - -// node_modules/stripe/esm/resources/FinancialConnections/Accounts.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod2 = StripeResource.method; -var Accounts = StripeResource.extend({ - retrieve: stripeMethod2({ - method: "GET", - fullPath: "/v1/financial_connections/accounts/{account}" - }), - list: stripeMethod2({ - method: "GET", - fullPath: "/v1/financial_connections/accounts", - methodType: "list" - }), - disconnect: stripeMethod2({ - method: "POST", - fullPath: "/v1/financial_connections/accounts/{account}/disconnect" - }), - listOwners: stripeMethod2({ - method: "GET", - fullPath: "/v1/financial_connections/accounts/{account}/owners", - methodType: "list" - }), - refresh: stripeMethod2({ - method: "POST", - fullPath: "/v1/financial_connections/accounts/{account}/refresh" - }), - subscribe: stripeMethod2({ - method: "POST", - fullPath: "/v1/financial_connections/accounts/{account}/subscribe" - }), - unsubscribe: stripeMethod2({ - method: "POST", - fullPath: "/v1/financial_connections/accounts/{account}/unsubscribe" - }) -}); - -// node_modules/stripe/esm/resources/Entitlements/ActiveEntitlements.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod3 = StripeResource.method; -var ActiveEntitlements = StripeResource.extend({ - retrieve: stripeMethod3({ - method: "GET", - fullPath: "/v1/entitlements/active_entitlements/{id}" - }), - list: stripeMethod3({ - method: "GET", - fullPath: "/v1/entitlements/active_entitlements", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Billing/Alerts.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod4 = StripeResource.method; -var Alerts = StripeResource.extend({ - create: stripeMethod4({ method: "POST", fullPath: "/v1/billing/alerts" }), - retrieve: stripeMethod4({ method: "GET", fullPath: "/v1/billing/alerts/{id}" }), - list: stripeMethod4({ - method: "GET", - fullPath: "/v1/billing/alerts", - methodType: "list" - }), - activate: stripeMethod4({ - method: "POST", - fullPath: "/v1/billing/alerts/{id}/activate" - }), - archive: stripeMethod4({ - method: "POST", - fullPath: "/v1/billing/alerts/{id}/archive" - }), - deactivate: stripeMethod4({ - method: "POST", - fullPath: "/v1/billing/alerts/{id}/deactivate" - }) -}); - -// node_modules/stripe/esm/resources/Issuing/Authorizations.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod5 = StripeResource.method; -var Authorizations = StripeResource.extend({ - retrieve: stripeMethod5({ - method: "GET", - fullPath: "/v1/issuing/authorizations/{authorization}" - }), - update: stripeMethod5({ - method: "POST", - fullPath: "/v1/issuing/authorizations/{authorization}" - }), - list: stripeMethod5({ - method: "GET", - fullPath: "/v1/issuing/authorizations", - methodType: "list" - }), - approve: stripeMethod5({ - method: "POST", - fullPath: "/v1/issuing/authorizations/{authorization}/approve" - }), - decline: stripeMethod5({ - method: "POST", - fullPath: "/v1/issuing/authorizations/{authorization}/decline" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Issuing/Authorizations.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod6 = StripeResource.method; -var Authorizations2 = StripeResource.extend({ - create: stripeMethod6({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/authorizations" - }), - capture: stripeMethod6({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/authorizations/{authorization}/capture" - }), - expire: stripeMethod6({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/authorizations/{authorization}/expire" - }), - finalizeAmount: stripeMethod6({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/authorizations/{authorization}/finalize_amount" - }), - increment: stripeMethod6({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/authorizations/{authorization}/increment" - }), - respond: stripeMethod6({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/authorizations/{authorization}/fraud_challenges/respond" - }), - reverse: stripeMethod6({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/authorizations/{authorization}/reverse" - }) -}); - -// node_modules/stripe/esm/resources/Tax/Calculations.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod7 = StripeResource.method; -var Calculations = StripeResource.extend({ - create: stripeMethod7({ method: "POST", fullPath: "/v1/tax/calculations" }), - retrieve: stripeMethod7({ - method: "GET", - fullPath: "/v1/tax/calculations/{calculation}" - }), - listLineItems: stripeMethod7({ - method: "GET", - fullPath: "/v1/tax/calculations/{calculation}/line_items", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Issuing/Cardholders.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod8 = StripeResource.method; -var Cardholders = StripeResource.extend({ - create: stripeMethod8({ method: "POST", fullPath: "/v1/issuing/cardholders" }), - retrieve: stripeMethod8({ - method: "GET", - fullPath: "/v1/issuing/cardholders/{cardholder}" - }), - update: stripeMethod8({ - method: "POST", - fullPath: "/v1/issuing/cardholders/{cardholder}" - }), - list: stripeMethod8({ - method: "GET", - fullPath: "/v1/issuing/cardholders", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Issuing/Cards.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod9 = StripeResource.method; -var Cards = StripeResource.extend({ - create: stripeMethod9({ method: "POST", fullPath: "/v1/issuing/cards" }), - retrieve: stripeMethod9({ method: "GET", fullPath: "/v1/issuing/cards/{card}" }), - update: stripeMethod9({ method: "POST", fullPath: "/v1/issuing/cards/{card}" }), - list: stripeMethod9({ - method: "GET", - fullPath: "/v1/issuing/cards", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Issuing/Cards.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod10 = StripeResource.method; -var Cards2 = StripeResource.extend({ - deliverCard: stripeMethod10({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/cards/{card}/shipping/deliver" - }), - failCard: stripeMethod10({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/cards/{card}/shipping/fail" - }), - returnCard: stripeMethod10({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/cards/{card}/shipping/return" - }), - shipCard: stripeMethod10({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/cards/{card}/shipping/ship" - }), - submitCard: stripeMethod10({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/cards/{card}/shipping/submit" - }) -}); - -// node_modules/stripe/esm/resources/BillingPortal/Configurations.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod11 = StripeResource.method; -var Configurations = StripeResource.extend({ - create: stripeMethod11({ - method: "POST", - fullPath: "/v1/billing_portal/configurations" - }), - retrieve: stripeMethod11({ - method: "GET", - fullPath: "/v1/billing_portal/configurations/{configuration}" - }), - update: stripeMethod11({ - method: "POST", - fullPath: "/v1/billing_portal/configurations/{configuration}" - }), - list: stripeMethod11({ - method: "GET", - fullPath: "/v1/billing_portal/configurations", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Terminal/Configurations.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod12 = StripeResource.method; -var Configurations2 = StripeResource.extend({ - create: stripeMethod12({ - method: "POST", - fullPath: "/v1/terminal/configurations" - }), - retrieve: stripeMethod12({ - method: "GET", - fullPath: "/v1/terminal/configurations/{configuration}" - }), - update: stripeMethod12({ - method: "POST", - fullPath: "/v1/terminal/configurations/{configuration}" - }), - list: stripeMethod12({ - method: "GET", - fullPath: "/v1/terminal/configurations", - methodType: "list" - }), - del: stripeMethod12({ - method: "DELETE", - fullPath: "/v1/terminal/configurations/{configuration}" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/ConfirmationTokens.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod13 = StripeResource.method; -var ConfirmationTokens = StripeResource.extend({ - create: stripeMethod13({ - method: "POST", - fullPath: "/v1/test_helpers/confirmation_tokens" - }) -}); - -// node_modules/stripe/esm/resources/Terminal/ConnectionTokens.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod14 = StripeResource.method; -var ConnectionTokens = StripeResource.extend({ - create: stripeMethod14({ - method: "POST", - fullPath: "/v1/terminal/connection_tokens" - }) -}); - -// node_modules/stripe/esm/resources/Billing/CreditBalanceSummary.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod15 = StripeResource.method; -var CreditBalanceSummary = StripeResource.extend({ - retrieve: stripeMethod15({ - method: "GET", - fullPath: "/v1/billing/credit_balance_summary" - }) -}); - -// node_modules/stripe/esm/resources/Billing/CreditBalanceTransactions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod16 = StripeResource.method; -var CreditBalanceTransactions = StripeResource.extend({ - retrieve: stripeMethod16({ - method: "GET", - fullPath: "/v1/billing/credit_balance_transactions/{id}" - }), - list: stripeMethod16({ - method: "GET", - fullPath: "/v1/billing/credit_balance_transactions", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Billing/CreditGrants.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod17 = StripeResource.method; -var CreditGrants = StripeResource.extend({ - create: stripeMethod17({ method: "POST", fullPath: "/v1/billing/credit_grants" }), - retrieve: stripeMethod17({ - method: "GET", - fullPath: "/v1/billing/credit_grants/{id}" - }), - update: stripeMethod17({ - method: "POST", - fullPath: "/v1/billing/credit_grants/{id}" - }), - list: stripeMethod17({ - method: "GET", - fullPath: "/v1/billing/credit_grants", - methodType: "list" - }), - expire: stripeMethod17({ - method: "POST", - fullPath: "/v1/billing/credit_grants/{id}/expire" - }), - voidGrant: stripeMethod17({ - method: "POST", - fullPath: "/v1/billing/credit_grants/{id}/void" - }) -}); - -// node_modules/stripe/esm/resources/Treasury/CreditReversals.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod18 = StripeResource.method; -var CreditReversals = StripeResource.extend({ - create: stripeMethod18({ - method: "POST", - fullPath: "/v1/treasury/credit_reversals" - }), - retrieve: stripeMethod18({ - method: "GET", - fullPath: "/v1/treasury/credit_reversals/{credit_reversal}" - }), - list: stripeMethod18({ - method: "GET", - fullPath: "/v1/treasury/credit_reversals", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Customers.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod19 = StripeResource.method; -var Customers = StripeResource.extend({ - fundCashBalance: stripeMethod19({ - method: "POST", - fullPath: "/v1/test_helpers/customers/{customer}/fund_cash_balance" - }) -}); - -// node_modules/stripe/esm/resources/Treasury/DebitReversals.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod20 = StripeResource.method; -var DebitReversals = StripeResource.extend({ - create: stripeMethod20({ - method: "POST", - fullPath: "/v1/treasury/debit_reversals" - }), - retrieve: stripeMethod20({ - method: "GET", - fullPath: "/v1/treasury/debit_reversals/{debit_reversal}" - }), - list: stripeMethod20({ - method: "GET", - fullPath: "/v1/treasury/debit_reversals", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Issuing/Disputes.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod21 = StripeResource.method; -var Disputes = StripeResource.extend({ - create: stripeMethod21({ method: "POST", fullPath: "/v1/issuing/disputes" }), - retrieve: stripeMethod21({ - method: "GET", - fullPath: "/v1/issuing/disputes/{dispute}" - }), - update: stripeMethod21({ - method: "POST", - fullPath: "/v1/issuing/disputes/{dispute}" - }), - list: stripeMethod21({ - method: "GET", - fullPath: "/v1/issuing/disputes", - methodType: "list" - }), - submit: stripeMethod21({ - method: "POST", - fullPath: "/v1/issuing/disputes/{dispute}/submit" - }) -}); - -// node_modules/stripe/esm/resources/Radar/EarlyFraudWarnings.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod22 = StripeResource.method; -var EarlyFraudWarnings = StripeResource.extend({ - retrieve: stripeMethod22({ - method: "GET", - fullPath: "/v1/radar/early_fraud_warnings/{early_fraud_warning}" - }), - list: stripeMethod22({ - method: "GET", - fullPath: "/v1/radar/early_fraud_warnings", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/V2/Core/EventDestinations.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod23 = StripeResource.method; -var EventDestinations = StripeResource.extend({ - create: stripeMethod23({ - method: "POST", - fullPath: "/v2/core/event_destinations" - }), - retrieve: stripeMethod23({ - method: "GET", - fullPath: "/v2/core/event_destinations/{id}" - }), - update: stripeMethod23({ - method: "POST", - fullPath: "/v2/core/event_destinations/{id}" - }), - list: stripeMethod23({ - method: "GET", - fullPath: "/v2/core/event_destinations", - methodType: "list" - }), - del: stripeMethod23({ - method: "DELETE", - fullPath: "/v2/core/event_destinations/{id}" - }), - disable: stripeMethod23({ - method: "POST", - fullPath: "/v2/core/event_destinations/{id}/disable" - }), - enable: stripeMethod23({ - method: "POST", - fullPath: "/v2/core/event_destinations/{id}/enable" - }), - ping: stripeMethod23({ - method: "POST", - fullPath: "/v2/core/event_destinations/{id}/ping" - }) -}); - -// node_modules/stripe/esm/resources/V2/Core/Events.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod24 = StripeResource.method; -var Events = StripeResource.extend({ - retrieve(...args) { - const transformResponseData = /* @__PURE__ */ __name((response) => { - return this.addFetchRelatedObjectIfNeeded(response); - }, "transformResponseData"); - return stripeMethod24({ - method: "GET", - fullPath: "/v2/core/events/{id}", - transformResponseData - }).apply(this, args); - }, - list(...args) { - const transformResponseData = /* @__PURE__ */ __name((response) => { - return Object.assign(Object.assign({}, response), { data: response.data.map(this.addFetchRelatedObjectIfNeeded.bind(this)) }); - }, "transformResponseData"); - return stripeMethod24({ - method: "GET", - fullPath: "/v2/core/events", - methodType: "list", - transformResponseData - }).apply(this, args); - }, - /** - * @private - * - * For internal use in stripe-node. - * - * @param pulledEvent The retrieved event object - * @returns The retrieved event object with a fetchRelatedObject method, - * if pulledEvent.related_object is valid (non-null and has a url) - */ - addFetchRelatedObjectIfNeeded(pulledEvent) { - if (!pulledEvent.related_object || !pulledEvent.related_object.url) { - return pulledEvent; - } - return Object.assign(Object.assign({}, pulledEvent), { fetchRelatedObject: /* @__PURE__ */ __name(() => ( - // call stripeMethod with 'this' resource to fetch - // the related object. 'this' is needed to construct - // and send the request, but the method spec controls - // the url endpoint and method, so it doesn't matter - // that 'this' is an Events resource object here - stripeMethod24({ - method: "GET", - fullPath: pulledEvent.related_object.url - }).apply(this, [ - { - stripeAccount: pulledEvent.context - } - ]) - ), "fetchRelatedObject") }); - } -}); - -// node_modules/stripe/esm/resources/Entitlements/Features.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod25 = StripeResource.method; -var Features = StripeResource.extend({ - create: stripeMethod25({ method: "POST", fullPath: "/v1/entitlements/features" }), - retrieve: stripeMethod25({ - method: "GET", - fullPath: "/v1/entitlements/features/{id}" - }), - update: stripeMethod25({ - method: "POST", - fullPath: "/v1/entitlements/features/{id}" - }), - list: stripeMethod25({ - method: "GET", - fullPath: "/v1/entitlements/features", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Treasury/FinancialAccounts.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod26 = StripeResource.method; -var FinancialAccounts = StripeResource.extend({ - create: stripeMethod26({ - method: "POST", - fullPath: "/v1/treasury/financial_accounts" - }), - retrieve: stripeMethod26({ - method: "GET", - fullPath: "/v1/treasury/financial_accounts/{financial_account}" - }), - update: stripeMethod26({ - method: "POST", - fullPath: "/v1/treasury/financial_accounts/{financial_account}" - }), - list: stripeMethod26({ - method: "GET", - fullPath: "/v1/treasury/financial_accounts", - methodType: "list" - }), - close: stripeMethod26({ - method: "POST", - fullPath: "/v1/treasury/financial_accounts/{financial_account}/close" - }), - retrieveFeatures: stripeMethod26({ - method: "GET", - fullPath: "/v1/treasury/financial_accounts/{financial_account}/features" - }), - updateFeatures: stripeMethod26({ - method: "POST", - fullPath: "/v1/treasury/financial_accounts/{financial_account}/features" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Treasury/InboundTransfers.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod27 = StripeResource.method; -var InboundTransfers = StripeResource.extend({ - fail: stripeMethod27({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/inbound_transfers/{id}/fail" - }), - returnInboundTransfer: stripeMethod27({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/inbound_transfers/{id}/return" - }), - succeed: stripeMethod27({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/inbound_transfers/{id}/succeed" - }) -}); - -// node_modules/stripe/esm/resources/Treasury/InboundTransfers.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod28 = StripeResource.method; -var InboundTransfers2 = StripeResource.extend({ - create: stripeMethod28({ - method: "POST", - fullPath: "/v1/treasury/inbound_transfers" - }), - retrieve: stripeMethod28({ - method: "GET", - fullPath: "/v1/treasury/inbound_transfers/{id}" - }), - list: stripeMethod28({ - method: "GET", - fullPath: "/v1/treasury/inbound_transfers", - methodType: "list" - }), - cancel: stripeMethod28({ - method: "POST", - fullPath: "/v1/treasury/inbound_transfers/{inbound_transfer}/cancel" - }) -}); - -// node_modules/stripe/esm/resources/Terminal/Locations.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod29 = StripeResource.method; -var Locations = StripeResource.extend({ - create: stripeMethod29({ method: "POST", fullPath: "/v1/terminal/locations" }), - retrieve: stripeMethod29({ - method: "GET", - fullPath: "/v1/terminal/locations/{location}" - }), - update: stripeMethod29({ - method: "POST", - fullPath: "/v1/terminal/locations/{location}" - }), - list: stripeMethod29({ - method: "GET", - fullPath: "/v1/terminal/locations", - methodType: "list" - }), - del: stripeMethod29({ - method: "DELETE", - fullPath: "/v1/terminal/locations/{location}" - }) -}); - -// node_modules/stripe/esm/resources/Billing/MeterEventAdjustments.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod30 = StripeResource.method; -var MeterEventAdjustments = StripeResource.extend({ - create: stripeMethod30({ - method: "POST", - fullPath: "/v1/billing/meter_event_adjustments" - }) -}); - -// node_modules/stripe/esm/resources/V2/Billing/MeterEventAdjustments.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod31 = StripeResource.method; -var MeterEventAdjustments2 = StripeResource.extend({ - create: stripeMethod31({ - method: "POST", - fullPath: "/v2/billing/meter_event_adjustments" - }) -}); - -// node_modules/stripe/esm/resources/V2/Billing/MeterEventSession.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod32 = StripeResource.method; -var MeterEventSession = StripeResource.extend({ - create: stripeMethod32({ - method: "POST", - fullPath: "/v2/billing/meter_event_session" - }) -}); - -// node_modules/stripe/esm/resources/V2/Billing/MeterEventStream.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod33 = StripeResource.method; -var MeterEventStream = StripeResource.extend({ - create: stripeMethod33({ - method: "POST", - fullPath: "/v2/billing/meter_event_stream", - host: "meter-events.stripe.com" - }) -}); - -// node_modules/stripe/esm/resources/Billing/MeterEvents.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod34 = StripeResource.method; -var MeterEvents = StripeResource.extend({ - create: stripeMethod34({ method: "POST", fullPath: "/v1/billing/meter_events" }) -}); - -// node_modules/stripe/esm/resources/V2/Billing/MeterEvents.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod35 = StripeResource.method; -var MeterEvents2 = StripeResource.extend({ - create: stripeMethod35({ method: "POST", fullPath: "/v2/billing/meter_events" }) -}); - -// node_modules/stripe/esm/resources/Billing/Meters.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod36 = StripeResource.method; -var Meters = StripeResource.extend({ - create: stripeMethod36({ method: "POST", fullPath: "/v1/billing/meters" }), - retrieve: stripeMethod36({ method: "GET", fullPath: "/v1/billing/meters/{id}" }), - update: stripeMethod36({ method: "POST", fullPath: "/v1/billing/meters/{id}" }), - list: stripeMethod36({ - method: "GET", - fullPath: "/v1/billing/meters", - methodType: "list" - }), - deactivate: stripeMethod36({ - method: "POST", - fullPath: "/v1/billing/meters/{id}/deactivate" - }), - listEventSummaries: stripeMethod36({ - method: "GET", - fullPath: "/v1/billing/meters/{id}/event_summaries", - methodType: "list" - }), - reactivate: stripeMethod36({ - method: "POST", - fullPath: "/v1/billing/meters/{id}/reactivate" - }) -}); - -// node_modules/stripe/esm/resources/Climate/Orders.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod37 = StripeResource.method; -var Orders = StripeResource.extend({ - create: stripeMethod37({ method: "POST", fullPath: "/v1/climate/orders" }), - retrieve: stripeMethod37({ - method: "GET", - fullPath: "/v1/climate/orders/{order}" - }), - update: stripeMethod37({ - method: "POST", - fullPath: "/v1/climate/orders/{order}" - }), - list: stripeMethod37({ - method: "GET", - fullPath: "/v1/climate/orders", - methodType: "list" - }), - cancel: stripeMethod37({ - method: "POST", - fullPath: "/v1/climate/orders/{order}/cancel" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Treasury/OutboundPayments.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod38 = StripeResource.method; -var OutboundPayments = StripeResource.extend({ - update: stripeMethod38({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/outbound_payments/{id}" - }), - fail: stripeMethod38({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/outbound_payments/{id}/fail" - }), - post: stripeMethod38({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/outbound_payments/{id}/post" - }), - returnOutboundPayment: stripeMethod38({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/outbound_payments/{id}/return" - }) -}); - -// node_modules/stripe/esm/resources/Treasury/OutboundPayments.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod39 = StripeResource.method; -var OutboundPayments2 = StripeResource.extend({ - create: stripeMethod39({ - method: "POST", - fullPath: "/v1/treasury/outbound_payments" - }), - retrieve: stripeMethod39({ - method: "GET", - fullPath: "/v1/treasury/outbound_payments/{id}" - }), - list: stripeMethod39({ - method: "GET", - fullPath: "/v1/treasury/outbound_payments", - methodType: "list" - }), - cancel: stripeMethod39({ - method: "POST", - fullPath: "/v1/treasury/outbound_payments/{id}/cancel" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Treasury/OutboundTransfers.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod40 = StripeResource.method; -var OutboundTransfers = StripeResource.extend({ - update: stripeMethod40({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}" - }), - fail: stripeMethod40({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail" - }), - post: stripeMethod40({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post" - }), - returnOutboundTransfer: stripeMethod40({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return" - }) -}); - -// node_modules/stripe/esm/resources/Treasury/OutboundTransfers.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod41 = StripeResource.method; -var OutboundTransfers2 = StripeResource.extend({ - create: stripeMethod41({ - method: "POST", - fullPath: "/v1/treasury/outbound_transfers" - }), - retrieve: stripeMethod41({ - method: "GET", - fullPath: "/v1/treasury/outbound_transfers/{outbound_transfer}" - }), - list: stripeMethod41({ - method: "GET", - fullPath: "/v1/treasury/outbound_transfers", - methodType: "list" - }), - cancel: stripeMethod41({ - method: "POST", - fullPath: "/v1/treasury/outbound_transfers/{outbound_transfer}/cancel" - }) -}); - -// node_modules/stripe/esm/resources/Issuing/PersonalizationDesigns.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod42 = StripeResource.method; -var PersonalizationDesigns = StripeResource.extend({ - create: stripeMethod42({ - method: "POST", - fullPath: "/v1/issuing/personalization_designs" - }), - retrieve: stripeMethod42({ - method: "GET", - fullPath: "/v1/issuing/personalization_designs/{personalization_design}" - }), - update: stripeMethod42({ - method: "POST", - fullPath: "/v1/issuing/personalization_designs/{personalization_design}" - }), - list: stripeMethod42({ - method: "GET", - fullPath: "/v1/issuing/personalization_designs", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Issuing/PersonalizationDesigns.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod43 = StripeResource.method; -var PersonalizationDesigns2 = StripeResource.extend({ - activate: stripeMethod43({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/personalization_designs/{personalization_design}/activate" - }), - deactivate: stripeMethod43({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/personalization_designs/{personalization_design}/deactivate" - }), - reject: stripeMethod43({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/personalization_designs/{personalization_design}/reject" - }) -}); - -// node_modules/stripe/esm/resources/Issuing/PhysicalBundles.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod44 = StripeResource.method; -var PhysicalBundles = StripeResource.extend({ - retrieve: stripeMethod44({ - method: "GET", - fullPath: "/v1/issuing/physical_bundles/{physical_bundle}" - }), - list: stripeMethod44({ - method: "GET", - fullPath: "/v1/issuing/physical_bundles", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Climate/Products.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod45 = StripeResource.method; -var Products = StripeResource.extend({ - retrieve: stripeMethod45({ - method: "GET", - fullPath: "/v1/climate/products/{product}" - }), - list: stripeMethod45({ - method: "GET", - fullPath: "/v1/climate/products", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Terminal/Readers.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod46 = StripeResource.method; -var Readers = StripeResource.extend({ - create: stripeMethod46({ method: "POST", fullPath: "/v1/terminal/readers" }), - retrieve: stripeMethod46({ - method: "GET", - fullPath: "/v1/terminal/readers/{reader}" - }), - update: stripeMethod46({ - method: "POST", - fullPath: "/v1/terminal/readers/{reader}" - }), - list: stripeMethod46({ - method: "GET", - fullPath: "/v1/terminal/readers", - methodType: "list" - }), - del: stripeMethod46({ - method: "DELETE", - fullPath: "/v1/terminal/readers/{reader}" - }), - cancelAction: stripeMethod46({ - method: "POST", - fullPath: "/v1/terminal/readers/{reader}/cancel_action" - }), - collectInputs: stripeMethod46({ - method: "POST", - fullPath: "/v1/terminal/readers/{reader}/collect_inputs" - }), - collectPaymentMethod: stripeMethod46({ - method: "POST", - fullPath: "/v1/terminal/readers/{reader}/collect_payment_method" - }), - confirmPaymentIntent: stripeMethod46({ - method: "POST", - fullPath: "/v1/terminal/readers/{reader}/confirm_payment_intent" - }), - processPaymentIntent: stripeMethod46({ - method: "POST", - fullPath: "/v1/terminal/readers/{reader}/process_payment_intent" - }), - processSetupIntent: stripeMethod46({ - method: "POST", - fullPath: "/v1/terminal/readers/{reader}/process_setup_intent" - }), - refundPayment: stripeMethod46({ - method: "POST", - fullPath: "/v1/terminal/readers/{reader}/refund_payment" - }), - setReaderDisplay: stripeMethod46({ - method: "POST", - fullPath: "/v1/terminal/readers/{reader}/set_reader_display" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Terminal/Readers.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod47 = StripeResource.method; -var Readers2 = StripeResource.extend({ - presentPaymentMethod: stripeMethod47({ - method: "POST", - fullPath: "/v1/test_helpers/terminal/readers/{reader}/present_payment_method" - }), - succeedInputCollection: stripeMethod47({ - method: "POST", - fullPath: "/v1/test_helpers/terminal/readers/{reader}/succeed_input_collection" - }), - timeoutInputCollection: stripeMethod47({ - method: "POST", - fullPath: "/v1/test_helpers/terminal/readers/{reader}/timeout_input_collection" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Treasury/ReceivedCredits.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod48 = StripeResource.method; -var ReceivedCredits = StripeResource.extend({ - create: stripeMethod48({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/received_credits" - }) -}); - -// node_modules/stripe/esm/resources/Treasury/ReceivedCredits.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod49 = StripeResource.method; -var ReceivedCredits2 = StripeResource.extend({ - retrieve: stripeMethod49({ - method: "GET", - fullPath: "/v1/treasury/received_credits/{id}" - }), - list: stripeMethod49({ - method: "GET", - fullPath: "/v1/treasury/received_credits", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Treasury/ReceivedDebits.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod50 = StripeResource.method; -var ReceivedDebits = StripeResource.extend({ - create: stripeMethod50({ - method: "POST", - fullPath: "/v1/test_helpers/treasury/received_debits" - }) -}); - -// node_modules/stripe/esm/resources/Treasury/ReceivedDebits.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod51 = StripeResource.method; -var ReceivedDebits2 = StripeResource.extend({ - retrieve: stripeMethod51({ - method: "GET", - fullPath: "/v1/treasury/received_debits/{id}" - }), - list: stripeMethod51({ - method: "GET", - fullPath: "/v1/treasury/received_debits", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Refunds.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod52 = StripeResource.method; -var Refunds = StripeResource.extend({ - expire: stripeMethod52({ - method: "POST", - fullPath: "/v1/test_helpers/refunds/{refund}/expire" - }) -}); - -// node_modules/stripe/esm/resources/Tax/Registrations.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod53 = StripeResource.method; -var Registrations = StripeResource.extend({ - create: stripeMethod53({ method: "POST", fullPath: "/v1/tax/registrations" }), - retrieve: stripeMethod53({ - method: "GET", - fullPath: "/v1/tax/registrations/{id}" - }), - update: stripeMethod53({ - method: "POST", - fullPath: "/v1/tax/registrations/{id}" - }), - list: stripeMethod53({ - method: "GET", - fullPath: "/v1/tax/registrations", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Reporting/ReportRuns.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod54 = StripeResource.method; -var ReportRuns = StripeResource.extend({ - create: stripeMethod54({ method: "POST", fullPath: "/v1/reporting/report_runs" }), - retrieve: stripeMethod54({ - method: "GET", - fullPath: "/v1/reporting/report_runs/{report_run}" - }), - list: stripeMethod54({ - method: "GET", - fullPath: "/v1/reporting/report_runs", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Reporting/ReportTypes.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod55 = StripeResource.method; -var ReportTypes = StripeResource.extend({ - retrieve: stripeMethod55({ - method: "GET", - fullPath: "/v1/reporting/report_types/{report_type}" - }), - list: stripeMethod55({ - method: "GET", - fullPath: "/v1/reporting/report_types", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Forwarding/Requests.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod56 = StripeResource.method; -var Requests = StripeResource.extend({ - create: stripeMethod56({ method: "POST", fullPath: "/v1/forwarding/requests" }), - retrieve: stripeMethod56({ - method: "GET", - fullPath: "/v1/forwarding/requests/{id}" - }), - list: stripeMethod56({ - method: "GET", - fullPath: "/v1/forwarding/requests", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Sigma/ScheduledQueryRuns.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod57 = StripeResource.method; -var ScheduledQueryRuns = StripeResource.extend({ - retrieve: stripeMethod57({ - method: "GET", - fullPath: "/v1/sigma/scheduled_query_runs/{scheduled_query_run}" - }), - list: stripeMethod57({ - method: "GET", - fullPath: "/v1/sigma/scheduled_query_runs", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Apps/Secrets.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod58 = StripeResource.method; -var Secrets = StripeResource.extend({ - create: stripeMethod58({ method: "POST", fullPath: "/v1/apps/secrets" }), - list: stripeMethod58({ - method: "GET", - fullPath: "/v1/apps/secrets", - methodType: "list" - }), - deleteWhere: stripeMethod58({ - method: "POST", - fullPath: "/v1/apps/secrets/delete" - }), - find: stripeMethod58({ method: "GET", fullPath: "/v1/apps/secrets/find" }) -}); - -// node_modules/stripe/esm/resources/BillingPortal/Sessions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod59 = StripeResource.method; -var Sessions = StripeResource.extend({ - create: stripeMethod59({ - method: "POST", - fullPath: "/v1/billing_portal/sessions" - }) -}); - -// node_modules/stripe/esm/resources/Checkout/Sessions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod60 = StripeResource.method; -var Sessions2 = StripeResource.extend({ - create: stripeMethod60({ method: "POST", fullPath: "/v1/checkout/sessions" }), - retrieve: stripeMethod60({ - method: "GET", - fullPath: "/v1/checkout/sessions/{session}" - }), - update: stripeMethod60({ - method: "POST", - fullPath: "/v1/checkout/sessions/{session}" - }), - list: stripeMethod60({ - method: "GET", - fullPath: "/v1/checkout/sessions", - methodType: "list" - }), - expire: stripeMethod60({ - method: "POST", - fullPath: "/v1/checkout/sessions/{session}/expire" - }), - listLineItems: stripeMethod60({ - method: "GET", - fullPath: "/v1/checkout/sessions/{session}/line_items", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/FinancialConnections/Sessions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod61 = StripeResource.method; -var Sessions3 = StripeResource.extend({ - create: stripeMethod61({ - method: "POST", - fullPath: "/v1/financial_connections/sessions" - }), - retrieve: stripeMethod61({ - method: "GET", - fullPath: "/v1/financial_connections/sessions/{session}" - }) -}); - -// node_modules/stripe/esm/resources/Tax/Settings.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod62 = StripeResource.method; -var Settings = StripeResource.extend({ - retrieve: stripeMethod62({ method: "GET", fullPath: "/v1/tax/settings" }), - update: stripeMethod62({ method: "POST", fullPath: "/v1/tax/settings" }) -}); - -// node_modules/stripe/esm/resources/Climate/Suppliers.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod63 = StripeResource.method; -var Suppliers = StripeResource.extend({ - retrieve: stripeMethod63({ - method: "GET", - fullPath: "/v1/climate/suppliers/{supplier}" - }), - list: stripeMethod63({ - method: "GET", - fullPath: "/v1/climate/suppliers", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/TestClocks.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod64 = StripeResource.method; -var TestClocks = StripeResource.extend({ - create: stripeMethod64({ - method: "POST", - fullPath: "/v1/test_helpers/test_clocks" - }), - retrieve: stripeMethod64({ - method: "GET", - fullPath: "/v1/test_helpers/test_clocks/{test_clock}" - }), - list: stripeMethod64({ - method: "GET", - fullPath: "/v1/test_helpers/test_clocks", - methodType: "list" - }), - del: stripeMethod64({ - method: "DELETE", - fullPath: "/v1/test_helpers/test_clocks/{test_clock}" - }), - advance: stripeMethod64({ - method: "POST", - fullPath: "/v1/test_helpers/test_clocks/{test_clock}/advance" - }) -}); - -// node_modules/stripe/esm/resources/Issuing/Tokens.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod65 = StripeResource.method; -var Tokens = StripeResource.extend({ - retrieve: stripeMethod65({ - method: "GET", - fullPath: "/v1/issuing/tokens/{token}" - }), - update: stripeMethod65({ - method: "POST", - fullPath: "/v1/issuing/tokens/{token}" - }), - list: stripeMethod65({ - method: "GET", - fullPath: "/v1/issuing/tokens", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Treasury/TransactionEntries.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod66 = StripeResource.method; -var TransactionEntries = StripeResource.extend({ - retrieve: stripeMethod66({ - method: "GET", - fullPath: "/v1/treasury/transaction_entries/{id}" - }), - list: stripeMethod66({ - method: "GET", - fullPath: "/v1/treasury/transaction_entries", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/FinancialConnections/Transactions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod67 = StripeResource.method; -var Transactions = StripeResource.extend({ - retrieve: stripeMethod67({ - method: "GET", - fullPath: "/v1/financial_connections/transactions/{transaction}" - }), - list: stripeMethod67({ - method: "GET", - fullPath: "/v1/financial_connections/transactions", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Issuing/Transactions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod68 = StripeResource.method; -var Transactions2 = StripeResource.extend({ - retrieve: stripeMethod68({ - method: "GET", - fullPath: "/v1/issuing/transactions/{transaction}" - }), - update: stripeMethod68({ - method: "POST", - fullPath: "/v1/issuing/transactions/{transaction}" - }), - list: stripeMethod68({ - method: "GET", - fullPath: "/v1/issuing/transactions", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Tax/Transactions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod69 = StripeResource.method; -var Transactions3 = StripeResource.extend({ - retrieve: stripeMethod69({ - method: "GET", - fullPath: "/v1/tax/transactions/{transaction}" - }), - createFromCalculation: stripeMethod69({ - method: "POST", - fullPath: "/v1/tax/transactions/create_from_calculation" - }), - createReversal: stripeMethod69({ - method: "POST", - fullPath: "/v1/tax/transactions/create_reversal" - }), - listLineItems: stripeMethod69({ - method: "GET", - fullPath: "/v1/tax/transactions/{transaction}/line_items", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/TestHelpers/Issuing/Transactions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod70 = StripeResource.method; -var Transactions4 = StripeResource.extend({ - createForceCapture: stripeMethod70({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/transactions/create_force_capture" - }), - createUnlinkedRefund: stripeMethod70({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/transactions/create_unlinked_refund" - }), - refund: stripeMethod70({ - method: "POST", - fullPath: "/v1/test_helpers/issuing/transactions/{transaction}/refund" - }) -}); - -// node_modules/stripe/esm/resources/Treasury/Transactions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod71 = StripeResource.method; -var Transactions5 = StripeResource.extend({ - retrieve: stripeMethod71({ - method: "GET", - fullPath: "/v1/treasury/transactions/{id}" - }), - list: stripeMethod71({ - method: "GET", - fullPath: "/v1/treasury/transactions", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Radar/ValueListItems.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod72 = StripeResource.method; -var ValueListItems = StripeResource.extend({ - create: stripeMethod72({ - method: "POST", - fullPath: "/v1/radar/value_list_items" - }), - retrieve: stripeMethod72({ - method: "GET", - fullPath: "/v1/radar/value_list_items/{item}" - }), - list: stripeMethod72({ - method: "GET", - fullPath: "/v1/radar/value_list_items", - methodType: "list" - }), - del: stripeMethod72({ - method: "DELETE", - fullPath: "/v1/radar/value_list_items/{item}" - }) -}); - -// node_modules/stripe/esm/resources/Radar/ValueLists.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod73 = StripeResource.method; -var ValueLists = StripeResource.extend({ - create: stripeMethod73({ method: "POST", fullPath: "/v1/radar/value_lists" }), - retrieve: stripeMethod73({ - method: "GET", - fullPath: "/v1/radar/value_lists/{value_list}" - }), - update: stripeMethod73({ - method: "POST", - fullPath: "/v1/radar/value_lists/{value_list}" - }), - list: stripeMethod73({ - method: "GET", - fullPath: "/v1/radar/value_lists", - methodType: "list" - }), - del: stripeMethod73({ - method: "DELETE", - fullPath: "/v1/radar/value_lists/{value_list}" - }) -}); - -// node_modules/stripe/esm/resources/Identity/VerificationReports.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod74 = StripeResource.method; -var VerificationReports = StripeResource.extend({ - retrieve: stripeMethod74({ - method: "GET", - fullPath: "/v1/identity/verification_reports/{report}" - }), - list: stripeMethod74({ - method: "GET", - fullPath: "/v1/identity/verification_reports", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Identity/VerificationSessions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod75 = StripeResource.method; -var VerificationSessions = StripeResource.extend({ - create: stripeMethod75({ - method: "POST", - fullPath: "/v1/identity/verification_sessions" - }), - retrieve: stripeMethod75({ - method: "GET", - fullPath: "/v1/identity/verification_sessions/{session}" - }), - update: stripeMethod75({ - method: "POST", - fullPath: "/v1/identity/verification_sessions/{session}" - }), - list: stripeMethod75({ - method: "GET", - fullPath: "/v1/identity/verification_sessions", - methodType: "list" - }), - cancel: stripeMethod75({ - method: "POST", - fullPath: "/v1/identity/verification_sessions/{session}/cancel" - }), - redact: stripeMethod75({ - method: "POST", - fullPath: "/v1/identity/verification_sessions/{session}/redact" - }) -}); - -// node_modules/stripe/esm/resources/Accounts.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod76 = StripeResource.method; -var Accounts2 = StripeResource.extend({ - create: stripeMethod76({ method: "POST", fullPath: "/v1/accounts" }), - retrieve(id, ...args) { - if (typeof id === "string") { - return stripeMethod76({ - method: "GET", - fullPath: "/v1/accounts/{id}" - }).apply(this, [id, ...args]); - } else { - if (id === null || id === void 0) { - [].shift.apply([id, ...args]); - } - return stripeMethod76({ - method: "GET", - fullPath: "/v1/account" - }).apply(this, [id, ...args]); - } - }, - update: stripeMethod76({ method: "POST", fullPath: "/v1/accounts/{account}" }), - list: stripeMethod76({ - method: "GET", - fullPath: "/v1/accounts", - methodType: "list" - }), - del: stripeMethod76({ method: "DELETE", fullPath: "/v1/accounts/{account}" }), - createExternalAccount: stripeMethod76({ - method: "POST", - fullPath: "/v1/accounts/{account}/external_accounts" - }), - createLoginLink: stripeMethod76({ - method: "POST", - fullPath: "/v1/accounts/{account}/login_links" - }), - createPerson: stripeMethod76({ - method: "POST", - fullPath: "/v1/accounts/{account}/persons" - }), - deleteExternalAccount: stripeMethod76({ - method: "DELETE", - fullPath: "/v1/accounts/{account}/external_accounts/{id}" - }), - deletePerson: stripeMethod76({ - method: "DELETE", - fullPath: "/v1/accounts/{account}/persons/{person}" - }), - listCapabilities: stripeMethod76({ - method: "GET", - fullPath: "/v1/accounts/{account}/capabilities", - methodType: "list" - }), - listExternalAccounts: stripeMethod76({ - method: "GET", - fullPath: "/v1/accounts/{account}/external_accounts", - methodType: "list" - }), - listPersons: stripeMethod76({ - method: "GET", - fullPath: "/v1/accounts/{account}/persons", - methodType: "list" - }), - reject: stripeMethod76({ - method: "POST", - fullPath: "/v1/accounts/{account}/reject" - }), - retrieveCurrent: stripeMethod76({ method: "GET", fullPath: "/v1/account" }), - retrieveCapability: stripeMethod76({ - method: "GET", - fullPath: "/v1/accounts/{account}/capabilities/{capability}" - }), - retrieveExternalAccount: stripeMethod76({ - method: "GET", - fullPath: "/v1/accounts/{account}/external_accounts/{id}" - }), - retrievePerson: stripeMethod76({ - method: "GET", - fullPath: "/v1/accounts/{account}/persons/{person}" - }), - updateCapability: stripeMethod76({ - method: "POST", - fullPath: "/v1/accounts/{account}/capabilities/{capability}" - }), - updateExternalAccount: stripeMethod76({ - method: "POST", - fullPath: "/v1/accounts/{account}/external_accounts/{id}" - }), - updatePerson: stripeMethod76({ - method: "POST", - fullPath: "/v1/accounts/{account}/persons/{person}" - }) -}); - -// node_modules/stripe/esm/resources/AccountLinks.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod77 = StripeResource.method; -var AccountLinks = StripeResource.extend({ - create: stripeMethod77({ method: "POST", fullPath: "/v1/account_links" }) -}); - -// node_modules/stripe/esm/resources/AccountSessions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod78 = StripeResource.method; -var AccountSessions = StripeResource.extend({ - create: stripeMethod78({ method: "POST", fullPath: "/v1/account_sessions" }) -}); - -// node_modules/stripe/esm/resources/ApplePayDomains.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod79 = StripeResource.method; -var ApplePayDomains = StripeResource.extend({ - create: stripeMethod79({ method: "POST", fullPath: "/v1/apple_pay/domains" }), - retrieve: stripeMethod79({ - method: "GET", - fullPath: "/v1/apple_pay/domains/{domain}" - }), - list: stripeMethod79({ - method: "GET", - fullPath: "/v1/apple_pay/domains", - methodType: "list" - }), - del: stripeMethod79({ - method: "DELETE", - fullPath: "/v1/apple_pay/domains/{domain}" - }) -}); - -// node_modules/stripe/esm/resources/ApplicationFees.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod80 = StripeResource.method; -var ApplicationFees = StripeResource.extend({ - retrieve: stripeMethod80({ - method: "GET", - fullPath: "/v1/application_fees/{id}" - }), - list: stripeMethod80({ - method: "GET", - fullPath: "/v1/application_fees", - methodType: "list" - }), - createRefund: stripeMethod80({ - method: "POST", - fullPath: "/v1/application_fees/{id}/refunds" - }), - listRefunds: stripeMethod80({ - method: "GET", - fullPath: "/v1/application_fees/{id}/refunds", - methodType: "list" - }), - retrieveRefund: stripeMethod80({ - method: "GET", - fullPath: "/v1/application_fees/{fee}/refunds/{id}" - }), - updateRefund: stripeMethod80({ - method: "POST", - fullPath: "/v1/application_fees/{fee}/refunds/{id}" - }) -}); - -// node_modules/stripe/esm/resources/Balance.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod81 = StripeResource.method; -var Balance = StripeResource.extend({ - retrieve: stripeMethod81({ method: "GET", fullPath: "/v1/balance" }) -}); - -// node_modules/stripe/esm/resources/BalanceTransactions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod82 = StripeResource.method; -var BalanceTransactions = StripeResource.extend({ - retrieve: stripeMethod82({ - method: "GET", - fullPath: "/v1/balance_transactions/{id}" - }), - list: stripeMethod82({ - method: "GET", - fullPath: "/v1/balance_transactions", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Charges.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod83 = StripeResource.method; -var Charges = StripeResource.extend({ - create: stripeMethod83({ method: "POST", fullPath: "/v1/charges" }), - retrieve: stripeMethod83({ method: "GET", fullPath: "/v1/charges/{charge}" }), - update: stripeMethod83({ method: "POST", fullPath: "/v1/charges/{charge}" }), - list: stripeMethod83({ - method: "GET", - fullPath: "/v1/charges", - methodType: "list" - }), - capture: stripeMethod83({ - method: "POST", - fullPath: "/v1/charges/{charge}/capture" - }), - search: stripeMethod83({ - method: "GET", - fullPath: "/v1/charges/search", - methodType: "search" - }) -}); - -// node_modules/stripe/esm/resources/ConfirmationTokens.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod84 = StripeResource.method; -var ConfirmationTokens2 = StripeResource.extend({ - retrieve: stripeMethod84({ - method: "GET", - fullPath: "/v1/confirmation_tokens/{confirmation_token}" - }) -}); - -// node_modules/stripe/esm/resources/CountrySpecs.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod85 = StripeResource.method; -var CountrySpecs = StripeResource.extend({ - retrieve: stripeMethod85({ - method: "GET", - fullPath: "/v1/country_specs/{country}" - }), - list: stripeMethod85({ - method: "GET", - fullPath: "/v1/country_specs", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Coupons.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod86 = StripeResource.method; -var Coupons = StripeResource.extend({ - create: stripeMethod86({ method: "POST", fullPath: "/v1/coupons" }), - retrieve: stripeMethod86({ method: "GET", fullPath: "/v1/coupons/{coupon}" }), - update: stripeMethod86({ method: "POST", fullPath: "/v1/coupons/{coupon}" }), - list: stripeMethod86({ - method: "GET", - fullPath: "/v1/coupons", - methodType: "list" - }), - del: stripeMethod86({ method: "DELETE", fullPath: "/v1/coupons/{coupon}" }) -}); - -// node_modules/stripe/esm/resources/CreditNotes.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod87 = StripeResource.method; -var CreditNotes = StripeResource.extend({ - create: stripeMethod87({ method: "POST", fullPath: "/v1/credit_notes" }), - retrieve: stripeMethod87({ method: "GET", fullPath: "/v1/credit_notes/{id}" }), - update: stripeMethod87({ method: "POST", fullPath: "/v1/credit_notes/{id}" }), - list: stripeMethod87({ - method: "GET", - fullPath: "/v1/credit_notes", - methodType: "list" - }), - listLineItems: stripeMethod87({ - method: "GET", - fullPath: "/v1/credit_notes/{credit_note}/lines", - methodType: "list" - }), - listPreviewLineItems: stripeMethod87({ - method: "GET", - fullPath: "/v1/credit_notes/preview/lines", - methodType: "list" - }), - preview: stripeMethod87({ method: "GET", fullPath: "/v1/credit_notes/preview" }), - voidCreditNote: stripeMethod87({ - method: "POST", - fullPath: "/v1/credit_notes/{id}/void" - }) -}); - -// node_modules/stripe/esm/resources/CustomerSessions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod88 = StripeResource.method; -var CustomerSessions = StripeResource.extend({ - create: stripeMethod88({ method: "POST", fullPath: "/v1/customer_sessions" }) -}); - -// node_modules/stripe/esm/resources/Customers.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod89 = StripeResource.method; -var Customers2 = StripeResource.extend({ - create: stripeMethod89({ method: "POST", fullPath: "/v1/customers" }), - retrieve: stripeMethod89({ method: "GET", fullPath: "/v1/customers/{customer}" }), - update: stripeMethod89({ method: "POST", fullPath: "/v1/customers/{customer}" }), - list: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers", - methodType: "list" - }), - del: stripeMethod89({ method: "DELETE", fullPath: "/v1/customers/{customer}" }), - createBalanceTransaction: stripeMethod89({ - method: "POST", - fullPath: "/v1/customers/{customer}/balance_transactions" - }), - createFundingInstructions: stripeMethod89({ - method: "POST", - fullPath: "/v1/customers/{customer}/funding_instructions" - }), - createSource: stripeMethod89({ - method: "POST", - fullPath: "/v1/customers/{customer}/sources" - }), - createTaxId: stripeMethod89({ - method: "POST", - fullPath: "/v1/customers/{customer}/tax_ids" - }), - deleteDiscount: stripeMethod89({ - method: "DELETE", - fullPath: "/v1/customers/{customer}/discount" - }), - deleteSource: stripeMethod89({ - method: "DELETE", - fullPath: "/v1/customers/{customer}/sources/{id}" - }), - deleteTaxId: stripeMethod89({ - method: "DELETE", - fullPath: "/v1/customers/{customer}/tax_ids/{id}" - }), - listBalanceTransactions: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/balance_transactions", - methodType: "list" - }), - listCashBalanceTransactions: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/cash_balance_transactions", - methodType: "list" - }), - listPaymentMethods: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/payment_methods", - methodType: "list" - }), - listSources: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/sources", - methodType: "list" - }), - listTaxIds: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/tax_ids", - methodType: "list" - }), - retrieveBalanceTransaction: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/balance_transactions/{transaction}" - }), - retrieveCashBalance: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/cash_balance" - }), - retrieveCashBalanceTransaction: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/cash_balance_transactions/{transaction}" - }), - retrievePaymentMethod: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/payment_methods/{payment_method}" - }), - retrieveSource: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/sources/{id}" - }), - retrieveTaxId: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/{customer}/tax_ids/{id}" - }), - search: stripeMethod89({ - method: "GET", - fullPath: "/v1/customers/search", - methodType: "search" - }), - updateBalanceTransaction: stripeMethod89({ - method: "POST", - fullPath: "/v1/customers/{customer}/balance_transactions/{transaction}" - }), - updateCashBalance: stripeMethod89({ - method: "POST", - fullPath: "/v1/customers/{customer}/cash_balance" - }), - updateSource: stripeMethod89({ - method: "POST", - fullPath: "/v1/customers/{customer}/sources/{id}" - }), - verifySource: stripeMethod89({ - method: "POST", - fullPath: "/v1/customers/{customer}/sources/{id}/verify" - }) -}); - -// node_modules/stripe/esm/resources/Disputes.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod90 = StripeResource.method; -var Disputes2 = StripeResource.extend({ - retrieve: stripeMethod90({ method: "GET", fullPath: "/v1/disputes/{dispute}" }), - update: stripeMethod90({ method: "POST", fullPath: "/v1/disputes/{dispute}" }), - list: stripeMethod90({ - method: "GET", - fullPath: "/v1/disputes", - methodType: "list" - }), - close: stripeMethod90({ - method: "POST", - fullPath: "/v1/disputes/{dispute}/close" - }) -}); - -// node_modules/stripe/esm/resources/EphemeralKeys.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod91 = StripeResource.method; -var EphemeralKeys = StripeResource.extend({ - create: stripeMethod91({ - method: "POST", - fullPath: "/v1/ephemeral_keys", - validator: /* @__PURE__ */ __name((data, options) => { - if (!options.headers || !options.headers["Stripe-Version"]) { - throw new Error("Passing apiVersion in a separate options hash is required to create an ephemeral key. See https://stripe.com/docs/api/versioning?lang=node"); - } - }, "validator") - }), - del: stripeMethod91({ method: "DELETE", fullPath: "/v1/ephemeral_keys/{key}" }) -}); - -// node_modules/stripe/esm/resources/Events.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod92 = StripeResource.method; -var Events2 = StripeResource.extend({ - retrieve: stripeMethod92({ method: "GET", fullPath: "/v1/events/{id}" }), - list: stripeMethod92({ - method: "GET", - fullPath: "/v1/events", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/ExchangeRates.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod93 = StripeResource.method; -var ExchangeRates = StripeResource.extend({ - retrieve: stripeMethod93({ - method: "GET", - fullPath: "/v1/exchange_rates/{rate_id}" - }), - list: stripeMethod93({ - method: "GET", - fullPath: "/v1/exchange_rates", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/FileLinks.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod94 = StripeResource.method; -var FileLinks = StripeResource.extend({ - create: stripeMethod94({ method: "POST", fullPath: "/v1/file_links" }), - retrieve: stripeMethod94({ method: "GET", fullPath: "/v1/file_links/{link}" }), - update: stripeMethod94({ method: "POST", fullPath: "/v1/file_links/{link}" }), - list: stripeMethod94({ - method: "GET", - fullPath: "/v1/file_links", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Files.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// node_modules/stripe/esm/multipart.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var multipartDataGenerator = /* @__PURE__ */ __name((method, data, headers) => { - const segno = (Math.round(Math.random() * 1e16) + Math.round(Math.random() * 1e16)).toString(); - headers["Content-Type"] = `multipart/form-data; boundary=${segno}`; - const textEncoder = new TextEncoder(); - let buffer = new Uint8Array(0); - const endBuffer = textEncoder.encode("\r\n"); - function push(l) { - const prevBuffer = buffer; - const newBuffer = l instanceof Uint8Array ? l : new Uint8Array(textEncoder.encode(l)); - buffer = new Uint8Array(prevBuffer.length + newBuffer.length + 2); - buffer.set(prevBuffer); - buffer.set(newBuffer, prevBuffer.length); - buffer.set(endBuffer, buffer.length - 2); - } - __name(push, "push"); - function q(s) { - return `"${s.replace(/"|"/g, "%22").replace(/\r\n|\r|\n/g, " ")}"`; - } - __name(q, "q"); - const flattenedData = flattenAndStringify(data); - for (const k in flattenedData) { - if (!Object.prototype.hasOwnProperty.call(flattenedData, k)) { - continue; - } - const v = flattenedData[k]; - push(`--${segno}`); - if (Object.prototype.hasOwnProperty.call(v, "data")) { - const typedEntry = v; - push(`Content-Disposition: form-data; name=${q(k)}; filename=${q(typedEntry.name || "blob")}`); - push(`Content-Type: ${typedEntry.type || "application/octet-stream"}`); - push(""); - push(typedEntry.data); - } else { - push(`Content-Disposition: form-data; name=${q(k)}`); - push(""); - push(v); - } - } - push(`--${segno}--`); - return buffer; -}, "multipartDataGenerator"); -function multipartRequestDataProcessor(method, data, headers, callback) { - data = data || {}; - if (method !== "POST") { - return callback(null, queryStringifyRequestData(data)); - } - this._stripe._platformFunctions.tryBufferData(data).then((bufferedData) => { - const buffer = multipartDataGenerator(method, bufferedData, headers); - return callback(null, buffer); - }).catch((err) => callback(err, null)); -} -__name(multipartRequestDataProcessor, "multipartRequestDataProcessor"); - -// node_modules/stripe/esm/resources/Files.js -var stripeMethod95 = StripeResource.method; -var Files = StripeResource.extend({ - create: stripeMethod95({ - method: "POST", - fullPath: "/v1/files", - headers: { - "Content-Type": "multipart/form-data" - }, - host: "files.stripe.com" - }), - retrieve: stripeMethod95({ method: "GET", fullPath: "/v1/files/{file}" }), - list: stripeMethod95({ - method: "GET", - fullPath: "/v1/files", - methodType: "list" - }), - requestDataProcessor: multipartRequestDataProcessor -}); - -// node_modules/stripe/esm/resources/InvoiceItems.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod96 = StripeResource.method; -var InvoiceItems = StripeResource.extend({ - create: stripeMethod96({ method: "POST", fullPath: "/v1/invoiceitems" }), - retrieve: stripeMethod96({ - method: "GET", - fullPath: "/v1/invoiceitems/{invoiceitem}" - }), - update: stripeMethod96({ - method: "POST", - fullPath: "/v1/invoiceitems/{invoiceitem}" - }), - list: stripeMethod96({ - method: "GET", - fullPath: "/v1/invoiceitems", - methodType: "list" - }), - del: stripeMethod96({ - method: "DELETE", - fullPath: "/v1/invoiceitems/{invoiceitem}" - }) -}); - -// node_modules/stripe/esm/resources/InvoicePayments.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod97 = StripeResource.method; -var InvoicePayments = StripeResource.extend({ - retrieve: stripeMethod97({ - method: "GET", - fullPath: "/v1/invoice_payments/{invoice_payment}" - }), - list: stripeMethod97({ - method: "GET", - fullPath: "/v1/invoice_payments", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/InvoiceRenderingTemplates.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod98 = StripeResource.method; -var InvoiceRenderingTemplates = StripeResource.extend({ - retrieve: stripeMethod98({ - method: "GET", - fullPath: "/v1/invoice_rendering_templates/{template}" - }), - list: stripeMethod98({ - method: "GET", - fullPath: "/v1/invoice_rendering_templates", - methodType: "list" - }), - archive: stripeMethod98({ - method: "POST", - fullPath: "/v1/invoice_rendering_templates/{template}/archive" - }), - unarchive: stripeMethod98({ - method: "POST", - fullPath: "/v1/invoice_rendering_templates/{template}/unarchive" - }) -}); - -// node_modules/stripe/esm/resources/Invoices.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod99 = StripeResource.method; -var Invoices = StripeResource.extend({ - create: stripeMethod99({ method: "POST", fullPath: "/v1/invoices" }), - retrieve: stripeMethod99({ method: "GET", fullPath: "/v1/invoices/{invoice}" }), - update: stripeMethod99({ method: "POST", fullPath: "/v1/invoices/{invoice}" }), - list: stripeMethod99({ - method: "GET", - fullPath: "/v1/invoices", - methodType: "list" - }), - del: stripeMethod99({ method: "DELETE", fullPath: "/v1/invoices/{invoice}" }), - addLines: stripeMethod99({ - method: "POST", - fullPath: "/v1/invoices/{invoice}/add_lines" - }), - attachPayment: stripeMethod99({ - method: "POST", - fullPath: "/v1/invoices/{invoice}/attach_payment" - }), - createPreview: stripeMethod99({ - method: "POST", - fullPath: "/v1/invoices/create_preview" - }), - finalizeInvoice: stripeMethod99({ - method: "POST", - fullPath: "/v1/invoices/{invoice}/finalize" - }), - listLineItems: stripeMethod99({ - method: "GET", - fullPath: "/v1/invoices/{invoice}/lines", - methodType: "list" - }), - markUncollectible: stripeMethod99({ - method: "POST", - fullPath: "/v1/invoices/{invoice}/mark_uncollectible" - }), - pay: stripeMethod99({ method: "POST", fullPath: "/v1/invoices/{invoice}/pay" }), - removeLines: stripeMethod99({ - method: "POST", - fullPath: "/v1/invoices/{invoice}/remove_lines" - }), - search: stripeMethod99({ - method: "GET", - fullPath: "/v1/invoices/search", - methodType: "search" - }), - sendInvoice: stripeMethod99({ - method: "POST", - fullPath: "/v1/invoices/{invoice}/send" - }), - updateLines: stripeMethod99({ - method: "POST", - fullPath: "/v1/invoices/{invoice}/update_lines" - }), - updateLineItem: stripeMethod99({ - method: "POST", - fullPath: "/v1/invoices/{invoice}/lines/{line_item_id}" - }), - voidInvoice: stripeMethod99({ - method: "POST", - fullPath: "/v1/invoices/{invoice}/void" - }) -}); - -// node_modules/stripe/esm/resources/Mandates.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod100 = StripeResource.method; -var Mandates = StripeResource.extend({ - retrieve: stripeMethod100({ method: "GET", fullPath: "/v1/mandates/{mandate}" }) -}); - -// node_modules/stripe/esm/resources/OAuth.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod101 = StripeResource.method; -var oAuthHost = "connect.stripe.com"; -var OAuth = StripeResource.extend({ - basePath: "/", - authorizeUrl(params, options) { - params = params || {}; - options = options || {}; - let path = "oauth/authorize"; - if (options.express) { - path = `express/${path}`; - } - if (!params.response_type) { - params.response_type = "code"; - } - if (!params.client_id) { - params.client_id = this._stripe.getClientId(); - } - if (!params.scope) { - params.scope = "read_write"; - } - return `https://${oAuthHost}/${path}?${queryStringifyRequestData(params)}`; - }, - token: stripeMethod101({ - method: "POST", - path: "oauth/token", - host: oAuthHost - }), - deauthorize(spec, ...args) { - if (!spec.client_id) { - spec.client_id = this._stripe.getClientId(); - } - return stripeMethod101({ - method: "POST", - path: "oauth/deauthorize", - host: oAuthHost - }).apply(this, [spec, ...args]); - } -}); - -// node_modules/stripe/esm/resources/PaymentIntents.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod102 = StripeResource.method; -var PaymentIntents = StripeResource.extend({ - create: stripeMethod102({ method: "POST", fullPath: "/v1/payment_intents" }), - retrieve: stripeMethod102({ - method: "GET", - fullPath: "/v1/payment_intents/{intent}" - }), - update: stripeMethod102({ - method: "POST", - fullPath: "/v1/payment_intents/{intent}" - }), - list: stripeMethod102({ - method: "GET", - fullPath: "/v1/payment_intents", - methodType: "list" - }), - applyCustomerBalance: stripeMethod102({ - method: "POST", - fullPath: "/v1/payment_intents/{intent}/apply_customer_balance" - }), - cancel: stripeMethod102({ - method: "POST", - fullPath: "/v1/payment_intents/{intent}/cancel" - }), - capture: stripeMethod102({ - method: "POST", - fullPath: "/v1/payment_intents/{intent}/capture" - }), - confirm: stripeMethod102({ - method: "POST", - fullPath: "/v1/payment_intents/{intent}/confirm" - }), - incrementAuthorization: stripeMethod102({ - method: "POST", - fullPath: "/v1/payment_intents/{intent}/increment_authorization" - }), - search: stripeMethod102({ - method: "GET", - fullPath: "/v1/payment_intents/search", - methodType: "search" - }), - verifyMicrodeposits: stripeMethod102({ - method: "POST", - fullPath: "/v1/payment_intents/{intent}/verify_microdeposits" - }) -}); - -// node_modules/stripe/esm/resources/PaymentLinks.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod103 = StripeResource.method; -var PaymentLinks = StripeResource.extend({ - create: stripeMethod103({ method: "POST", fullPath: "/v1/payment_links" }), - retrieve: stripeMethod103({ - method: "GET", - fullPath: "/v1/payment_links/{payment_link}" - }), - update: stripeMethod103({ - method: "POST", - fullPath: "/v1/payment_links/{payment_link}" - }), - list: stripeMethod103({ - method: "GET", - fullPath: "/v1/payment_links", - methodType: "list" - }), - listLineItems: stripeMethod103({ - method: "GET", - fullPath: "/v1/payment_links/{payment_link}/line_items", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/PaymentMethodConfigurations.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod104 = StripeResource.method; -var PaymentMethodConfigurations = StripeResource.extend({ - create: stripeMethod104({ - method: "POST", - fullPath: "/v1/payment_method_configurations" - }), - retrieve: stripeMethod104({ - method: "GET", - fullPath: "/v1/payment_method_configurations/{configuration}" - }), - update: stripeMethod104({ - method: "POST", - fullPath: "/v1/payment_method_configurations/{configuration}" - }), - list: stripeMethod104({ - method: "GET", - fullPath: "/v1/payment_method_configurations", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/PaymentMethodDomains.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod105 = StripeResource.method; -var PaymentMethodDomains = StripeResource.extend({ - create: stripeMethod105({ - method: "POST", - fullPath: "/v1/payment_method_domains" - }), - retrieve: stripeMethod105({ - method: "GET", - fullPath: "/v1/payment_method_domains/{payment_method_domain}" - }), - update: stripeMethod105({ - method: "POST", - fullPath: "/v1/payment_method_domains/{payment_method_domain}" - }), - list: stripeMethod105({ - method: "GET", - fullPath: "/v1/payment_method_domains", - methodType: "list" - }), - validate: stripeMethod105({ - method: "POST", - fullPath: "/v1/payment_method_domains/{payment_method_domain}/validate" - }) -}); - -// node_modules/stripe/esm/resources/PaymentMethods.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod106 = StripeResource.method; -var PaymentMethods = StripeResource.extend({ - create: stripeMethod106({ method: "POST", fullPath: "/v1/payment_methods" }), - retrieve: stripeMethod106({ - method: "GET", - fullPath: "/v1/payment_methods/{payment_method}" - }), - update: stripeMethod106({ - method: "POST", - fullPath: "/v1/payment_methods/{payment_method}" - }), - list: stripeMethod106({ - method: "GET", - fullPath: "/v1/payment_methods", - methodType: "list" - }), - attach: stripeMethod106({ - method: "POST", - fullPath: "/v1/payment_methods/{payment_method}/attach" - }), - detach: stripeMethod106({ - method: "POST", - fullPath: "/v1/payment_methods/{payment_method}/detach" - }) -}); - -// node_modules/stripe/esm/resources/Payouts.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod107 = StripeResource.method; -var Payouts = StripeResource.extend({ - create: stripeMethod107({ method: "POST", fullPath: "/v1/payouts" }), - retrieve: stripeMethod107({ method: "GET", fullPath: "/v1/payouts/{payout}" }), - update: stripeMethod107({ method: "POST", fullPath: "/v1/payouts/{payout}" }), - list: stripeMethod107({ - method: "GET", - fullPath: "/v1/payouts", - methodType: "list" - }), - cancel: stripeMethod107({ - method: "POST", - fullPath: "/v1/payouts/{payout}/cancel" - }), - reverse: stripeMethod107({ - method: "POST", - fullPath: "/v1/payouts/{payout}/reverse" - }) -}); - -// node_modules/stripe/esm/resources/Plans.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod108 = StripeResource.method; -var Plans = StripeResource.extend({ - create: stripeMethod108({ method: "POST", fullPath: "/v1/plans" }), - retrieve: stripeMethod108({ method: "GET", fullPath: "/v1/plans/{plan}" }), - update: stripeMethod108({ method: "POST", fullPath: "/v1/plans/{plan}" }), - list: stripeMethod108({ - method: "GET", - fullPath: "/v1/plans", - methodType: "list" - }), - del: stripeMethod108({ method: "DELETE", fullPath: "/v1/plans/{plan}" }) -}); - -// node_modules/stripe/esm/resources/Prices.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod109 = StripeResource.method; -var Prices = StripeResource.extend({ - create: stripeMethod109({ method: "POST", fullPath: "/v1/prices" }), - retrieve: stripeMethod109({ method: "GET", fullPath: "/v1/prices/{price}" }), - update: stripeMethod109({ method: "POST", fullPath: "/v1/prices/{price}" }), - list: stripeMethod109({ - method: "GET", - fullPath: "/v1/prices", - methodType: "list" - }), - search: stripeMethod109({ - method: "GET", - fullPath: "/v1/prices/search", - methodType: "search" - }) -}); - -// node_modules/stripe/esm/resources/Products.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod110 = StripeResource.method; -var Products2 = StripeResource.extend({ - create: stripeMethod110({ method: "POST", fullPath: "/v1/products" }), - retrieve: stripeMethod110({ method: "GET", fullPath: "/v1/products/{id}" }), - update: stripeMethod110({ method: "POST", fullPath: "/v1/products/{id}" }), - list: stripeMethod110({ - method: "GET", - fullPath: "/v1/products", - methodType: "list" - }), - del: stripeMethod110({ method: "DELETE", fullPath: "/v1/products/{id}" }), - createFeature: stripeMethod110({ - method: "POST", - fullPath: "/v1/products/{product}/features" - }), - deleteFeature: stripeMethod110({ - method: "DELETE", - fullPath: "/v1/products/{product}/features/{id}" - }), - listFeatures: stripeMethod110({ - method: "GET", - fullPath: "/v1/products/{product}/features", - methodType: "list" - }), - retrieveFeature: stripeMethod110({ - method: "GET", - fullPath: "/v1/products/{product}/features/{id}" - }), - search: stripeMethod110({ - method: "GET", - fullPath: "/v1/products/search", - methodType: "search" - }) -}); - -// node_modules/stripe/esm/resources/PromotionCodes.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod111 = StripeResource.method; -var PromotionCodes = StripeResource.extend({ - create: stripeMethod111({ method: "POST", fullPath: "/v1/promotion_codes" }), - retrieve: stripeMethod111({ - method: "GET", - fullPath: "/v1/promotion_codes/{promotion_code}" - }), - update: stripeMethod111({ - method: "POST", - fullPath: "/v1/promotion_codes/{promotion_code}" - }), - list: stripeMethod111({ - method: "GET", - fullPath: "/v1/promotion_codes", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Quotes.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod112 = StripeResource.method; -var Quotes = StripeResource.extend({ - create: stripeMethod112({ method: "POST", fullPath: "/v1/quotes" }), - retrieve: stripeMethod112({ method: "GET", fullPath: "/v1/quotes/{quote}" }), - update: stripeMethod112({ method: "POST", fullPath: "/v1/quotes/{quote}" }), - list: stripeMethod112({ - method: "GET", - fullPath: "/v1/quotes", - methodType: "list" - }), - accept: stripeMethod112({ method: "POST", fullPath: "/v1/quotes/{quote}/accept" }), - cancel: stripeMethod112({ method: "POST", fullPath: "/v1/quotes/{quote}/cancel" }), - finalizeQuote: stripeMethod112({ - method: "POST", - fullPath: "/v1/quotes/{quote}/finalize" - }), - listComputedUpfrontLineItems: stripeMethod112({ - method: "GET", - fullPath: "/v1/quotes/{quote}/computed_upfront_line_items", - methodType: "list" - }), - listLineItems: stripeMethod112({ - method: "GET", - fullPath: "/v1/quotes/{quote}/line_items", - methodType: "list" - }), - pdf: stripeMethod112({ - method: "GET", - fullPath: "/v1/quotes/{quote}/pdf", - host: "files.stripe.com", - streaming: true - }) -}); - -// node_modules/stripe/esm/resources/Refunds.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod113 = StripeResource.method; -var Refunds2 = StripeResource.extend({ - create: stripeMethod113({ method: "POST", fullPath: "/v1/refunds" }), - retrieve: stripeMethod113({ method: "GET", fullPath: "/v1/refunds/{refund}" }), - update: stripeMethod113({ method: "POST", fullPath: "/v1/refunds/{refund}" }), - list: stripeMethod113({ - method: "GET", - fullPath: "/v1/refunds", - methodType: "list" - }), - cancel: stripeMethod113({ - method: "POST", - fullPath: "/v1/refunds/{refund}/cancel" - }) -}); - -// node_modules/stripe/esm/resources/Reviews.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod114 = StripeResource.method; -var Reviews = StripeResource.extend({ - retrieve: stripeMethod114({ method: "GET", fullPath: "/v1/reviews/{review}" }), - list: stripeMethod114({ - method: "GET", - fullPath: "/v1/reviews", - methodType: "list" - }), - approve: stripeMethod114({ - method: "POST", - fullPath: "/v1/reviews/{review}/approve" - }) -}); - -// node_modules/stripe/esm/resources/SetupAttempts.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod115 = StripeResource.method; -var SetupAttempts = StripeResource.extend({ - list: stripeMethod115({ - method: "GET", - fullPath: "/v1/setup_attempts", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/SetupIntents.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod116 = StripeResource.method; -var SetupIntents = StripeResource.extend({ - create: stripeMethod116({ method: "POST", fullPath: "/v1/setup_intents" }), - retrieve: stripeMethod116({ - method: "GET", - fullPath: "/v1/setup_intents/{intent}" - }), - update: stripeMethod116({ - method: "POST", - fullPath: "/v1/setup_intents/{intent}" - }), - list: stripeMethod116({ - method: "GET", - fullPath: "/v1/setup_intents", - methodType: "list" - }), - cancel: stripeMethod116({ - method: "POST", - fullPath: "/v1/setup_intents/{intent}/cancel" - }), - confirm: stripeMethod116({ - method: "POST", - fullPath: "/v1/setup_intents/{intent}/confirm" - }), - verifyMicrodeposits: stripeMethod116({ - method: "POST", - fullPath: "/v1/setup_intents/{intent}/verify_microdeposits" - }) -}); - -// node_modules/stripe/esm/resources/ShippingRates.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod117 = StripeResource.method; -var ShippingRates = StripeResource.extend({ - create: stripeMethod117({ method: "POST", fullPath: "/v1/shipping_rates" }), - retrieve: stripeMethod117({ - method: "GET", - fullPath: "/v1/shipping_rates/{shipping_rate_token}" - }), - update: stripeMethod117({ - method: "POST", - fullPath: "/v1/shipping_rates/{shipping_rate_token}" - }), - list: stripeMethod117({ - method: "GET", - fullPath: "/v1/shipping_rates", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Sources.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod118 = StripeResource.method; -var Sources = StripeResource.extend({ - create: stripeMethod118({ method: "POST", fullPath: "/v1/sources" }), - retrieve: stripeMethod118({ method: "GET", fullPath: "/v1/sources/{source}" }), - update: stripeMethod118({ method: "POST", fullPath: "/v1/sources/{source}" }), - listSourceTransactions: stripeMethod118({ - method: "GET", - fullPath: "/v1/sources/{source}/source_transactions", - methodType: "list" - }), - verify: stripeMethod118({ - method: "POST", - fullPath: "/v1/sources/{source}/verify" - }) -}); - -// node_modules/stripe/esm/resources/SubscriptionItems.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod119 = StripeResource.method; -var SubscriptionItems = StripeResource.extend({ - create: stripeMethod119({ method: "POST", fullPath: "/v1/subscription_items" }), - retrieve: stripeMethod119({ - method: "GET", - fullPath: "/v1/subscription_items/{item}" - }), - update: stripeMethod119({ - method: "POST", - fullPath: "/v1/subscription_items/{item}" - }), - list: stripeMethod119({ - method: "GET", - fullPath: "/v1/subscription_items", - methodType: "list" - }), - del: stripeMethod119({ - method: "DELETE", - fullPath: "/v1/subscription_items/{item}" - }) -}); - -// node_modules/stripe/esm/resources/SubscriptionSchedules.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod120 = StripeResource.method; -var SubscriptionSchedules = StripeResource.extend({ - create: stripeMethod120({ - method: "POST", - fullPath: "/v1/subscription_schedules" - }), - retrieve: stripeMethod120({ - method: "GET", - fullPath: "/v1/subscription_schedules/{schedule}" - }), - update: stripeMethod120({ - method: "POST", - fullPath: "/v1/subscription_schedules/{schedule}" - }), - list: stripeMethod120({ - method: "GET", - fullPath: "/v1/subscription_schedules", - methodType: "list" - }), - cancel: stripeMethod120({ - method: "POST", - fullPath: "/v1/subscription_schedules/{schedule}/cancel" - }), - release: stripeMethod120({ - method: "POST", - fullPath: "/v1/subscription_schedules/{schedule}/release" - }) -}); - -// node_modules/stripe/esm/resources/Subscriptions.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod121 = StripeResource.method; -var Subscriptions = StripeResource.extend({ - create: stripeMethod121({ method: "POST", fullPath: "/v1/subscriptions" }), - retrieve: stripeMethod121({ - method: "GET", - fullPath: "/v1/subscriptions/{subscription_exposed_id}" - }), - update: stripeMethod121({ - method: "POST", - fullPath: "/v1/subscriptions/{subscription_exposed_id}" - }), - list: stripeMethod121({ - method: "GET", - fullPath: "/v1/subscriptions", - methodType: "list" - }), - cancel: stripeMethod121({ - method: "DELETE", - fullPath: "/v1/subscriptions/{subscription_exposed_id}" - }), - deleteDiscount: stripeMethod121({ - method: "DELETE", - fullPath: "/v1/subscriptions/{subscription_exposed_id}/discount" - }), - migrate: stripeMethod121({ - method: "POST", - fullPath: "/v1/subscriptions/{subscription}/migrate" - }), - resume: stripeMethod121({ - method: "POST", - fullPath: "/v1/subscriptions/{subscription}/resume" - }), - search: stripeMethod121({ - method: "GET", - fullPath: "/v1/subscriptions/search", - methodType: "search" - }) -}); - -// node_modules/stripe/esm/resources/TaxCodes.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod122 = StripeResource.method; -var TaxCodes = StripeResource.extend({ - retrieve: stripeMethod122({ method: "GET", fullPath: "/v1/tax_codes/{id}" }), - list: stripeMethod122({ - method: "GET", - fullPath: "/v1/tax_codes", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/TaxIds.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod123 = StripeResource.method; -var TaxIds = StripeResource.extend({ - create: stripeMethod123({ method: "POST", fullPath: "/v1/tax_ids" }), - retrieve: stripeMethod123({ method: "GET", fullPath: "/v1/tax_ids/{id}" }), - list: stripeMethod123({ - method: "GET", - fullPath: "/v1/tax_ids", - methodType: "list" - }), - del: stripeMethod123({ method: "DELETE", fullPath: "/v1/tax_ids/{id}" }) -}); - -// node_modules/stripe/esm/resources/TaxRates.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod124 = StripeResource.method; -var TaxRates = StripeResource.extend({ - create: stripeMethod124({ method: "POST", fullPath: "/v1/tax_rates" }), - retrieve: stripeMethod124({ method: "GET", fullPath: "/v1/tax_rates/{tax_rate}" }), - update: stripeMethod124({ method: "POST", fullPath: "/v1/tax_rates/{tax_rate}" }), - list: stripeMethod124({ - method: "GET", - fullPath: "/v1/tax_rates", - methodType: "list" - }) -}); - -// node_modules/stripe/esm/resources/Tokens.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod125 = StripeResource.method; -var Tokens2 = StripeResource.extend({ - create: stripeMethod125({ method: "POST", fullPath: "/v1/tokens" }), - retrieve: stripeMethod125({ method: "GET", fullPath: "/v1/tokens/{token}" }) -}); - -// node_modules/stripe/esm/resources/Topups.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod126 = StripeResource.method; -var Topups = StripeResource.extend({ - create: stripeMethod126({ method: "POST", fullPath: "/v1/topups" }), - retrieve: stripeMethod126({ method: "GET", fullPath: "/v1/topups/{topup}" }), - update: stripeMethod126({ method: "POST", fullPath: "/v1/topups/{topup}" }), - list: stripeMethod126({ - method: "GET", - fullPath: "/v1/topups", - methodType: "list" - }), - cancel: stripeMethod126({ method: "POST", fullPath: "/v1/topups/{topup}/cancel" }) -}); - -// node_modules/stripe/esm/resources/Transfers.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod127 = StripeResource.method; -var Transfers = StripeResource.extend({ - create: stripeMethod127({ method: "POST", fullPath: "/v1/transfers" }), - retrieve: stripeMethod127({ method: "GET", fullPath: "/v1/transfers/{transfer}" }), - update: stripeMethod127({ method: "POST", fullPath: "/v1/transfers/{transfer}" }), - list: stripeMethod127({ - method: "GET", - fullPath: "/v1/transfers", - methodType: "list" - }), - createReversal: stripeMethod127({ - method: "POST", - fullPath: "/v1/transfers/{id}/reversals" - }), - listReversals: stripeMethod127({ - method: "GET", - fullPath: "/v1/transfers/{id}/reversals", - methodType: "list" - }), - retrieveReversal: stripeMethod127({ - method: "GET", - fullPath: "/v1/transfers/{transfer}/reversals/{id}" - }), - updateReversal: stripeMethod127({ - method: "POST", - fullPath: "/v1/transfers/{transfer}/reversals/{id}" - }) -}); - -// node_modules/stripe/esm/resources/WebhookEndpoints.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var stripeMethod128 = StripeResource.method; -var WebhookEndpoints = StripeResource.extend({ - create: stripeMethod128({ method: "POST", fullPath: "/v1/webhook_endpoints" }), - retrieve: stripeMethod128({ - method: "GET", - fullPath: "/v1/webhook_endpoints/{webhook_endpoint}" - }), - update: stripeMethod128({ - method: "POST", - fullPath: "/v1/webhook_endpoints/{webhook_endpoint}" - }), - list: stripeMethod128({ - method: "GET", - fullPath: "/v1/webhook_endpoints", - methodType: "list" - }), - del: stripeMethod128({ - method: "DELETE", - fullPath: "/v1/webhook_endpoints/{webhook_endpoint}" - }) -}); - -// node_modules/stripe/esm/resources.js -var Apps = resourceNamespace("apps", { Secrets }); -var Billing = resourceNamespace("billing", { - Alerts, - CreditBalanceSummary, - CreditBalanceTransactions, - CreditGrants, - MeterEventAdjustments, - MeterEvents, - Meters -}); -var BillingPortal = resourceNamespace("billingPortal", { - Configurations, - Sessions -}); -var Checkout = resourceNamespace("checkout", { - Sessions: Sessions2 -}); -var Climate = resourceNamespace("climate", { - Orders, - Products, - Suppliers -}); -var Entitlements = resourceNamespace("entitlements", { - ActiveEntitlements, - Features -}); -var FinancialConnections = resourceNamespace("financialConnections", { - Accounts, - Sessions: Sessions3, - Transactions -}); -var Forwarding = resourceNamespace("forwarding", { - Requests -}); -var Identity = resourceNamespace("identity", { - VerificationReports, - VerificationSessions -}); -var Issuing = resourceNamespace("issuing", { - Authorizations, - Cardholders, - Cards, - Disputes, - PersonalizationDesigns, - PhysicalBundles, - Tokens, - Transactions: Transactions2 -}); -var Radar = resourceNamespace("radar", { - EarlyFraudWarnings, - ValueListItems, - ValueLists -}); -var Reporting = resourceNamespace("reporting", { - ReportRuns, - ReportTypes -}); -var Sigma = resourceNamespace("sigma", { - ScheduledQueryRuns -}); -var Tax = resourceNamespace("tax", { - Calculations, - Registrations, - Settings, - Transactions: Transactions3 -}); -var Terminal = resourceNamespace("terminal", { - Configurations: Configurations2, - ConnectionTokens, - Locations, - Readers -}); -var TestHelpers = resourceNamespace("testHelpers", { - ConfirmationTokens, - Customers, - Refunds, - TestClocks, - Issuing: resourceNamespace("issuing", { - Authorizations: Authorizations2, - Cards: Cards2, - PersonalizationDesigns: PersonalizationDesigns2, - Transactions: Transactions4 - }), - Terminal: resourceNamespace("terminal", { - Readers: Readers2 - }), - Treasury: resourceNamespace("treasury", { - InboundTransfers, - OutboundPayments, - OutboundTransfers, - ReceivedCredits, - ReceivedDebits - }) -}); -var Treasury = resourceNamespace("treasury", { - CreditReversals, - DebitReversals, - FinancialAccounts, - InboundTransfers: InboundTransfers2, - OutboundPayments: OutboundPayments2, - OutboundTransfers: OutboundTransfers2, - ReceivedCredits: ReceivedCredits2, - ReceivedDebits: ReceivedDebits2, - TransactionEntries, - Transactions: Transactions5 -}); -var V2 = resourceNamespace("v2", { - Billing: resourceNamespace("billing", { - MeterEventAdjustments: MeterEventAdjustments2, - MeterEventSession, - MeterEventStream, - MeterEvents: MeterEvents2 - }), - Core: resourceNamespace("core", { - EventDestinations, - Events - }) -}); - -// node_modules/stripe/esm/stripe.core.js -var DEFAULT_HOST = "api.stripe.com"; -var DEFAULT_PORT = "443"; -var DEFAULT_BASE_PATH = "/v1/"; -var DEFAULT_API_VERSION = ApiVersion; -var DEFAULT_TIMEOUT = 8e4; -var MAX_NETWORK_RETRY_DELAY_SEC = 5; -var INITIAL_NETWORK_RETRY_DELAY_SEC = 0.5; -var APP_INFO_PROPERTIES = ["name", "version", "url", "partner_id"]; -var ALLOWED_CONFIG_PROPERTIES = [ - "authenticator", - "apiVersion", - "typescript", - "maxNetworkRetries", - "httpAgent", - "httpClient", - "timeout", - "host", - "port", - "protocol", - "telemetry", - "appInfo", - "stripeAccount", - "stripeContext" -]; -var defaultRequestSenderFactory = /* @__PURE__ */ __name((stripe) => new RequestSender(stripe, StripeResource.MAX_BUFFERED_REQUEST_METRICS), "defaultRequestSenderFactory"); -function createStripe(platformFunctions, requestSender = defaultRequestSenderFactory) { - Stripe2.PACKAGE_VERSION = "18.5.0"; - Stripe2.API_VERSION = ApiVersion; - Stripe2.USER_AGENT = Object.assign({ bindings_version: Stripe2.PACKAGE_VERSION, lang: "node", publisher: "stripe", uname: null, typescript: false }, determineProcessUserAgentProperties()); - Stripe2.StripeResource = StripeResource; - Stripe2.resources = resources_exports; - Stripe2.HttpClient = HttpClient; - Stripe2.HttpClientResponse = HttpClientResponse; - Stripe2.CryptoProvider = CryptoProvider; - Stripe2.webhooks = createWebhooks(platformFunctions); - function Stripe2(key, config2 = {}) { - if (!(this instanceof Stripe2)) { - return new Stripe2(key, config2); - } - const props = this._getPropsFromConfig(config2); - this._platformFunctions = platformFunctions; - Object.defineProperty(this, "_emitter", { - value: this._platformFunctions.createEmitter(), - enumerable: false, - configurable: false, - writable: false - }); - this.VERSION = Stripe2.PACKAGE_VERSION; - this.on = this._emitter.on.bind(this._emitter); - this.once = this._emitter.once.bind(this._emitter); - this.off = this._emitter.removeListener.bind(this._emitter); - const agent = props.httpAgent || null; - this._api = { - host: props.host || DEFAULT_HOST, - port: props.port || DEFAULT_PORT, - protocol: props.protocol || "https", - basePath: DEFAULT_BASE_PATH, - version: props.apiVersion || DEFAULT_API_VERSION, - timeout: validateInteger("timeout", props.timeout, DEFAULT_TIMEOUT), - maxNetworkRetries: validateInteger("maxNetworkRetries", props.maxNetworkRetries, 2), - agent, - httpClient: props.httpClient || (agent ? this._platformFunctions.createNodeHttpClient(agent) : this._platformFunctions.createDefaultHttpClient()), - dev: false, - stripeAccount: props.stripeAccount || null, - stripeContext: props.stripeContext || null - }; - const typescript = props.typescript || false; - if (typescript !== Stripe2.USER_AGENT.typescript) { - Stripe2.USER_AGENT.typescript = typescript; - } - if (props.appInfo) { - this._setAppInfo(props.appInfo); - } - this._prepResources(); - this._setAuthenticator(key, props.authenticator); - this.errors = Error_exports; - this.webhooks = Stripe2.webhooks; - this._prevRequestMetrics = []; - this._enableTelemetry = props.telemetry !== false; - this._requestSender = requestSender(this); - this.StripeResource = Stripe2.StripeResource; - } - __name(Stripe2, "Stripe"); - Stripe2.errors = Error_exports; - Stripe2.createNodeHttpClient = platformFunctions.createNodeHttpClient; - Stripe2.createFetchHttpClient = platformFunctions.createFetchHttpClient; - Stripe2.createNodeCryptoProvider = platformFunctions.createNodeCryptoProvider; - Stripe2.createSubtleCryptoProvider = platformFunctions.createSubtleCryptoProvider; - Stripe2.prototype = { - // Properties are set in the constructor above - _appInfo: void 0, - on: null, - off: null, - once: null, - VERSION: null, - StripeResource: null, - webhooks: null, - errors: null, - _api: null, - _prevRequestMetrics: null, - _emitter: null, - _enableTelemetry: null, - _requestSender: null, - _platformFunctions: null, - rawRequest(method, path, params, options) { - return this._requestSender._rawRequest(method, path, params, options); - }, - /** - * @private - */ - _setAuthenticator(key, authenticator) { - if (key && authenticator) { - throw new Error("Can't specify both apiKey and authenticator"); - } - if (!key && !authenticator) { - throw new Error("Neither apiKey nor config.authenticator provided"); - } - this._authenticator = key ? createApiKeyAuthenticator(key) : authenticator; - }, - /** - * @private - * This may be removed in the future. - */ - _setAppInfo(info3) { - if (info3 && typeof info3 !== "object") { - throw new Error("AppInfo must be an object."); - } - if (info3 && !info3.name) { - throw new Error("AppInfo.name is required"); - } - info3 = info3 || {}; - this._appInfo = APP_INFO_PROPERTIES.reduce((accum, prop) => { - if (typeof info3[prop] == "string") { - accum = accum || {}; - accum[prop] = info3[prop]; - } - return accum; - }, {}); - }, - /** - * @private - * This may be removed in the future. - */ - _setApiField(key, value) { - this._api[key] = value; - }, - /** - * @private - * Please open or upvote an issue at github.com/stripe/stripe-node - * if you use this, detailing your use-case. - * - * It may be deprecated and removed in the future. - */ - getApiField(key) { - return this._api[key]; - }, - setClientId(clientId) { - this._clientId = clientId; - }, - getClientId() { - return this._clientId; - }, - /** - * @private - * Please open or upvote an issue at github.com/stripe/stripe-node - * if you use this, detailing your use-case. - * - * It may be deprecated and removed in the future. - */ - getConstant: /* @__PURE__ */ __name((c) => { - switch (c) { - case "DEFAULT_HOST": - return DEFAULT_HOST; - case "DEFAULT_PORT": - return DEFAULT_PORT; - case "DEFAULT_BASE_PATH": - return DEFAULT_BASE_PATH; - case "DEFAULT_API_VERSION": - return DEFAULT_API_VERSION; - case "DEFAULT_TIMEOUT": - return DEFAULT_TIMEOUT; - case "MAX_NETWORK_RETRY_DELAY_SEC": - return MAX_NETWORK_RETRY_DELAY_SEC; - case "INITIAL_NETWORK_RETRY_DELAY_SEC": - return INITIAL_NETWORK_RETRY_DELAY_SEC; - } - return Stripe2[c]; - }, "getConstant"), - getMaxNetworkRetries() { - return this.getApiField("maxNetworkRetries"); - }, - /** - * @private - * This may be removed in the future. - */ - _setApiNumberField(prop, n, defaultVal) { - const val = validateInteger(prop, n, defaultVal); - this._setApiField(prop, val); - }, - getMaxNetworkRetryDelay() { - return MAX_NETWORK_RETRY_DELAY_SEC; - }, - getInitialNetworkRetryDelay() { - return INITIAL_NETWORK_RETRY_DELAY_SEC; - }, - /** - * @private - * Please open or upvote an issue at github.com/stripe/stripe-node - * if you use this, detailing your use-case. - * - * It may be deprecated and removed in the future. - * - * Gets a JSON version of a User-Agent and uses a cached version for a slight - * speed advantage. - */ - getClientUserAgent(cb) { - return this.getClientUserAgentSeeded(Stripe2.USER_AGENT, cb); - }, - /** - * @private - * Please open or upvote an issue at github.com/stripe/stripe-node - * if you use this, detailing your use-case. - * - * It may be deprecated and removed in the future. - * - * Gets a JSON version of a User-Agent by encoding a seeded object and - * fetching a uname from the system. - */ - getClientUserAgentSeeded(seed, cb) { - this._platformFunctions.getUname().then((uname) => { - var _a; - const userAgent = {}; - for (const field in seed) { - if (!Object.prototype.hasOwnProperty.call(seed, field)) { - continue; - } - userAgent[field] = encodeURIComponent((_a = seed[field]) !== null && _a !== void 0 ? _a : "null"); - } - userAgent.uname = encodeURIComponent(uname || "UNKNOWN"); - const client = this.getApiField("httpClient"); - if (client) { - userAgent.httplib = encodeURIComponent(client.getClientName()); - } - if (this._appInfo) { - userAgent.application = this._appInfo; - } - cb(JSON.stringify(userAgent)); - }); - }, - /** - * @private - * Please open or upvote an issue at github.com/stripe/stripe-node - * if you use this, detailing your use-case. - * - * It may be deprecated and removed in the future. - */ - getAppInfoAsString() { - if (!this._appInfo) { - return ""; - } - let formatted = this._appInfo.name; - if (this._appInfo.version) { - formatted += `/${this._appInfo.version}`; - } - if (this._appInfo.url) { - formatted += ` (${this._appInfo.url})`; - } - return formatted; - }, - getTelemetryEnabled() { - return this._enableTelemetry; - }, - /** - * @private - * This may be removed in the future. - */ - _prepResources() { - for (const name in resources_exports) { - if (!Object.prototype.hasOwnProperty.call(resources_exports, name)) { - continue; - } - this[pascalToCamelCase(name)] = new resources_exports[name](this); - } - }, - /** - * @private - * This may be removed in the future. - */ - _getPropsFromConfig(config2) { - if (!config2) { - return {}; - } - const isString = typeof config2 === "string"; - const isObject2 = config2 === Object(config2) && !Array.isArray(config2); - if (!isObject2 && !isString) { - throw new Error("Config must either be an object or a string"); - } - if (isString) { - return { - apiVersion: config2 - }; - } - const values = Object.keys(config2).filter((value) => !ALLOWED_CONFIG_PROPERTIES.includes(value)); - if (values.length > 0) { - throw new Error(`Config object may only contain the following: ${ALLOWED_CONFIG_PROPERTIES.join(", ")}`); - } - return config2; - }, - parseThinEvent(payload, header, secret, tolerance, cryptoProvider, receivedAt) { - return this.webhooks.constructEvent(payload, header, secret, tolerance, cryptoProvider, receivedAt); - } - }; - return Stripe2; -} -__name(createStripe, "createStripe"); - -// node_modules/stripe/esm/stripe.esm.worker.js -var Stripe = createStripe(new WebPlatformFunctions()); -var stripe_esm_worker_default = Stripe; - -// src/services/StripeService.js -var StripeService = class { - static { - __name(this, "StripeService"); - } - constructor(secretKey, siteUrl) { - this.stripe = new stripe_esm_worker_default(secretKey); - this.siteUrl = siteUrl; - } - /** - * Create a Stripe product - */ - async createProduct(productData) { - const stripeImages = Array.isArray(productData.images) ? productData.images : productData.imageUrl ? [productData.imageUrl] : []; - const productParams = { - name: productData.name, - images: stripeImages.slice(0, 8), - type: "good", - tax_code: "txcd_99999999" - // Physical goods tax code - }; - if (productData.description && String(productData.description).trim() !== "") { - productParams.description = String(productData.description); - } - return await this.stripe.products.create(productParams); - } - /** - * Update a Stripe product - */ - async updateProduct(productId, updates) { - const updateParams = { - name: updates.name, - images: updates.images?.slice(0, 8) || [] - }; - if (typeof updates.description === "string") { - const trimmed = updates.description.trim(); - if (trimmed) { - updateParams.description = trimmed; - } - } - return await this.stripe.products.update(productId, updateParams); - } - /** - * Archive a Stripe product - */ - async archiveProduct(productId) { - return await this.stripe.products.update(productId, { active: false }); - } - /** - * Create a Stripe price - */ - async createPrice(params) { - return await this.stripe.prices.create({ - unit_amount: Math.round(params.amount * 100), - currency: params.currency, - product: params.productId, - nickname: params.nickname, - metadata: params.metadata || {} - }); - } - /** - * Archive a Stripe price - */ - async archivePrice(priceId) { - return await this.stripe.prices.update(priceId, { active: false }); - } - /** - * Create checkout session for single item - */ - async createCheckoutSession(priceId) { - return await this.stripe.checkout.sessions.create({ - payment_method_types: ["card"], - line_items: [{ price: priceId, quantity: 1 }], - mode: "payment", - shipping_address_collection: { - allowed_countries: SHIPPING_COUNTRIES - }, - billing_address_collection: "required", - success_url: `${this.siteUrl}/success?session_id={CHECKOUT_SESSION_ID}`, - cancel_url: `${this.siteUrl}/` - }); - } - /** - * Create checkout session for cart - */ - async createCartCheckoutSession(items) { - const lineItems = items.map((item) => { - const lineItem = { - price: item.stripePriceId, - quantity: item.quantity || 1 - }; - return lineItem; - }); - const metadata = { - order_type: "cart_checkout", - item_count: items.length.toString(), - total_quantity: items.reduce((sum, item) => sum + item.quantity, 0).toString() - }; - items.forEach((item, index) => { - const itemName = item.name || `Item ${index + 1}`; - metadata[`item_${index}_name`] = itemName; - if (item.selectedVariant?.name) { - metadata[`item_${index}_variant1`] = item.selectedVariant.name; - } - if (item.selectedVariant2?.name) { - metadata[`item_${index}_variant2`] = item.selectedVariant2.name; - } - }); - return await this.stripe.checkout.sessions.create({ - payment_method_types: ["card"], - line_items: lineItems, - mode: "payment", - shipping_address_collection: { - allowed_countries: SHIPPING_COUNTRIES - }, - billing_address_collection: "required", - success_url: `${this.siteUrl}/success?session_id={CHECKOUT_SESSION_ID}`, - cancel_url: `${this.siteUrl}/`, - metadata - }); - } - /** - * Get checkout session details - */ - async getCheckoutSession(sessionId) { - const session = await this.stripe.checkout.sessions.retrieve(sessionId); - return { - id: session.id, - amount_total: session.amount_total, - currency: session.currency, - customer_email: session.customer_details?.email, - payment_status: session.payment_status, - created: session.created - }; - } - /** - * List checkout sessions with pagination - */ - async listCheckoutSessions(options = {}) { - const params = { - limit: Math.min(options.limit || 25, 50) - }; - if (options.cursor) { - if (options.direction === "prev") { - params.ending_before = options.cursor; - } else { - params.starting_after = options.cursor; - } - } - return await this.stripe.checkout.sessions.list(params); - } - /** - * Get line items for a checkout session - */ - async getCheckoutSessionLineItems(sessionId) { - return await this.stripe.checkout.sessions.listLineItems(sessionId, { - limit: 100, - expand: ["data.price"] - }); - } - /** - * Get payment intent with shipping details - */ - async getPaymentIntent(paymentIntentId) { - return await this.stripe.paymentIntents.retrieve(paymentIntentId, { - expand: ["shipping"] - }); - } - /** - * List payment intents for analytics - */ - async listPaymentIntents(startDate) { - return await this.stripe.paymentIntents.list({ - created: { gte: Math.floor(startDate.getTime() / 1e3) }, - limit: 100 - }); - } -}; - -// src/routes/public/checkout.js -var router4 = new Hono2(); -router4.post("/create-checkout-session", asyncHandler(async (c) => { - const { priceId } = await c.req.json(); - if (!priceId || typeof priceId !== "string") { - throw new ValidationError("Valid price ID is required"); - } - const trimmedPriceId = priceId.trim(); - if (trimmedPriceId.length === 0) { - throw new ValidationError("Valid price ID is required"); - } - if (!trimmedPriceId.startsWith("price_")) { - throw new ValidationError("Invalid price ID format"); - } - if (trimmedPriceId.length > 255) { - throw new ValidationError("Price ID is too long"); - } - const stripeService = new StripeService(c.env.STRIPE_SECRET_KEY, c.env.SITE_URL); - const session = await stripeService.createCheckoutSession(trimmedPriceId); - return c.json({ sessionId: session.id }); -})); -router4.post("/create-cart-checkout-session", asyncHandler(async (c) => { - const { items } = await c.req.json(); - if (!items || !Array.isArray(items) || items.length === 0) { - throw new ValidationError("Cart items are required"); - } - if (items.length > 100) { - throw new ValidationError("Cart size exceeds maximum allowed items"); - } - const normalizedItems = items.map((item, index) => { - if (!item || typeof item !== "object") { - throw new ValidationError(`Invalid cart item format at index ${index}`); - } - const priceId = item.stripePriceId || item.priceId; - if (!priceId || typeof priceId !== "string" || !priceId.startsWith("price_")) { - throw new ValidationError(`Invalid price ID in cart item at index ${index}`); - } - let quantity = item.quantity; - if (quantity === void 0 || quantity === null) { - quantity = 1; - } - quantity = Number.parseInt(quantity, 10); - if (!Number.isInteger(quantity) || quantity < 1 || quantity > 100) { - throw new ValidationError(`Invalid quantity in cart item at index ${index} (must be 1-100, got ${quantity})`); - } - return { - ...item, - stripePriceId: priceId.trim(), - quantity - }; - }); - const stripeService = new StripeService(c.env.STRIPE_SECRET_KEY, c.env.SITE_URL); - const session = await stripeService.createCartCheckoutSession(normalizedItems); - return c.json({ sessionId: session.id }); -})); -router4.get("/checkout-session/:sessionId", asyncHandler(async (c) => { - const sessionId = c.req.param("sessionId"); - if (!sessionId || typeof sessionId !== "string") { - throw new ValidationError("Invalid session ID format"); - } - const trimmedSessionId = sessionId.trim(); - if (!trimmedSessionId.startsWith("cs_")) { - throw new ValidationError("Invalid session ID format"); - } - if (trimmedSessionId.length > 255) { - throw new ValidationError("Session ID is too long"); - } - const stripeService = new StripeService(c.env.STRIPE_SECRET_KEY, c.env.SITE_URL); - const session = await stripeService.getCheckoutSession(trimmedSessionId); - return c.json(session); -})); -var checkout_default = router4; - -// src/routes/public/imageProxy.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var router5 = new Hono2(); -router5.get("/", asyncHandler(async (c) => { - const src = c.req.query("src"); - if (!src) { - throw new ValidationError("Missing src"); - } - let targetUrl; - try { - const u = new URL(src); - const isAllowed = ALLOWED_DRIVE_HOSTS.some((h) => u.hostname === h || u.hostname.endsWith("." + h)); - if (!isAllowed) { - throw new ValidationError("Host not allowed"); - } - if (u.hostname.endsWith("drive.google.com")) { - const pathId = u.pathname.match(/\/file\/d\/([a-zA-Z0-9_-]+)/); - const queryId = u.searchParams.get("id"); - const id = pathId && pathId[1] || queryId; - if (!id) { - throw new ValidationError("Missing Google Drive file id"); - } - targetUrl = `https://drive.usercontent.google.com/download?id=${id}&export=view`; - } else if (u.hostname.endsWith("drive.usercontent.google.com")) { - const id = u.searchParams.get("id"); - if (!id) { - throw new ValidationError("Missing Google Drive file id"); - } - const newUrl = new URL("https://drive.usercontent.google.com/download"); - newUrl.searchParams.set("id", id); - newUrl.searchParams.set("export", "view"); - targetUrl = newUrl.toString(); - } else { - targetUrl = u.toString(); - } - } catch (error3) { - if (error3 instanceof ValidationError) { - throw error3; - } - throw new ValidationError("Invalid src url"); - } - const upstream = await fetch(targetUrl, { - redirect: "follow", - headers: { - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123 Safari/537.36", - "Accept": "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8", - "Accept-Language": "en-US,en;q=0.9", - "Referer": "https://drive.google.com/" - }, - cf: { cacheEverything: true } - }); - if (!upstream.ok) { - throw new Error(`Upstream error: ${upstream.status}`); - } - const headers = new Headers(); - const contentType = upstream.headers.get("content-type") || "image/jpeg"; - headers.set("Content-Type", contentType); - headers.set("Cache-Control", "public, max-age=86400"); - headers.set("Access-Control-Allow-Origin", "*"); - headers.set("Cross-Origin-Resource-Policy", "cross-origin"); - return new Response(upstream.body, { headers }); -})); -var imageProxy_default = router5; - -// src/routes/public/storeSettings.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var router6 = new Hono2(); -router6.get("/", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const settingsService = new StoreSettingsService(kvNamespace); - const settings = await settingsService.getSettings(); - return c.json(settings); -})); -var storeSettings_default = router6; -var contactEmailRouter = new Hono2(); -contactEmailRouter.get("/", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const settingsService = new StoreSettingsService(kvNamespace); - const email = await settingsService.getContactEmail(); - return c.json(email); -})); - -// src/routes/public/images.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/services/R2Service.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var R2Service = class { - static { - __name(this, "R2Service"); - } - constructor(env2) { - this.env = env2; - this.bucket = env2.IMAGES; - } - /** - * Upload file to R2 - * @param {string} mimeType - * @param {string} dataBase64 - * @param {string} filename - */ - async uploadFile(mimeType, dataBase64, filename) { - if (!this.bucket) { - throw new Error("R2 bucket not configured"); - } - const binaryString = atob(dataBase64); - const bytes = new Uint8Array(binaryString.length); - for (let i = 0; i < binaryString.length; i++) { - bytes[i] = binaryString.charCodeAt(i); - } - const safeFilename = filename.replace(/[^a-zA-Z0-9.-]/g, "_"); - const key = `${Date.now()}-${generateSessionToken()}-${safeFilename}`; - await this.bucket.put(key, bytes.buffer, { - httpMetadata: { - contentType: mimeType - } - }); - const viewUrl = `/api/images/${key}`; - return { - id: key, - viewUrl, - downloadUrl: viewUrl, - webViewLink: viewUrl, - folder: { id: "r2", name: "R2 Bucket" } - }; - } - /** - * Get file from R2 - * @param {string} key - */ - async getFile(key) { - if (!this.bucket) { - throw new Error("R2 bucket not configured"); - } - return await this.bucket.get(key); - } -}; - -// src/routes/public/images.js -var router7 = new Hono2(); -router7.get("/:key", async (c) => { - const key = c.req.param("key"); - const r2Service = new R2Service(c.env); - try { - const object = await r2Service.getFile(key); - if (!object) { - return c.notFound(); - } - const headers = new Headers(); - object.writeHttpMetadata(headers); - headers.set("etag", object.httpEtag); - headers.set("Cache-Control", "public, max-age=31536000, immutable"); - return new Response(object.body, { - headers - }); - } catch (e) { - console.error("Error fetching image:", e); - return c.notFound(); - } -}); -var images_default = router7; - -// src/routes/admin/auth.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var router8 = new Hono2(); -router8.post("/login", asyncHandler(async (c) => { - const { password } = await c.req.json(); - if (!password || typeof password !== "string") { - throw new ValidationError("Password is required"); - } - const kvNamespace = getKVNamespace(c.env); - const clientIp = c.req.header("CF-Connecting-IP") || c.req.header("X-Forwarded-For") || "unknown"; - const rateLimitKey = `rate_limit:login:${clientIp}`; - const attempts = await kvNamespace.get(rateLimitKey); - const attemptCount = attempts ? parseInt(attempts, 10) : 0; - if (attemptCount >= 5) { - throw new AuthenticationError("Too many login attempts. Please try again later."); - } - const storedHashKey = `${KV_KEYS.ADMIN_TOKEN_PREFIX}password_hash`; - let storedHash = await kvNamespace.get(storedHashKey); - const adminPassword = c.env.ADMIN_PASSWORD || "admin123"; - if (!storedHash) { - storedHash = await hashPasswordWithSalt(adminPassword); - await kvNamespace.put(storedHashKey, storedHash); - } - const isValid = await verifyPassword(password, storedHash); - if (!isValid) { - await kvNamespace.put(rateLimitKey, (attemptCount + 1).toString(), { - expirationTtl: 900 - // 15 minutes - }); - throw new AuthenticationError("Invalid password"); - } - await kvNamespace.delete(rateLimitKey); - const token = generateSessionToken(); - const hashedToken = await hashToken(token); - await kvNamespace.put(`${KV_KEYS.ADMIN_TOKEN_PREFIX}${hashedToken}`, Date.now().toString(), { - expirationTtl: ADMIN_TOKEN_TTL - // 24 hours - }); - return c.json({ token }); -})); -var auth_default = router8; - -// src/routes/admin/products.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/services/ProductStripeService.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var ProductStripeService = class { - static { - __name(this, "ProductStripeService"); - } - constructor(stripeService) { - this.stripe = stripeService; - } - /** - * Create Stripe product and prices for a product with variants - */ - async createProductWithPrices(productData) { - const stripeProduct = await this.stripe.createProduct({ - name: productData.name, - description: productData.description, - images: Array.isArray(productData.images) ? productData.images : productData.imageUrl ? [productData.imageUrl] : [] - }); - const variants = Array.isArray(productData.variants) ? productData.variants : []; - const variants2 = Array.isArray(productData.variants2) ? productData.variants2 : []; - let basePrice = null; - const variantPrices = {}; - if (variants.length === 0 && variants2.length === 0) { - basePrice = await this.stripe.createPrice({ - amount: productData.price, - currency: productData.currency, - productId: stripeProduct.id, - nickname: `${productData.name} - Base`, - metadata: { - price_type: "base", - product_name: productData.name - } - }); - } else { - const combinations = []; - if (variants.length > 0 && variants2.length > 0) { - for (const v1 of variants) { - for (const v2 of variants2) { - const comboName = `${productData.name} - ${v1.name} - ${v2.name}`; - const comboPrice = v1.hasCustomPrice && v1.price ? v1.price : v2.hasCustomPrice && v2.price ? v2.price : productData.price; - combinations.push({ - name: comboName, - price: comboPrice, - variant1: v1, - variant2: v2, - description: comboName, - variantCombo: `${v1.id || v1.name}-${v2.id || v2.name}` - }); - } - } - } else if (variants.length > 0) { - for (const v of variants) { - const comboName = `${productData.name} - ${v.name}`; - const comboPrice = v.hasCustomPrice && v.price ? v.price : productData.price; - combinations.push({ - name: comboName, - price: comboPrice, - variant1: v, - description: comboName, - variantCombo: `${v.id || v.name}` - }); - } - } else if (variants2.length > 0) { - for (const v of variants2) { - const comboName = `${productData.name} - ${v.name}`; - const comboPrice = v.hasCustomPrice && v.price ? v.price : productData.price; - combinations.push({ - name: comboName, - price: comboPrice, - variant2: v, - description: comboName, - variantCombo: `${v.id || v.name}` - }); - } - } - for (const combo of combinations) { - const stripePrice = await this.stripe.createPrice({ - amount: combo.price, - currency: productData.currency, - productId: stripeProduct.id, - nickname: combo.name, - metadata: { - price_type: "variant_combo", - product_name: productData.name, - variant1_name: combo.variant1?.name || "", - variant2_name: combo.variant2?.name || "", - variant1_id: combo.variant1?.id || "", - variant2_id: combo.variant2?.id || "", - variant1_style: productData.variantStyle || "Variant", - variant2_style: productData.variantStyle2 || "Variant", - variant_combo: combo.variantCombo - } - }); - if (combo.variant1 && combo.variant2) { - variantPrices[`${combo.variant1.id}-${combo.variant2.id}`] = stripePrice.id; - } else if (combo.variant1) { - variantPrices[combo.variant1.id] = stripePrice.id; - } else if (combo.variant2) { - variantPrices[combo.variant2.id] = stripePrice.id; - } - } - basePrice = await this.stripe.createPrice({ - amount: productData.price, - currency: productData.currency, - productId: stripeProduct.id, - nickname: `${productData.name} - Base`, - metadata: { - price_type: "base", - product_name: productData.name - } - }); - } - return { - stripeProduct, - basePrice, - variantPrices - }; - } - /** - * Update product variants and prices - */ - async updateProductVariants(existingProduct, updates, stripeService) { - const baseStripePriceId = updates.stripePriceId || existingProduct.stripePriceId; - const updatedVariants = []; - const updatedVariants2 = []; - if (Array.isArray(updates.variants)) { - const incomingVariants = updates.variants; - const existingVariants = Array.isArray(existingProduct.variants) ? existingProduct.variants : []; - for (const v of incomingVariants) { - const prior = v.id ? existingVariants.find((ev) => ev.id === v.id) : void 0; - const wantsCustom = !!v.hasCustomPrice && typeof v.price === "number" && v.price > 0; - if (wantsCustom) { - const desiredUnitAmount = Math.round(v.price * 100); - let priceIdToUse = prior?.stripePriceId; - const priorWasCustom = !!prior?.hasCustomPrice && typeof prior?.price === "number"; - const priorAmount = priorWasCustom ? Math.round(prior.price * 100) : null; - if (!priceIdToUse || !priorWasCustom || priorAmount !== desiredUnitAmount) { - const newVariantPrice = await stripeService.createPrice({ - amount: v.price, - currency: updates.currency || existingProduct.currency, - productId: existingProduct.stripeProductId, - nickname: `${updates.name || existingProduct.name} - ${v.name}`, - metadata: { - price_type: "variant_primary", - variant_id: v.id || "", - variant_name: v.name || "" - } - }); - if (prior?.stripePriceId && priorWasCustom) { - try { - await stripeService.archivePrice(prior.stripePriceId); - } catch (_) { - } - } - priceIdToUse = newVariantPrice.id; - } - updatedVariants.push({ ...v, stripePriceId: priceIdToUse, hasCustomPrice: true }); - } else { - if (prior?.stripePriceId && prior?.hasCustomPrice) { - try { - await stripeService.archivePrice(prior.stripePriceId); - } catch (_) { - } - } - updatedVariants.push({ ...v, stripePriceId: baseStripePriceId, hasCustomPrice: false, price: void 0 }); - } - } - } - if (Array.isArray(updates.variants2)) { - const incomingVariants = updates.variants2; - const existingVariants = Array.isArray(existingProduct.variants2) ? existingProduct.variants2 : []; - for (const v of incomingVariants) { - const prior = v.id ? existingVariants.find((ev) => ev.id === v.id) : void 0; - const wantsCustom = !!v.hasCustomPrice && typeof v.price === "number" && v.price > 0; - if (wantsCustom) { - const desiredUnitAmount = Math.round(v.price * 100); - let priceIdToUse = prior?.stripePriceId; - const priorWasCustom = !!prior?.hasCustomPrice && typeof prior?.price === "number"; - const priorAmount = priorWasCustom ? Math.round(prior.price * 100) : null; - if (!priceIdToUse || !priorWasCustom || priorAmount !== desiredUnitAmount) { - const newVariantPrice = await stripeService.createPrice({ - amount: v.price, - currency: updates.currency || existingProduct.currency, - productId: existingProduct.stripeProductId, - nickname: `${updates.name || existingProduct.name}${updates.variantStyle2 || existingProduct.variantStyle2 ? ` - ${updates.variantStyle2 || existingProduct.variantStyle2}: ${v.name}` : ` - ${v.name}`}`, - metadata: { - price_type: "variant_secondary", - variant_id: v.id || "", - variant_name: v.name || "", - variant2_name: v.name || "" - } - }); - if (prior?.stripePriceId && priorWasCustom) { - try { - await stripeService.archivePrice(prior.stripePriceId); - } catch (_) { - } - } - priceIdToUse = newVariantPrice.id; - } - updatedVariants2.push({ ...v, stripePriceId: priceIdToUse, hasCustomPrice: true }); - } else { - if (prior?.stripePriceId && prior?.hasCustomPrice) { - try { - await stripeService.archivePrice(prior.stripePriceId); - } catch (_) { - } - } - updatedVariants2.push({ ...v, stripePriceId: baseStripePriceId, hasCustomPrice: false, price: void 0 }); - } - } - } - return { - variants: updatedVariants.length > 0 ? updatedVariants : existingProduct.variants, - variants2: updatedVariants2.length > 0 ? updatedVariants2 : existingProduct.variants2 - }; - } -}; - -// src/routes/admin/products.js -var router9 = new Hono2(); -router9.get("/", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const productService = new ProductService(kvNamespace); - const products = await productService.getAllProductsAdmin(); - return c.json(products); -})); -router9.post("/", asyncHandler(async (c) => { - const productData = await c.req.json(); - const kvNamespace = getKVNamespace(c.env); - const productService = new ProductService(kvNamespace); - const stripeService = new StripeService(c.env.STRIPE_SECRET_KEY, c.env.SITE_URL); - const productStripeService = new ProductStripeService(stripeService); - const { stripeProduct, basePrice, variantPrices } = await productStripeService.createProductWithPrices(productData); - const product = { - ...productData, - stripePriceId: basePrice?.id || Object.values(variantPrices)[0] || "", - stripeProductId: stripeProduct.id, - variantPrices, - variants: Array.isArray(productData.variants) ? productData.variants : [], - variants2: Array.isArray(productData.variants2) ? productData.variants2 : [] - }; - const savedProduct = await productService.createProduct(product); - return c.json(savedProduct, 201); -})); -router9.get("/:id", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const productService = new ProductService(kvNamespace); - const product = await productService.getProduct(c.req.param("id")); - return c.json(product); -})); -router9.put("/:id", asyncHandler(async (c) => { - const updates = await c.req.json(); - const kvNamespace = getKVNamespace(c.env); - const productService = new ProductService(kvNamespace); - const stripeService = new StripeService(c.env.STRIPE_SECRET_KEY, c.env.SITE_URL); - const productStripeService = new ProductStripeService(stripeService); - const existingProduct = await productService.getProduct(c.req.param("id")); - if (updates.name || updates.description !== void 0 || updates.images || updates.imageUrl) { - const stripeImages = Array.isArray(updates.images) ? updates.images : updates.imageUrl ? [updates.imageUrl] : Array.isArray(existingProduct.images) ? existingProduct.images : existingProduct.imageUrl ? [existingProduct.imageUrl] : []; - await stripeService.updateProduct(existingProduct.stripeProductId, { - name: updates.name || existingProduct.name, - description: updates.description, - images: stripeImages.slice(0, 8) - }); - } - if (typeof updates.price !== "undefined" && updates.price !== existingProduct.price) { - const numericPrice = typeof updates.price === "number" ? updates.price : parseFloat(String(updates.price)); - const newPrice = await stripeService.createPrice({ - amount: numericPrice, - currency: updates.currency || existingProduct.currency, - productId: existingProduct.stripeProductId, - nickname: `${updates.name || existingProduct.name} - Base`, - metadata: {} - }); - if (existingProduct.stripePriceId) { - await stripeService.archivePrice(existingProduct.stripePriceId); - } - updates.stripePriceId = newPrice.id; - updates.price = numericPrice; - } - if (Array.isArray(updates.variants) || Array.isArray(updates.variants2)) { - const variantUpdates = await productStripeService.updateProductVariants(existingProduct, updates, stripeService); - updates.variants = variantUpdates.variants; - updates.variants2 = variantUpdates.variants2; - } - const updatedProduct = await productService.updateProduct(c.req.param("id"), updates); - return c.json(updatedProduct); -})); -router9.delete("/:id", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const productService = new ProductService(kvNamespace); - const stripeService = new StripeService(c.env.STRIPE_SECRET_KEY, c.env.SITE_URL); - const existingProduct = await productService.getProduct(c.req.param("id")); - if (existingProduct.stripePriceId) { - await stripeService.archivePrice(existingProduct.stripePriceId); - } - if (existingProduct.stripeProductId) { - await stripeService.archiveProduct(existingProduct.stripeProductId); - } - await productService.deleteProduct(c.req.param("id")); - return c.json({ success: true }); -})); -var products_default2 = router9; - -// src/routes/admin/collections.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var router10 = new Hono2(); -router10.get("/", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const collectionService = new CollectionService(kvNamespace); - const collections = await collectionService.getAllCollectionsAdmin(); - return c.json(collections); -})); -router10.post("/", asyncHandler(async (c) => { - const collectionData = await c.req.json(); - const kvNamespace = getKVNamespace(c.env); - const collectionService = new CollectionService(kvNamespace); - const savedCollection = await collectionService.createCollection(collectionData); - return c.json(savedCollection, 201); -})); -router10.get("/:id", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const collectionService = new CollectionService(kvNamespace); - const collection = await collectionService.getCollection(c.req.param("id")); - return c.json(collection); -})); -router10.put("/:id", asyncHandler(async (c) => { - const updates = await c.req.json(); - const kvNamespace = getKVNamespace(c.env); - const collectionService = new CollectionService(kvNamespace); - const updatedCollection = await collectionService.updateCollection(c.req.param("id"), updates); - return c.json(updatedCollection); -})); -router10.delete("/:id", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const collectionService = new CollectionService(kvNamespace); - await collectionService.deleteCollection(c.req.param("id")); - return c.json({ success: true }); -})); -var collections_default2 = router10; - -// src/routes/admin/analytics.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/services/AnalyticsService.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var AnalyticsService = class { - static { - __name(this, "AnalyticsService"); - } - constructor(stripeService) { - this.stripe = stripeService; - } - /** - * Get analytics data for a period - */ - async getAnalytics(period = "30d") { - const periodDays = { "1d": 1, "7d": 7, "30d": 30, "90d": 90, "1y": 365 }; - const days = periodDays[period] || 30; - const now = /* @__PURE__ */ new Date(); - const startDate = new Date(now.getTime() - days * 24 * 60 * 60 * 1e3); - const paymentIntents = await this.stripe.listPaymentIntents(startDate); - const successfulPayments = paymentIntents.data.filter((pi) => pi.status === "succeeded"); - const totalRevenue = successfulPayments.reduce((sum, payment) => sum + payment.amount, 0) / 100; - const totalOrders = successfulPayments.length; - const averageOrderValue = totalOrders > 0 ? totalRevenue / totalOrders : 0; - const chartData = []; - if (period === "1d") { - const hourlyOrders = {}; - const hourlyRevenue = {}; - successfulPayments.forEach((payment) => { - const d = new Date(payment.created * 1e3); - const bucket = new Date(d); - bucket.setMinutes(0, 0, 0); - const key = bucket.toISOString(); - hourlyOrders[key] = (hourlyOrders[key] || 0) + 1; - hourlyRevenue[key] = (hourlyRevenue[key] || 0) + payment.amount / 100; - }); - const cursor = new Date(now); - cursor.setMinutes(0, 0, 0); - const startHour = new Date(cursor.getTime() - 23 * 60 * 60 * 1e3); - const iter = new Date(startHour); - while (iter <= cursor) { - const key = new Date(iter).toISOString(); - chartData.push({ - date: key, - orders: hourlyOrders[key] || 0, - revenue: Math.round(((hourlyRevenue[key] || 0) + Number.EPSILON) * 100) / 100, - formattedDate: new Date(iter).toLocaleTimeString("en-US", { hour: "numeric" }) - }); - iter.setHours(iter.getHours() + 1); - } - } else { - const dailyData = {}; - const revenueByDate = {}; - successfulPayments.forEach((payment) => { - const date = new Date(payment.created * 1e3).toISOString().split("T")[0]; - dailyData[date] = (dailyData[date] || 0) + 1; - revenueByDate[date] = (revenueByDate[date] || 0) + payment.amount / 100; - }); - const currentDate = new Date(startDate); - while (currentDate <= now) { - const dateStr = currentDate.toISOString().split("T")[0]; - chartData.push({ - date: dateStr, - orders: dailyData[dateStr] || 0, - revenue: revenueByDate[dateStr] || 0, - formattedDate: currentDate.toLocaleDateString("en-US", { month: "short", day: "numeric" }) - }); - currentDate.setDate(currentDate.getDate() + 1); - } - } - return { - period, - totalRevenue: Math.round(totalRevenue * 100) / 100, - totalOrders, - averageOrderValue: Math.round(averageOrderValue * 100) / 100, - chartData, - recentOrders: [], - dateRange: { - start: startDate.toISOString(), - end: now.toISOString() - } - }; - } - /** - * Get orders with fulfillment status - */ - async getOrders(options = {}) { - const limit = Math.min(options.limit || 25, 50); - const direction = options.direction || "next"; - const cursor = options.cursor; - const showFulfilled = options.showFulfilled === true; - const listParams = { limit }; - if (cursor) { - if (direction === "prev") { - listParams.ending_before = cursor; - } else { - listParams.starting_after = cursor; - } - } - const sessions = await this.stripe.listCheckoutSessions(listParams); - let filteredSessions = []; - for (const s of sessions.data) { - if (s.payment_status === "paid" || s.status === "complete" || s.status === "completed") { - let includeSession = true; - if (options.kvNamespace) { - const fulfillmentKey = `order_fulfillment:${s.id}`; - const fulfillmentData = await options.kvNamespace.get(fulfillmentKey); - const fulfillmentStatus = fulfillmentData ? JSON.parse(fulfillmentData) : { fulfilled: false }; - if (showFulfilled) { - if (!fulfillmentStatus.fulfilled) { - includeSession = false; - } - } else { - if (fulfillmentStatus.fulfilled) { - includeSession = false; - } - } - } - if (includeSession) { - filteredSessions.push(s); - } - } - } - const ordered = filteredSessions.reverse(); - const orders = []; - for (const s of ordered) { - try { - const lineItems = await this.stripe.getCheckoutSessionLineItems(s.id); - let shippingDetails = null; - if (s.shipping_details) { - shippingDetails = s.shipping_details; - } else if (s.payment_intent) { - try { - const paymentIntent = await this.stripe.getPaymentIntent(s.payment_intent); - if (paymentIntent.shipping) { - shippingDetails = { - address: paymentIntent.shipping.address, - name: paymentIntent.shipping.name - }; - } - } catch (piError) { - console.log("Error fetching payment intent shipping:", piError.message); - } - } - const fulfillmentKey = `order_fulfillment:${s.id}`; - const fulfillmentData = options.kvNamespace ? await options.kvNamespace.get(fulfillmentKey) : null; - const fulfillmentStatus = fulfillmentData ? JSON.parse(fulfillmentData) : { fulfilled: false, fulfilledAt: null, fulfilledBy: null }; - orders.push({ - id: s.id, - created: s.created, - amount_total: s.amount_total, - currency: s.currency, - customer_email: s.customer_details?.email || s.customer_email || null, - customer_name: s.customer_details?.name || null, - shipping: shippingDetails, - payment_intent: s.payment_intent || null, - billing: { - name: s.customer_details?.name || null, - email: s.customer_details?.email || null, - address: s.customer_details?.address || null - }, - fulfillment: fulfillmentStatus, - items: lineItems.data.map((li) => { - const nickname = li.price?.nickname || ""; - let productName = "Unknown Product"; - let variant1Info = ""; - let variant2Info = ""; - if (nickname.includes(" - ")) { - const parts = nickname.split(" - "); - productName = parts[0]; - if (parts.length >= 2) { - variant1Info = parts[1]; - } - if (parts.length >= 3) { - variant2Info = parts[2]; - } - } else { - productName = nickname; - } - return { - id: li.id, - description: productName, - quantity: li.quantity, - amount_total: li.amount_total, - currency: li.currency, - price_nickname: nickname, - variant1_name: variant1Info || li.price?.metadata?.variant1_name || null, - variant1_style: li.price?.metadata?.variant1_style || "Variant", - variant2_name: variant2Info || li.price?.metadata?.variant2_name || null, - variant2_style: li.price?.metadata?.variant2_style || "Variant" - }; - }) - }); - } catch (e) { - console.error("Error fetching line items for session", s.id, e); - let fulfillmentStatus = { fulfilled: false, fulfilledAt: null, fulfilledBy: null }; - if (options.kvNamespace) { - const fulfillmentKey = `order_fulfillment:${s.id}`; - const fulfillmentData = await options.kvNamespace.get(fulfillmentKey); - fulfillmentStatus = fulfillmentData ? JSON.parse(fulfillmentData) : { fulfilled: false, fulfilledAt: null, fulfilledBy: null }; - } - orders.push({ - id: s.id, - created: s.created, - amount_total: s.amount_total, - currency: s.currency, - customer_email: s.customer_details?.email || s.customer_email || null, - customer_name: s.customer_details?.name || null, - shipping: s.shipping_details || null, - billing: { - name: s.customer_details?.name || null, - email: s.customer_details?.email || null, - address: s.customer_details?.address || null - }, - fulfillment: fulfillmentStatus, - items: [] - }); - } - } - const nextCursor = ordered.length > 0 ? ordered[0].id : null; - const prevCursor = ordered.length > 0 ? ordered[ordered.length - 1].id : null; - return { - limit, - orders, - cursors: { next: nextCursor, prev: prevCursor }, - has_more: sessions.has_more - }; - } -}; - -// src/routes/admin/analytics.js -var router11 = new Hono2(); -router11.get("/", asyncHandler(async (c) => { - const period = c.req.query("period") || "30d"; - const stripeService = new StripeService(c.env.STRIPE_SECRET_KEY, c.env.SITE_URL); - const analyticsService = new AnalyticsService(stripeService); - const analytics = await analyticsService.getAnalytics(period); - return c.json(analytics); -})); -router11.get("/orders", asyncHandler(async (c) => { - const limit = Math.min(parseInt(c.req.query("limit") || "25", 10), 50); - const direction = c.req.query("direction") || "next"; - const cursor = c.req.query("cursor") || void 0; - const showFulfilled = c.req.query("showFulfilled") === "true"; - const stripeService = new StripeService(c.env.STRIPE_SECRET_KEY, c.env.SITE_URL); - const analyticsService = new AnalyticsService(stripeService); - const kvNamespace = getKVNamespace(c.env); - const orders = await analyticsService.getOrders({ - limit, - direction, - cursor, - showFulfilled, - kvNamespace - }); - return c.json(orders); -})); -router11.post("/orders/:orderId/fulfill", asyncHandler(async (c) => { - const orderId = c.req.param("orderId"); - const kvNamespace = getKVNamespace(c.env); - if (!kvNamespace) { - throw new Error("KV namespace not available"); - } - const fulfillmentKey = `order_fulfillment:${orderId}`; - const fulfillmentData = { - fulfilled: true, - fulfilledAt: (/* @__PURE__ */ new Date()).toISOString(), - fulfilledBy: "admin" - }; - await kvNamespace.put(fulfillmentKey, JSON.stringify(fulfillmentData)); - return c.json({ success: true, fulfillment: fulfillmentData }); -})); -var analytics_default = router11; - -// src/routes/admin/media.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/services/MediaService.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var MediaService = class { - static { - __name(this, "MediaService"); - } - constructor(kvNamespace) { - this.kv = new KVManager(kvNamespace); - } - /** - * Generate server ID for media item - */ - generateServerId() { - const rnd = randomHex(4); - const ts = Date.now().toString(36); - return `${ts}-${rnd}`; - } - /** - * Get all media items (sorted by creation date, most recent first) - */ - async getAllMediaItems() { - const items = await this.kv.getAllMediaItems(); - return [...items].sort((a, b) => (b.createdAt || 0) - (a.createdAt || 0)); - } - /** - * Create media item - */ - async createMediaItem(itemData) { - const item = { - id: itemData.id || this.generateServerId(), - url: String(itemData.url || ""), - source: itemData.source || "link", - filename: itemData.filename || "", - mimeType: itemData.mimeType || "", - driveFileId: itemData.driveFileId || "", - createdAt: typeof itemData.createdAt === "number" ? itemData.createdAt : Date.now() - }; - return await this.kv.createMediaItem(item); - } - /** - * Delete media item - */ - async deleteMediaItem(id) { - await this.kv.deleteMediaItem(id); - } -}; - -// src/routes/admin/media.js -var router12 = new Hono2(); -router12.get("/", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const mediaService = new MediaService(kvNamespace); - const items = await mediaService.getAllMediaItems(); - return c.json(items); -})); -router12.post("/", asyncHandler(async (c) => { - const body = await c.req.json(); - const url = body?.url; - if (!url || typeof url !== "string" || url.trim() === "") { - throw new ValidationError("url is required"); - } - const kvNamespace = getKVNamespace(c.env); - const mediaService = new MediaService(kvNamespace); - const saved = await mediaService.createMediaItem(body); - return c.json(saved, 201); -})); -router12.delete("/:id", asyncHandler(async (c) => { - const id = c.req.param("id"); - if (!id) { - throw new ValidationError("Missing id"); - } - const kvNamespace = getKVNamespace(c.env); - const mediaService = new MediaService(kvNamespace); - await mediaService.deleteMediaItem(id); - return c.json({ success: true }); -})); -var media_default = router12; - -// src/routes/admin/storage.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var router13 = new Hono2(); -router13.post("/upload", asyncHandler(async (c) => { - const { mimeType, dataBase64, filename } = await c.req.json(); - if (!mimeType || !dataBase64) { - throw new ValidationError("Missing mimeType or dataBase64"); - } - const r2Service = new R2Service(c.env); - const result = await r2Service.uploadFile(mimeType, dataBase64, filename || "image"); - return c.json(result); -})); -var storage_default = router13; - -// src/routes/admin/settings.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/middleware/validation.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); - -// src/utils/validation.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -function isValidHexColor(color) { - if (typeof color !== "string") return false; - const hexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/; - return hexColorRegex.test(color.trim()); -} -__name(isValidHexColor, "isValidHexColor"); -function isNumberInRange(value, min, max) { - const num = Number(value); - return Number.isFinite(num) && num >= min && num <= max; -} -__name(isNumberInRange, "isNumberInRange"); -function isValidObject(value) { - return value !== null && typeof value === "object" && !Array.isArray(value); -} -__name(isValidObject, "isValidObject"); - -// src/middleware/validation.js -var ALLOWED_FONT_IDS = new Set(FONT_OPTIONS.map((font) => font.id)); -function validateThemePayload(payload) { - if (!isValidObject(payload)) { - return { valid: false, message: "Invalid theme payload" }; - } - const colors = payload.colors; - if (!isValidObject(colors)) { - return { valid: false, message: "Missing colors object" }; - } - for (const key of THEME_COLOR_KEYS) { - const value = typeof colors[key] === "string" ? colors[key].trim() : ""; - if (!isValidHexColor(value)) { - return { valid: false, message: `Invalid ${key} color` }; - } - } - const fontCandidate = payload.typography?.fontId ?? payload.typography?.font ?? payload.fontId ?? payload.font; - if (fontCandidate && !ALLOWED_FONT_IDS.has(fontCandidate)) { - return { valid: false, message: "Invalid font selection" }; - } - if (payload.corners) { - if (payload.corners.radiusMultiplier !== void 0) { - if (!isNumberInRange(payload.corners.radiusMultiplier, THEME_RADIUS_MULTIPLIER_MIN, THEME_RADIUS_MULTIPLIER_MAX)) { - return { valid: false, message: `Radius multiplier must be between ${THEME_RADIUS_MULTIPLIER_MIN} and ${THEME_RADIUS_MULTIPLIER_MAX}` }; - } - } - if (payload.corners.enabled !== void 0 && typeof payload.corners.enabled !== "boolean") { - return { valid: false, message: "Corners enabled must be a boolean" }; - } - } - return { valid: true }; -} -__name(validateThemePayload, "validateThemePayload"); - -// src/routes/admin/settings.js -var router14 = new Hono2(); -router14.get("/storefront/theme", asyncHandler(async (c) => { - const themeService = new ThemeService(c.env); - const theme = await themeService.getTheme(); - return c.json(theme); -})); -router14.put("/storefront/theme", asyncHandler(async (c) => { - const payload = await c.req.json(); - const validation = validateThemePayload(payload); - if (!validation.valid) { - throw new ValidationError(validation.message); - } - const themeService = new ThemeService(c.env); - const theme = await themeService.updateTheme(payload); - return c.json(theme); -})); -router14.delete("/storefront/theme", asyncHandler(async (c) => { - const themeService = new ThemeService(c.env); - const theme = await themeService.resetTheme(); - return c.json(theme); -})); -router14.get("/store-settings", asyncHandler(async (c) => { - const kvNamespace = getKVNamespace(c.env); - const settingsService = new StoreSettingsService(kvNamespace); - const settings = await settingsService.getSettings(); - if ((settings.productLimit === null || settings.productLimit === void 0 || settings.productLimit === "") && c.env.PRODUCT_LIMIT) { - settings.productLimit = c.env.PRODUCT_LIMIT; - } - return c.json(settings); -})); -router14.put("/store-settings", asyncHandler(async (c) => { - const settings = await c.req.json(); - const kvNamespace = getKVNamespace(c.env); - const settingsService = new StoreSettingsService(kvNamespace); - const updatedSettings = await settingsService.updateSettings(settings); - return c.json(updatedSettings); -})); -var settings_default = router14; - -// src/routes/admin/ai.js -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process(); -init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console(); -init_performance2(); -var router15 = new Hono2(); -router15.post("/generate-image", asyncHandler(async (c) => { - const { prompt, inputs } = await c.req.json(); - if (!prompt || typeof prompt !== "string") { - throw new ValidationError("Missing prompt"); - } - const apiKey = c.env.GEMINI_API_KEY; - if (!apiKey) { - throw new Error("GEMINI_API_KEY not configured"); - } - const parts = []; - parts.push({ text: prompt }); - if (Array.isArray(inputs)) { - for (const item of inputs.slice(0, 4)) { - if (item && item.dataBase64 && item.mimeType) { - parts.push({ - inline_data: { - mime_type: item.mimeType, - data: item.dataBase64 - } - }); - } - } - } - const endpoint = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent"; - const res = await fetch(endpoint, { - method: "POST", - headers: { - "x-goog-api-key": apiKey, - "Content-Type": "application/json" - }, - body: JSON.stringify({ - contents: [{ parts }] - }) - }); - if (!res.ok) { - const errText = await res.text(); - console.error("Gemini API error", res.status, errText); - throw new Error(`Gemini API failed: ${errText}`); - } - const data = await res.json(); - const candidates = data?.candidates || []; - let foundBase64 = null; - let mime = "image/png"; - for (const cand of candidates) { - const parts2 = cand?.content?.parts || []; - for (const p of parts2) { - const inlineA = p?.inlineData || p?.inline_data; - if (inlineA && inlineA.data) { - foundBase64 = inlineA.data; - mime = inlineA.mimeType || inlineA.mime_type || mime; - break; - } - } - if (foundBase64) break; - } - if (!foundBase64) { - throw new Error("No image returned from Gemini"); - } - return c.json({ mimeType: mime, dataBase64: foundBase64 }); -})); -var ai_default = router15; - -// src/routes/index.js -function registerRoutes(app2) { - app2.get("/api/health", (c) => { - return c.json({ status: "healthy", timestamp: (/* @__PURE__ */ new Date()).toISOString() }); - }); - app2.route("/api/products", products_default); - app2.route("/api/collections", collections_default); - app2.route("/api/storefront", storefront_default); - app2.route("/api", checkout_default); - app2.route("/api/image-proxy", imageProxy_default); - app2.route("/api/store-settings", storeSettings_default); - app2.route("/api/contact-email", contactEmailRouter); - app2.route("/api/images", images_default); - app2.route("/api/admin", auth_default); - app2.route("/api/admin/products", products_default2); - app2.route("/api/admin/collections", collections_default2); - app2.route("/api/admin/analytics", analytics_default); - app2.route("/api/admin/media", media_default); - app2.route("/api/admin/storage", storage_default); - app2.route("/api/admin", settings_default); - app2.route("/api/admin/ai", ai_default); -} -__name(registerRoutes, "registerRoutes"); - -// src/worker.js -var app = new Hono2(); -app.use("*", async (c, next) => { - await next(); - c.header("X-Content-Type-Options", "nosniff"); - c.header("X-Frame-Options", "DENY"); - c.header("X-XSS-Protection", "1; mode=block"); - c.header("Referrer-Policy", "strict-origin-when-cross-origin"); - c.header("Permissions-Policy", "geolocation=(), microphone=(), camera=()"); - const csp = [ - "default-src 'self'", - "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://js.stripe.com", - "style-src 'self' 'unsafe-inline'", - "img-src 'self' data: https: blob:", - "font-src 'self' data:", - "connect-src 'self' https://api.stripe.com https://*.stripe.com https://oauth2.googleapis.com https://www.googleapis.com", - "frame-src https://js.stripe.com https://hooks.stripe.com", - "frame-ancestors 'none'", - "base-uri 'self'", - "form-action 'self'", - "upgrade-insecure-requests" - ].join("; "); - c.header("Content-Security-Policy", csp); - const url = new URL(c.req.url); - if (url.protocol === "https:") { - c.header("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload"); - } -}); -app.use("*", async (c, next) => { - const corsMiddleware = createCorsMiddleware(c.env); - return await corsMiddleware(c, next); -}); -app.use("/api/admin/*", async (c, next) => { - const unauthenticatedPaths = /* @__PURE__ */ new Set([ - "/api/admin/login", - "/api/admin/drive/oauth/start", - "/api/admin/drive/oauth/callback" - ]); - if (unauthenticatedPaths.has(c.req.path)) { - return next(); - } - try { - const authResult = await verifyAdminAuth(c.req, c.env); - if (!authResult.isValid) { - console.error("Auth failed:", authResult.error); - return c.json({ error: authResult.error, status: authResult.status }, authResult.status); - } - return next(); - } catch (error3) { - console.error("Auth middleware error:", error3); - return c.json({ error: "Authentication middleware failed", status: 500 }, 500); - } -}); -app.use("/api/admin/*", productLimitMiddleware); -registerRoutes(app); -app.onError(errorHandler2); -app.get("*", async (c) => { - const url = new URL(c.req.url); - const pathname = url.pathname; - if (pathname.startsWith("/api/")) { - return c.notFound(); - } - try { - if (pathname !== "/" && !pathname.startsWith("/admin") && !pathname.startsWith("/collections") && !pathname.startsWith("/products") && !pathname.startsWith("/success")) { - const asset = await c.env.ASSETS.fetch(c.req); - if (asset.ok) { - return asset; - } - } - const indexUrl = new URL(c.req.url); - indexUrl.pathname = "/index.html"; - const indexRequest = new Request(indexUrl, c.req); - const indexAsset = await c.env.ASSETS.fetch(indexRequest); - if (indexAsset.ok) { - return indexAsset; - } else { - throw new Error("index.html not found"); - } - } catch (error3) { - console.error("Error serving static asset:", error3, "for path:", pathname); - return c.html(` +var uc=Object.defineProperty;var Pt=(t,e)=>{for(var r in e)uc(t,r,{get:e[r],enumerable:!0})};var Mr=(t,e,r)=>(o,s)=>{let i=-1;return a(0);async function a(l){if(l<=i)throw new Error("next() called multiple times");i=l;let c,u=!1,d;if(t[l]?(d=t[l][0][0],o.req.routeIndex=l):d=l===t.length&&s||void 0,d)try{c=await d(o,()=>a(l+1))}catch(m){if(m instanceof Error&&e)o.error=m,c=await e(m,o),u=!0;else throw m}else o.finalized===!1&&r&&(c=await r(o));return c&&(o.finalized===!1||u)&&(o.res=c),o}};var jo=Symbol();var Uo=async(t,e=Object.create(null))=>{let{all:r=!1,dot:o=!1}=e,i=(t instanceof Tt?t.raw.headers:t.headers).get("Content-Type");return i?.startsWith("multipart/form-data")||i?.startsWith("application/x-www-form-urlencoded")?dc(t,{all:r,dot:o}):{}};async function dc(t,e){let r=await t.formData();return r?mc(r,e):{}}function mc(t,e){let r=Object.create(null);return t.forEach((o,s)=>{e.all||s.endsWith("[]")?hc(r,s,o):r[s]=o}),e.dot&&Object.entries(r).forEach(([o,s])=>{o.includes(".")&&(pc(r,o,s),delete r[o])}),r}var hc=(t,e,r)=>{t[e]!==void 0?Array.isArray(t[e])?t[e].push(r):t[e]=[t[e],r]:e.endsWith("[]")?t[e]=[r]:t[e]=r},pc=(t,e,r)=>{let o=t,s=e.split(".");s.forEach((i,a)=>{a===s.length-1?o[i]=r:((!o[i]||typeof o[i]!="object"||Array.isArray(o[i])||o[i]instanceof File)&&(o[i]=Object.create(null)),o=o[i])})};var Nr=t=>{let e=t.split("/");return e[0]===""&&e.shift(),e},Fo=t=>{let{groups:e,path:r}=fc(t),o=Nr(r);return vc(o,e)},fc=t=>{let e=[];return t=t.replace(/\{[^}]+\}/g,(r,o)=>{let s=`@${o}`;return e.push([s,r]),s}),{groups:e,path:t}},vc=(t,e)=>{for(let r=e.length-1;r>=0;r--){let[o]=e[r];for(let s=t.length-1;s>=0;s--)if(t[s].includes(o)){t[s]=t[s].replace(o,e[r][1]);break}}return t},_t={},$o=(t,e)=>{if(t==="*")return"*";let r=t.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let o=`${t}#${e}`;return _t[o]||(r[2]?_t[o]=e&&e[0]!==":"&&e[0]!=="*"?[o,r[1],new RegExp(`^${r[2]}(?=/${e})`)]:[t,r[1],new RegExp(`^${r[2]}$`)]:_t[o]=[t,r[1],!0]),_t[o]}return null},St=(t,e)=>{try{return e(t)}catch{return t.replace(/(?:%[0-9A-Fa-f]{2})+/g,r=>{try{return e(r)}catch{return r}})}},gc=t=>St(t,decodeURI),Dr=t=>{let e=t.url,r=e.indexOf("/",e.indexOf(":")+4),o=r;for(;o{let e=Dr(t);return e.length>1&&e.at(-1)==="/"?e.slice(0,-1):e},le=(t,e,...r)=>(r.length&&(e=le(e,...r)),`${t?.[0]==="/"?"":"/"}${t}${e==="/"?"":`${t?.at(-1)==="/"?"":"/"}${e?.[0]==="/"?e.slice(1):e}`}`),Et=t=>{if(t.charCodeAt(t.length-1)!==63||!t.includes(":"))return null;let e=t.split("/"),r=[],o="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))o+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){r.length===0&&o===""?r.push("/"):r.push(o);let i=s.replace("?","");o+="/"+i,r.push(o)}else o+="/"+s}),r.filter((s,i,a)=>a.indexOf(s)===i)},kr=t=>/[%+]/.test(t)?(t.indexOf("+")!==-1&&(t=t.replace(/\+/g," ")),t.indexOf("%")!==-1?St(t,Gr):t):t,Ko=(t,e,r)=>{let o;if(!r&&e&&!/[%+]/.test(e)){let a=t.indexOf(`?${e}`,8);for(a===-1&&(a=t.indexOf(`&${e}`,8));a!==-1;){let l=t.charCodeAt(a+e.length+1);if(l===61){let c=a+e.length+2,u=t.indexOf("&",c);return kr(t.slice(c,u===-1?void 0:u))}else if(l==38||isNaN(l))return"";a=t.indexOf(`&${e}`,a+1)}if(o=/[%+]/.test(t),!o)return}let s={};o??=/[%+]/.test(t);let i=t.indexOf("?",8);for(;i!==-1;){let a=t.indexOf("&",i+1),l=t.indexOf("=",i);l>a&&a!==-1&&(l=-1);let c=t.slice(i+1,l===-1?a===-1?void 0:a:l);if(o&&(c=kr(c)),i=a,c==="")continue;let u;l===-1?u="":(u=t.slice(l+1,a===-1?void 0:a),o&&(u=kr(u))),r?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??=u}return e?s[e]:s},Bo=Ko,zo=(t,e)=>Ko(t,e,!0),Gr=decodeURIComponent;var Wo=t=>St(t,Gr),Tt=class{raw;#t;#e;routeIndex=0;path;bodyCache={};constructor(t,e="/",r=[[]]){this.raw=t,this.path=e,this.#e=r,this.#t={}}param(t){return t?this.#r(t):this.#n()}#r(t){let e=this.#e[0][this.routeIndex][1][t],r=this.#s(e);return r?/\%/.test(r)?Wo(r):r:void 0}#n(){let t={},e=Object.keys(this.#e[0][this.routeIndex][1]);for(let r of e){let o=this.#s(this.#e[0][this.routeIndex][1][r]);o&&typeof o=="string"&&(t[r]=/\%/.test(o)?Wo(o):o)}return t}#s(t){return this.#e[1]?this.#e[1][t]:t}query(t){return Bo(this.url,t)}queries(t){return zo(this.url,t)}header(t){if(t)return this.raw.headers.get(t)??void 0;let e={};return this.raw.headers.forEach((r,o)=>{e[o]=r}),e}async parseBody(t){return this.bodyCache.parsedBody??=await Uo(this,t)}#o=t=>{let{bodyCache:e,raw:r}=this,o=e[t];if(o)return o;let s=Object.keys(e)[0];return s?e[s].then(i=>(s==="json"&&(i=JSON.stringify(i)),new Response(i)[t]())):e[t]=r[t]()};json(){return this.#o("text").then(t=>JSON.parse(t))}text(){return this.#o("text")}arrayBuffer(){return this.#o("arrayBuffer")}blob(){return this.#o("blob")}formData(){return this.#o("formData")}addValidatedData(t,e){this.#t[t]=e}valid(t){return this.#t[t]}get url(){return this.raw.url}get method(){return this.raw.method}get[jo](){return this.#e}get matchedRoutes(){return this.#e[0].map(([[,t]])=>t)}get routePath(){return this.#e[0].map(([[,t]])=>t)[this.routeIndex].path}};var Jo={Stringify:1,BeforeStream:2,Stream:3},yc=(t,e)=>{let r=new String(t);return r.isEscaped=!0,r.callbacks=e,r};var Hr=async(t,e,r,o,s)=>{typeof t=="object"&&!(t instanceof String)&&(t instanceof Promise||(t=t.toString()),t instanceof Promise&&(t=await t));let i=t.callbacks;if(!i?.length)return Promise.resolve(t);s?s[0]+=t:s=[t];let a=Promise.all(i.map(l=>l({phase:e,buffer:s,context:o}))).then(l=>Promise.all(l.filter(Boolean).map(c=>Hr(c,e,!1,o,s))).then(()=>s[0]));return r?yc(await a,i):a};var Pc="text/plain; charset=UTF-8",Lr=(t,e)=>({"Content-Type":t,...e}),Yo=class{#t;#e;env={};#r;finalized=!1;error;#n;#s;#o;#u;#c;#l;#a;#d;#m;constructor(t,e){this.#t=t,e&&(this.#s=e.executionCtx,this.env=e.env,this.#l=e.notFoundHandler,this.#m=e.path,this.#d=e.matchResult)}get req(){return this.#e??=new Tt(this.#t,this.#m,this.#d),this.#e}get event(){if(this.#s&&"respondWith"in this.#s)return this.#s;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#s)return this.#s;throw Error("This context has no ExecutionContext")}get res(){return this.#o||=new Response(null,{headers:this.#a??=new Headers})}set res(t){if(this.#o&&t){t=new Response(t.body,t);for(let[e,r]of this.#o.headers.entries())if(e!=="content-type")if(e==="set-cookie"){let o=this.#o.headers.getSetCookie();t.headers.delete("set-cookie");for(let s of o)t.headers.append("set-cookie",s)}else t.headers.set(e,r)}this.#o=t,this.finalized=!0}render=(...t)=>(this.#c??=e=>this.html(e),this.#c(...t));setLayout=t=>this.#u=t;getLayout=()=>this.#u;setRenderer=t=>{this.#c=t};header=(t,e,r)=>{this.finalized&&(this.#o=new Response(this.#o.body,this.#o));let o=this.#o?this.#o.headers:this.#a??=new Headers;e===void 0?o.delete(t):r?.append?o.append(t,e):o.set(t,e)};status=t=>{this.#n=t};set=(t,e)=>{this.#r??=new Map,this.#r.set(t,e)};get=t=>this.#r?this.#r.get(t):void 0;get var(){return this.#r?Object.fromEntries(this.#r):{}}#i(t,e,r){let o=this.#o?new Headers(this.#o.headers):this.#a??new Headers;if(typeof e=="object"&&"headers"in e){let i=e.headers instanceof Headers?e.headers:new Headers(e.headers);for(let[a,l]of i)a.toLowerCase()==="set-cookie"?o.append(a,l):o.set(a,l)}if(r)for(let[i,a]of Object.entries(r))if(typeof a=="string")o.set(i,a);else{o.delete(i);for(let l of a)o.append(i,l)}let s=typeof e=="number"?e:e?.status??this.#n;return new Response(t,{status:s,headers:o})}newResponse=(...t)=>this.#i(...t);body=(t,e,r)=>this.#i(t,e,r);text=(t,e,r)=>!this.#a&&!this.#n&&!e&&!r&&!this.finalized?new Response(t):this.#i(t,e,Lr(Pc,r));json=(t,e,r)=>this.#i(JSON.stringify(t),e,Lr("application/json",r));html=(t,e,r)=>{let o=s=>this.#i(s,e,Lr("text/html; charset=UTF-8",r));return typeof t=="object"?Hr(t,Jo.Stringify,!1,{}).then(o):o(t)};redirect=(t,e)=>{let r=String(t);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,e??302)};notFound=()=>(this.#l??=()=>new Response,this.#l(this))};var A="ALL",Xo="all",Qo=["get","post","put","delete","options","patch"],xt="Can not add a route since the matcher is already built.",wt=class extends Error{};var Zo="__COMPOSED_HANDLER";var Tc=t=>t.text("404 Not Found",404),es=(t,e)=>{if("getResponse"in t){let r=t.getResponse();return e.newResponse(r.body,r)}return console.error(t),e.text("Internal Server Error",500)},qr=class{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#t="/";routes=[];constructor(t={}){[...Qo,Xo].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?this.#t=i:this.#n(s,this.#t,i),a.forEach(l=>{this.#n(s,this.#t,l)}),this)}),this.on=(s,i,...a)=>{for(let l of[i].flat()){this.#t=l;for(let c of[s].flat())a.map(u=>{this.#n(c.toUpperCase(),this.#t,u)})}return this},this.use=(s,...i)=>(typeof s=="string"?this.#t=s:(this.#t="*",i.unshift(s)),i.forEach(a=>{this.#n(A,this.#t,a)}),this);let{strict:r,...o}=t;Object.assign(this,o),this.getPath=r??!0?t.getPath??Dr:Vo}#e(){let t=new qr({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#r=this.#r,t.routes=this.routes,t}#r=Tc;errorHandler=es;route(t,e){let r=this.basePath(t);return e.routes.map(o=>{let s;e.errorHandler===es?s=o.handler:(s=async(i,a)=>(await Mr([],e.errorHandler)(i,()=>o.handler(i,a))).res,s[Zo]=o.handler),r.#n(o.method,o.path,s)}),this}basePath(t){let e=this.#e();return e._basePath=le(this._basePath,t),e}onError=t=>(this.errorHandler=t,this);notFound=t=>(this.#r=t,this);mount(t,e,r){let o,s;r&&(typeof r=="function"?s=r:(s=r.optionHandler,r.replaceRequest===!1?o=l=>l:o=r.replaceRequest));let i=s?l=>{let c=s(l);return Array.isArray(c)?c:[c]}:l=>{let c;try{c=l.executionCtx}catch{}return[l.env,c]};o||=(()=>{let l=le(this._basePath,t),c=l==="/"?0:l.length;return u=>{let d=new URL(u.url);return d.pathname=d.pathname.slice(c)||"/",new Request(d,u)}})();let a=async(l,c)=>{let u=await e(o(l.req.raw),...i(l));if(u)return u;await c()};return this.#n(A,le(t,"*"),a),this}#n(t,e,r){t=t.toUpperCase(),e=le(this._basePath,e);let o={basePath:this._basePath,path:e,method:t,handler:r};this.router.add(t,e,[r,o]),this.routes.push(o)}#s(t,e){if(t instanceof Error)return this.errorHandler(t,e);throw t}#o(t,e,r,o){if(o==="HEAD")return(async()=>new Response(null,await this.#o(t,e,r,"GET")))();let s=this.getPath(t,{env:r}),i=this.router.match(o,s),a=new Yo(t,{path:s,matchResult:i,env:r,executionCtx:e,notFoundHandler:this.#r});if(i[0].length===1){let c;try{c=i[0][0][0][0](a,async()=>{a.res=await this.#r(a)})}catch(u){return this.#s(u,a)}return c instanceof Promise?c.then(u=>u||(a.finalized?a.res:this.#r(a))).catch(u=>this.#s(u,a)):c??this.#r(a)}let l=Mr(i[0],this.errorHandler,this.#r);return(async()=>{try{let c=await l(a);if(!c.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return c.res}catch(c){return this.#s(c,a)}})()}fetch=(t,...e)=>this.#o(t,e[1],e[0],t.method);request=(t,e,r,o)=>t instanceof Request?this.fetch(e?new Request(t,e):t,r,o):(t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${le("/",t)}`,e),r,o));fire=()=>{addEventListener("fetch",t=>{t.respondWith(this.#o(t.request,t,void 0,t.request.method))})}};var Ot="[^/]+",je=".*",Ue="(?:|/.*)",ue=Symbol(),_c=new Set(".\\+*[^]$()");function Sc(t,e){return t.length===1?e.length===1?tm!==je&&m!==Ue))throw ue;if(s)return;c=this.#r[d]=new bt,u!==""&&(c.#e=o.varIndex++)}!s&&u!==""&&r.push([u,c.#e])}else if(c=this.#r[i],!c){if(Object.keys(this.#r).some(u=>u.length>1&&u!==je&&u!==Ue))throw ue;if(s)return;c=this.#r[i]=new bt}c.insert(a,e,r,o,s)}buildRegExpStr(){let e=Object.keys(this.#r).sort(Sc).map(r=>{let o=this.#r[r];return(typeof o.#e=="number"?`(${r})@${o.#e}`:_c.has(r)?`\\${r}`:r)+o.buildRegExpStr()});return typeof this.#t=="number"&&e.unshift(`#${this.#t}`),e.length===0?"":e.length===1?e[0]:"(?:"+e.join("|")+")"}};var ts=class{#t={varIndex:0};#e=new bt;insert(t,e,r){let o=[],s=[];for(let a=0;;){let l=!1;if(t=t.replace(/\{[^}]+\}/g,c=>{let u=`@\\${a}`;return s[a]=[u,c],a++,l=!0,u}),!l)break}let i=t.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=s.length-1;a>=0;a--){let[l]=s[a];for(let c=i.length-1;c>=0;c--)if(i[c].indexOf(l)!==-1){i[c]=i[c].replace(l,s[a][1]);break}}return this.#e.insert(i,e,o,this.#t,r),o}buildRegExp(){let t=this.#e.buildRegExpStr();if(t==="")return[/^$/,[],[]];let e=0,r=[],o=[];return t=t.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,i,a)=>i!==void 0?(r[++e]=Number(i),"$()"):(a!==void 0&&(o[Number(a)]=++e),"")),[new RegExp(`^${t}`),r,o]}};var rs=[],Ec=[/^$/,[],Object.create(null)],os=Object.create(null);function ss(t){return os[t]??=new RegExp(t==="*"?"":`^${t.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,r)=>r?`\\${r}`:"(?:|/.*)")}$`)}function xc(){os=Object.create(null)}function wc(t){let e=new ts,r=[];if(t.length===0)return Ec;let o=t.map(u=>[!/\*|\/:/.test(u[0]),...u]).sort(([u,d],[m,h])=>u?1:m?-1:d.length-h.length),s=Object.create(null);for(let u=0,d=-1,m=o.length;u[g,Object.create(null)]),rs]:d++;let v;try{v=e.insert(p,d,h)}catch(g){throw g===ue?new wt(p):g}h||(r[d]=f.map(([g,y])=>{let O=Object.create(null);for(y-=1;y>=0;y--){let[P,S]=v[y];O[P]=S}return[g,O]}))}let[i,a,l]=e.buildRegExp();for(let u=0,d=r.length;us.length-o.length))if(ss(r).test(e))return[...t[r]]}}var jr=class{name="RegExpRouter";#t;#e;constructor(){this.#t={[A]:Object.create(null)},this.#e={[A]:Object.create(null)}}add(t,e,r){let o=this.#t,s=this.#e;if(!o||!s)throw new Error(xt);o[t]||[o,s].forEach(l=>{l[t]=Object.create(null),Object.keys(l[A]).forEach(c=>{l[t][c]=[...l[A][c]]})}),e==="/*"&&(e="*");let i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){let l=ss(e);t===A?Object.keys(o).forEach(c=>{o[c][e]||=ve(o[c],e)||ve(o[A],e)||[]}):o[t][e]||=ve(o[t],e)||ve(o[A],e)||[],Object.keys(o).forEach(c=>{(t===A||t===c)&&Object.keys(o[c]).forEach(u=>{l.test(u)&&o[c][u].push([r,i])})}),Object.keys(s).forEach(c=>{(t===A||t===c)&&Object.keys(s[c]).forEach(u=>l.test(u)&&s[c][u].push([r,i]))});return}let a=Et(e)||[e];for(let l=0,c=a.length;l{(t===A||t===d)&&(s[d][u]||=[...ve(o[d],u)||ve(o[A],u)||[]],s[d][u].push([r,i-c+l+1]))})}}match(t,e){xc();let r=this.#r();return this.match=(o,s)=>{let i=r[o]||r[A],a=i[2][s];if(a)return a;let l=s.match(i[0]);if(!l)return[[],rs];let c=l.indexOf("",1);return[i[1][c],l]},this.match(t,e)}#r(){let t=Object.create(null);return Object.keys(this.#e).concat(Object.keys(this.#t)).forEach(e=>{t[e]||=this.#n(e)}),this.#t=this.#e=void 0,t}#n(t){let e=[],r=t===A;return[this.#t,this.#e].forEach(o=>{let s=o[t]?Object.keys(o[t]).map(i=>[i,o[t][i]]):[];s.length!==0?(r||=!0,e.push(...s)):t!==A&&e.push(...Object.keys(o[A]).map(i=>[i,o[A][i]]))}),r?wc(e):null}};var Ur=class{name="SmartRouter";#t=[];#e=[];constructor(t){this.#t=t.routers}add(t,e,r){if(!this.#e)throw new Error(xt);this.#e.push([t,e,r])}match(t,e){if(!this.#e)throw new Error("Fatal error");let r=this.#t,o=this.#e,s=r.length,i=0,a;for(;ic.indexOf(a)===l),score:this.#n}}),o}#o(t,e,r,o){let s=[];for(let i=0,a=t.#t.length;i1&&r.sort((l,c)=>l.score-c.score),[r.map(({handler:l,params:c})=>[l,c])]}};var $r=class{name="TrieRouter";#t;constructor(){this.#t=new Fr}add(t,e,r){let o=Et(e);if(o){for(let s=0,i=o.length;s{let r={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...t},o=(i=>typeof i=="string"?i==="*"?()=>i:a=>i===a?a:null:typeof i=="function"?i:a=>i.includes(a)?a:null)(r.origin),s=(i=>typeof i=="function"?i:Array.isArray(i)?()=>i:()=>[])(r.allowMethods);return async function(a,l){function c(d,m){a.res.headers.set(d,m)}let u=await o(a.req.header("origin")||"",a);if(u&&c("Access-Control-Allow-Origin",u),r.origin!=="*"){let d=a.req.header("Vary");d?c("Vary",d):c("Vary","Origin")}if(r.credentials&&c("Access-Control-Allow-Credentials","true"),r.exposeHeaders?.length&&c("Access-Control-Expose-Headers",r.exposeHeaders.join(",")),a.req.method==="OPTIONS"){r.maxAge!=null&&c("Access-Control-Max-Age",r.maxAge.toString());let d=await s(a.req.header("origin")||"",a);d.length&&c("Access-Control-Allow-Methods",d.join(","));let m=r.allowHeaders;if(!m?.length){let h=a.req.header("Access-Control-Request-Headers");h&&(m=h.split(/\s*,\s*/))}return m?.length&&(c("Access-Control-Allow-Headers",m.join(",")),a.res.headers.append("Vary","Access-Control-Request-Headers")),a.res.headers.delete("Content-Length"),a.res.headers.delete("Content-Type"),new Response(null,{headers:a.res.headers,status:204,statusText:"No Content"})}await l()}};function Vr(t){return t.CORS_ORIGINS?t.CORS_ORIGINS.split(",").map(e=>e.trim()):t.SITE_URL?[t.SITE_URL]:["*"]}var Kr=["GET","POST","PUT","DELETE","OPTIONS"],Br=["Content-Type","X-Admin-Token"],Rt=["US","CA","GB","AU","DE","FR","IT","ES","NL","BE","AT","CH","SE","NO","DK","FI","IE","PT","PL","CZ","HU","GR","RO","BG","HR","SI","SK","EE","LV","LT","LU","MT","CY"],zr=["drive.google.com","drive.usercontent.google.com","lh3.googleusercontent.com"],Wr=86400,Jr=864e5,Q={PRODUCTS_LIST:"products:all",COLLECTIONS_LIST:"collections:all",MEDIA_LIST:"media:all",STORE_SETTINGS:"store:settings",DRIVE_TOKEN:"drive:oauth:tokens",DRIVE_FOLDER_PREFIX:"drive:folder",ADMIN_TOKEN_PREFIX:"admin_token:"},Yr=["primary","secondary","accent","text","background","card"],At=0,Ct=4;function is(t={}){let e=Vr(t),r=e.length===1&&e[0]==="*"?"*":o=>{let s=o;return e.includes("*")||e.includes(s)?s:e[0]};return ns({origin:r,allowMethods:Kr,allowHeaders:Br,credentials:!0})}var ee=class extends Error{constructor(e,r=500,o=null){super(e),this.name="APIError",this.statusCode=r,this.details=o}toJSON(){return{error:this.message,status:this.statusCode,...this.details&&{details:this.details}}}},x=class extends ee{constructor(e,r=null){super(e,400,r),this.name="ValidationError"}},It=class extends ee{constructor(e="Authentication required"){super(e,401),this.name="AuthenticationError"}},Mt=class extends ee{constructor(e="Too many requests"){super(e,429),this.name="RateLimitError"}};var V=class extends ee{constructor(e="Resource not found"){super(e,404),this.name="NotFoundError"}};function Xr(t,e){return console.error("Error in request handler:",t),t instanceof ee?e.json(t.toJSON(),t.statusCode):t.name==="ValidationError"||t.status===400?e.json({error:t.message||"Validation error",status:400},400):t.name==="AuthenticationError"||t.status===401?e.json({error:t.message||"Authentication required",status:401},401):t.name==="NotFoundError"||t.status===404?e.json({error:t.message||"Resource not found",status:404},404):e.json({error:t.message||"Internal server error",status:500},500)}function T(t){return async(e,r)=>{try{return await t(e,r)}catch(o){return Xr(o,e)}}}function _(t){if(!t||typeof t!="object")return console.error("getKVNamespace: Invalid environment object"),null;let e=["OPENSHOP-TEST3_KV","OPENSHOP_TEST3_KV","OPENSHOP_KV"];for(let s of e)if(s in t&&t[s]){let i=t[s];if(Qr(i))return console.log(`Found KV namespace via direct access: ${s}`),i}let r=Object.keys(t).find(s=>(s.endsWith("_KV")||s.endsWith("-KV")||s.includes("KV"))&&Qr(t[s]));if(r)return console.log(`Found KV namespace via search: ${r}`),t[r];let o=Object.values(t).find(s=>Qr(s));return o?(console.log("Found KV namespace via fallback"),o):(console.error("No KV namespace found! Available bindings:",Object.keys(t)),console.error("Environment value types:",Object.values(t).map(s=>typeof s)),null)}function Qr(t){return t&&typeof t.get=="function"&&typeof t.put=="function"&&typeof t.delete=="function"&&typeof t.list=="function"}function kt(){let t=typeof globalThis<"u"?globalThis.crypto:null;if(!t)throw new Error("Web Crypto API is not available in this environment");return t}function Nt(t=16){let e=kt();if(typeof e.getRandomValues!="function")throw new Error("crypto.getRandomValues is not available");let r=new Uint8Array(t);return e.getRandomValues(r),Array.from(r,o=>o.toString(16).padStart(2,"0")).join("")}function Dt(){let t=kt();return typeof t.randomUUID=="function"?t.randomUUID().replace(/-/g,""):Nt(32)}async function Gt(t){if(typeof t!="string"||t.length===0)throw new Error("Token must be a non-empty string for hashing");let e=kt();if(!e.subtle||typeof e.subtle.digest!="function")throw new Error("Web Crypto API is not available for hashing tokens");let o=new TextEncoder().encode(t),s=await e.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(s)).map(a=>a.toString(16).padStart(2,"0")).join("")}async function as(t,e,r=1e5){let o=kt();if(!o.subtle)throw new Error("Web Crypto API is not available for password hashing");let i=new TextEncoder().encode(t),a=new Uint8Array(e.match(/.{1,2}/g).map(u=>parseInt(u,16))),l=await o.subtle.importKey("raw",i,{name:"PBKDF2"},!1,["deriveBits"]),c=await o.subtle.deriveBits({name:"PBKDF2",salt:a,iterations:r,hash:"SHA-256"},l,256);return Array.from(new Uint8Array(c)).map(u=>u.toString(16).padStart(2,"0")).join("")}async function cs(t,e){try{let[r,o,s]=e.split(":"),i=parseInt(r,10);return!i||!o||!s?!1:await as(t,o,i)===s}catch{return!1}}function Oc(t=16){return Nt(t)}async function ls(t,e=1e5){let r=Oc(16),o=await as(t,r,e);return`${e}:${r}:${o}`}async function us(t,e){let r;try{t&&typeof t.header=="function"?r=t.header("X-Admin-Token")||t.header("x-admin-token"):t&&t.headers&&typeof t.headers.get=="function"?r=t.headers.get("X-Admin-Token")||t.headers.get("x-admin-token"):t&&t.raw&&t.raw.headers&&typeof t.raw.headers.get=="function"&&(r=t.raw.headers.get("X-Admin-Token")||t.raw.headers.get("x-admin-token"))}catch(o){console.error("Auth middleware - error reading admin token header:",o)}if(!r)return{isValid:!1,error:"Admin authentication required",status:401};try{let o=_(e);if(!o)return console.error("Auth middleware - KV namespace is undefined"),{isValid:!1,error:"KV namespace not available",status:500};let s=await Gt(r),i=`${Q.ADMIN_TOKEN_PREFIX}${s}`,a=await o.get(i);if(!a)return{isValid:!1,error:"Invalid or expired admin token",status:401};let l=parseInt(a);return Date.now()-l>Jr?(await o.delete(i),{isValid:!1,error:"Admin session expired",status:401}):{isValid:!0}}catch(o){return console.error("Admin auth verification error:",o),{isValid:!1,error:"Authentication verification failed",status:500}}}var z=class{constructor(e){this.namespace=e}async createProduct(e){let r=`product:${e.id}`,o={...e,images:Array.isArray(e.images)?e.images:e.imageUrl?[e.imageUrl]:[]};await this.namespace.put(r,JSON.stringify(o));let s=await this.namespace.get("products:all"),i=s?JSON.parse(s):[];return i.push(e.id),await this.namespace.put("products:all",JSON.stringify(i)),o}async getProduct(e){let r=`product:${e}`,o=await this.namespace.get(r);return o?JSON.parse(o):null}async updateProduct(e,r){let o=await this.getProduct(e);if(!o)throw new Error("Product not found");let s={...o,...r,images:Array.isArray(r.images)?r.images:r.imageUrl?[r.imageUrl]:o.images||[]},i=`product:${e}`;return await this.namespace.put(i,JSON.stringify(s)),s}async deleteProduct(e){let r=`product:${e}`;await this.namespace.delete(r);let o=await this.namespace.get("products:all");if(o){let i=JSON.parse(o).filter(a=>a!==e);await this.namespace.put("products:all",JSON.stringify(i))}}async getAllProducts(){let e=await this.namespace.get("products:all");if(!e)return[];let r=JSON.parse(e);return(await Promise.all(r.map(s=>this.getProduct(s)))).filter(Boolean)}async createCollection(e){let r=`collection:${e.id}`;await this.namespace.put(r,JSON.stringify(e));let o=await this.namespace.get("collections:all"),s=o?JSON.parse(o):[];return s.push(e.id),await this.namespace.put("collections:all",JSON.stringify(s)),e}async getCollection(e){let r=`collection:${e}`,o=await this.namespace.get(r);return o?JSON.parse(o):null}async updateCollection(e,r){let o=await this.getCollection(e);if(!o)throw new Error("Collection not found");let s={...o,...r},i=`collection:${e}`;return await this.namespace.put(i,JSON.stringify(s)),s}async deleteCollection(e){let r=`collection:${e}`;await this.namespace.delete(r);let o=await this.namespace.get("collections:all");if(o){let i=JSON.parse(o).filter(a=>a!==e);await this.namespace.put("collections:all",JSON.stringify(i))}}async getAllCollections(){let e=await this.namespace.get("collections:all");if(!e)return[];let r=JSON.parse(e);return(await Promise.all(r.map(s=>this.getCollection(s)))).filter(Boolean)}async getProductsByCollection(e){return(await this.getAllProducts()).filter(o=>o.collectionId===e)}async createMediaItem(e){let r=e.id;if(!r)throw new Error("Media item missing id");let o=`media:${r}`,s={id:r,url:String(e.url||""),source:e.source||"unknown",filename:e.filename||"",mimeType:e.mimeType||"",driveFileId:e.driveFileId||"",createdAt:typeof e.createdAt=="number"?e.createdAt:Date.now(),updatedAt:Date.now()};await this.namespace.put(o,JSON.stringify(s));let i="media:all",a=await this.namespace.get(i),l=a?JSON.parse(a):[];return l.includes(r)||l.push(r),await this.namespace.put(i,JSON.stringify(l)),s}async getMediaItem(e){let r=`media:${e}`,o=await this.namespace.get(r);return o?JSON.parse(o):null}async deleteMediaItem(e){let r=`media:${e}`;await this.namespace.delete(r);let o="media:all",s=await this.namespace.get(o);if(s){let a=JSON.parse(s).filter(l=>l!==e);await this.namespace.put(o,JSON.stringify(a))}}async getAllMediaItems(){let r=await this.namespace.get("media:all");if(!r)return[];let o=JSON.parse(r);return(await Promise.all(o.map(i=>this.getMediaItem(i)))).filter(Boolean)}};var Zr={logoType:"text",logoText:"OpenShop",logoImageUrl:"",storeName:"OpenShop",storeDescription:"Your amazing online store",heroImageUrl:"",heroTitle:"Welcome to OpenShop",heroSubtitle:"Discover amazing products at unbeatable prices. Built on Cloudflare for lightning-fast performance.",contactEmail:"contact@example.com",businessName:"",businessAddressLine1:"",businessAddressLine2:"",businessCity:"",businessState:"",businessPostalCode:"",businessCountry:"",productLimit:null},W=class{constructor(e){this.kv=new z(e)}async getSettings(){let e=await this.kv.namespace.get(Q.STORE_SETTINGS);if(e){let r=JSON.parse(e);return{...Zr,...r}}return Zr}async updateSettings(e){if(!e.logoType||!["text","image"].includes(e.logoType))throw new Error('Invalid logoType. Must be "text" or "image"');let r={...Zr,...e};return await this.kv.namespace.put(Q.STORE_SETTINGS,JSON.stringify(r)),r}async getContactEmail(){return{email:(await this.getSettings()).contactEmail||"contact@example.com"}}};var L=class{constructor(e){this.kv=new z(e)}async getAllProducts(){return(await this.kv.getAllProducts()).filter(r=>!r.archived)}async getAllProductsAdmin(){return await this.kv.getAllProducts()}async getProduct(e){let r=await this.kv.getProduct(e);if(!r)throw new V("Product not found");return r}async createProduct(e){return await this.kv.createProduct(e)}async updateProduct(e,r){if(!await this.kv.getProduct(e))throw new V("Product not found");return await this.kv.updateProduct(e,r)}async deleteProduct(e){if(!await this.kv.getProduct(e))throw new V("Product not found");await this.kv.deleteProduct(e)}async getProductsByCollection(e){return(await this.kv.getProductsByCollection(e)).filter(o=>!o.archived)}};async function ds(t,e){if(t.req.method!=="POST"||t.req.path!=="/api/admin/products")return e();try{let r=_(t.env);if(!r)return console.error("Product limit middleware - KV namespace not available"),e();let i=(await new W(r).getSettings()).productLimit;if((i==null||i==="")&&t.env.PRODUCT_LIMIT&&(i=t.env.PRODUCT_LIMIT),i==null||i==="")return e();let a=parseInt(i,10);if(isNaN(a)||a<=0)return e();let u=(await new L(r).getAllProducts()).length;return u>=a?t.json({error:"Product limit reached",message:`You have reached your product limit of ${a}. Please delete products or upgrade your plan to add more.`,limit:a,current:u},403):e()}catch(r){return console.error("Product limit middleware error:",r),e()}}var eo=new E;eo.get("/",T(async t=>{let e=_(t.env),o=await new L(e).getAllProducts();return t.json(o)}));eo.get("/:id",T(async t=>{let e=_(t.env),o=await new L(e).getProduct(t.req.param("id"));return t.json(o)}));var ms=eo;var F=class{constructor(e){this.kv=new z(e)}async getAllCollections(){return(await this.kv.getAllCollections()).filter(r=>!r.archived)}async getAllCollectionsAdmin(){return await this.kv.getAllCollections()}async getCollection(e){let r=await this.kv.getCollection(e);if(!r)throw new V("Collection not found");return r}async createCollection(e){return await this.kv.createCollection(e)}async updateCollection(e,r){if(!await this.kv.getCollection(e))throw new V("Collection not found");return await this.kv.updateCollection(e,r)}async deleteCollection(e){if(!await this.kv.getCollection(e))throw new V("Collection not found");await this.kv.deleteCollection(e)}async getProductsInCollection(e){let r=await this.kv.getCollection(e);if(!r)throw new V("Collection not found");let o=await this.kv.getProductsByCollection(e);return r.archived?[]:o.filter(s=>!s.archived)}};var Ht=new E;Ht.get("/",T(async t=>{let e=_(t.env),o=await new F(e).getAllCollections();return t.json(o)}));Ht.get("/:id",T(async t=>{let e=_(t.env),o=await new F(e).getCollection(t.req.param("id"));return t.json(o)}));Ht.get("/:id/products",T(async t=>{let e=_(t.env),o=await new F(e).getProductsInCollection(t.req.param("id"));return t.json(o)}));var hs=Ht;var qt="storefront:theme",bc=/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/,oo=[{id:"inter",label:"Inter",stack:"'Inter', 'system-ui', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"},{id:"roboto",label:"Roboto",stack:"'Roboto', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"},{id:"montserrat",label:"Montserrat",stack:"'Montserrat', 'Segoe UI', sans-serif"},{id:"poppins",label:"Poppins",stack:"'Poppins', 'Segoe UI', sans-serif"},{id:"lora",label:"Lora",stack:"'Lora', 'Georgia', serif"}],ro=oo.reduce((t,e)=>(t[e.id]=e,t),{}),M={colors:{primary:"#1e293b",secondary:"#475569",accent:"#3b82f6",text:"#0f172a",background:"#f8fafc",card:"#ffffff"},typography:{fontId:"inter"},corners:{enabled:!0,radiusMultiplier:1}};function Lt(t,e,r){return Math.min(Math.max(t,e),r)}function so(t){if(!t)return null;let r=(t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t).replace("#",""),o=parseInt(r,16);return Number.isNaN(o)?null:{r:o>>16&255,g:o>>8&255,b:o&255}}function gs({r:t,g:e,b:r}){let o=s=>s.toString(16).padStart(2,"0");return`#${o(Lt(Math.round(to(t)),0,255))}${o(Lt(Math.round(to(e)),0,255))}${o(Lt(Math.round(to(r)),0,255))}`}function to(t){return Number.isFinite(t)?t:0}function ye(t,e,r){return t+(e-t)*r}function ps(t,e=.1){let r=so(t);return r?gs({r:ye(r.r,255,e),g:ye(r.g,255,e),b:ye(r.b,255,e)}):t}function fs(t,e=.1){let r=so(t);return r?gs({r:ye(r.r,0,e),g:ye(r.g,0,e),b:ye(r.b,0,e)}):t}function vs(t){let e=so(t);return e&&(.299*e.r+.587*e.g+.114*e.b)/255>.6?"#0f172a":"#ffffff"}function ge(t,e){return typeof t!="string"?e:bc.test(t.trim())?t.trim():e}function Rc(t){return ro[t]?t:M.typography.fontId}function Ac(t){if(typeof t=="string"&&t.trim()!==""){let e=Number(t);Number.isNaN(e)||(t=e)}return(typeof t!="number"||Number.isNaN(t))&&(t=M.corners.radiusMultiplier),Lt(Math.abs(t),0,4)}function jt(t={}){let e=t.colors||{},r=t.typography||t.font,o=t.corners||t.radius,s={primary:ge(e.primary,M.colors.primary),secondary:ge(e.secondary,M.colors.secondary),accent:ge(e.accent,M.colors.accent),text:ge(e.text,M.colors.text),background:ge(e.background,M.colors.background),card:ge(e.card,M.colors.card)},i={fontId:Rc(r?.fontId??r?.font??r?.id)},a={enabled:o?.enabled!==void 0?!!o.enabled:M.corners.enabled,radiusMultiplier:Ac(o?.radiusMultiplier??o?.multiplier??o?.value)};return{colors:s,typography:i,corners:a}}function ys(t){let{colors:e,typography:r,corners:o}=t,{fontId:s}=r,i=ro[s]||ro[M.typography.fontId],a=o.enabled?o.radiusMultiplier*12:0;return{colors:{onPrimary:vs(e.primary),onSecondary:vs(e.secondary),primaryHover:fs(e.primary,.12),secondaryHover:fs(e.secondary,.12),accentSoft:ps(e.accent,.4),background:e.background,surface:"#ffffff",mutedText:ps(e.text,.35)},typography:{fontFamily:i.stack,fontLabel:i.label},corners:{radiusPx:a,radiusSm:o.enabled?Math.max(a*.5,2):0,radiusLg:o.enabled?a*1.5:0}}}function Cc(t){let e=jt(t),r=ys(e);return{"--storefront-color-primary":e.colors.primary,"--storefront-color-primary-hover":r.colors.primaryHover,"--storefront-color-primary-contrast":r.colors.onPrimary,"--storefront-color-secondary":e.colors.secondary,"--storefront-color-secondary-hover":r.colors.secondaryHover,"--storefront-color-secondary-contrast":r.colors.onSecondary,"--storefront-color-accent":e.colors.accent,"--storefront-color-accent-soft":r.colors.accentSoft,"--storefront-color-text":e.colors.text,"--storefront-color-text-muted":r.colors.mutedText,"--storefront-color-background":r.colors.background,"--storefront-color-surface":r.colors.surface,"--storefront-color-card":e.colors.card,"--storefront-font-family":r.typography.fontFamily,"--storefront-radius-base":`${r.corners.radiusPx}px`,"--storefront-radius-sm":`${r.corners.radiusSm}px`,"--storefront-radius-lg":`${r.corners.radiusLg}px`}}function $e(t={}){let e=jt(t.theme??t),r={...M,...e,colors:{...M.colors,...e.colors},typography:{...M.typography,...e.typography},corners:{...M.corners,...e.corners}},{typography:o,corners:s}=ys(r);return{...r,typography:{...r.typography,fontFamily:o.fontFamily,fontLabel:o.fontLabel},corners:{...r.corners,radiusPx:s.radiusPx,radiusSm:s.radiusSm,radiusLg:s.radiusLg},meta:{updatedAt:t.updatedAt??null},cssVariables:Cc(r)}}var te=class{constructor(e){this.env=e,this.kv=_(e)}async getTheme(){try{let e=this.kv?await this.kv.get(qt):null,r=null;if(e)try{r=JSON.parse(e)}catch(o){console.error("Invalid theme JSON in KV, falling back to defaults:",o)}return $e(r||M)}catch(e){return console.error("Error fetching storefront theme:",e),$e(M)}}async updateTheme(e){if(!this.kv)throw new Error("KV namespace unavailable");let o={theme:jt(e),updatedAt:Date.now()};return await this.kv.put(qt,JSON.stringify(o)),$e(o)}async resetTheme(){if(!this.kv)throw new Error("KV namespace unavailable");return await this.kv.delete(qt),$e(M)}};var Ps=new E;Ps.get("/theme",T(async t=>{let r=await new te(t.env).getTheme();return t.json(r)}));var Ts=Ps;var em=globalThis.crypto||{};var _s=t=>({update:()=>{},digest:e=>""});var Ve=class{constructor(){}on(){return this}emit(){return!1}once(){return this}removeListener(){return this}};var re=class{computeHMACSignature(e,r){throw new Error("computeHMACSignature not implemented.")}computeHMACSignatureAsync(e,r){throw new Error("computeHMACSignatureAsync not implemented.")}computeSHA256Async(e){throw new Error("computeSHA256 not implemented.")}},Pe=class extends Error{};var Ut=class extends re{computeHMACSignature(e,r){return(void 0)("sha256",r).update(e,"utf8").digest("hex")}async computeHMACSignatureAsync(e,r){return await this.computeHMACSignature(e,r)}async computeSHA256Async(e){return new Uint8Array(await _s("sha256").update(e).digest())}};var io={};Pt(io,{default:()=>no,get:()=>Mc,request:()=>Ic});var no={},Ic=()=>{},Mc=()=>{};var co={};Pt(co,{default:()=>ao,get:()=>Nc,request:()=>kc});var ao={},kc=()=>{},Nc=()=>{};var D=class t{getClientName(){throw new Error("getClientName not implemented.")}makeRequest(e,r,o,s,i,a,l,c){throw new Error("makeRequest not implemented.")}static makeTimeoutError(){let e=new TypeError(t.TIMEOUT_ERROR_CODE);return e.code=t.TIMEOUT_ERROR_CODE,e}};D.CONNECTION_CLOSED_ERROR_CODES=["ECONNRESET","EPIPE"];D.TIMEOUT_ERROR_CODE="ETIMEDOUT";var oe=class{constructor(e,r){this._statusCode=e,this._headers=r}getStatusCode(){return this._statusCode}getHeaders(){return this._headers}getRawResponse(){throw new Error("getRawResponse not implemented.")}toStream(e){throw new Error("toStream not implemented.")}toJSON(){throw new Error("toJSON not implemented.")}};var Ss=no||io,Es=ao||co,Dc=new Ss.Agent({keepAlive:!0}),Gc=new Es.Agent({keepAlive:!0}),Ke=class extends D{constructor(e){super(),this._agent=e}getClientName(){return"node"}makeRequest(e,r,o,s,i,a,l,c){let u=l==="http",d=this._agent;return d||(d=u?Dc:Gc),new Promise((h,p)=>{let f=(u?Ss:Es).request({host:e,port:r,path:o,method:s,agent:d,headers:i,ciphers:"DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5"});f.setTimeout(c,()=>{f.destroy(D.makeTimeoutError())}),f.on("response",v=>{h(new lo(v))}),f.on("error",v=>{p(v)}),f.once("socket",v=>{v.connecting?v.once(u?"connect":"secureConnect",()=>{f.write(a),f.end()}):(f.write(a),f.end())})})}},lo=class extends oe{constructor(e){super(e.statusCode,e.headers||{}),this._res=e}getRawResponse(){return this._res}toStream(e){return this._res.once("end",()=>e()),this._res}toJSON(){return new Promise((e,r)=>{let o="";this._res.setEncoding("utf8"),this._res.on("data",s=>{o+=s}),this._res.once("end",()=>{try{e(JSON.parse(o))}catch(s){r(s)}})})}};var xs=t=>new URLSearchParams(t).toString();var uo=["apiKey","idempotencyKey","stripeAccount","apiVersion","maxNetworkRetries","timeout","host","authenticator","stripeContext","additionalHeaders","streaming"];function ws(t){return t&&typeof t=="object"&&uo.some(e=>Object.prototype.hasOwnProperty.call(t,e))}function se(t,e){return xs(t,{serializeDate:r=>Math.floor(r.getTime()/1e3).toString(),arrayFormat:e=="v2"?"repeat":"indices"}).replace(/%5B/g,"[").replace(/%5D/g,"]")}var $t=(()=>{let t={"\n":"\\n",'"':'\\"',"\u2028":"\\u2028","\u2029":"\\u2029"};return e=>{let r=e.replace(/["\n\r\u2028\u2029]/g,o=>t[o]);return o=>r.replace(/\{([\s\S]+?)\}/g,(s,i)=>{let a=o[i];return Lc(a)?encodeURIComponent(a):""})}})();function Lc(t){return["number","string","boolean"].includes(typeof t)}function Os(t){let e=t.match(/\{\w+\}/g);return e?e.map(r=>r.replace(/[{}]/g,"")):[]}function Te(t){if(!Array.isArray(t)||!t[0]||typeof t[0]!="object")return{};if(!ws(t[0]))return t.shift();let e=Object.keys(t[0]),r=e.filter(o=>uo.includes(o));return r.length>0&&r.length!==e.length&&ze(`Options found in arguments (${r.join(", ")}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.`),{}}function Vt(t){let e={host:null,headers:{},settings:{},streaming:!1};if(t.length>0){let r=t[t.length-1];if(typeof r=="string")e.authenticator=Ft(t.pop());else if(ws(r)){let o=Object.assign({},t.pop()),s=Object.keys(o).filter(i=>!uo.includes(i));if(s.length&&ze(`Invalid options found (${s.join(", ")}); ignoring.`),o.apiKey&&(e.authenticator=Ft(o.apiKey)),o.idempotencyKey&&(e.headers["Idempotency-Key"]=o.idempotencyKey),o.stripeAccount&&(e.headers["Stripe-Account"]=o.stripeAccount),o.stripeContext){if(e.headers["Stripe-Account"])throw new Error("Can't specify both stripeAccount and stripeContext.");e.headers["Stripe-Context"]=o.stripeContext}if(o.apiVersion&&(e.headers["Stripe-Version"]=o.apiVersion),Number.isInteger(o.maxNetworkRetries)&&(e.settings.maxNetworkRetries=o.maxNetworkRetries),Number.isInteger(o.timeout)&&(e.settings.timeout=o.timeout),o.host&&(e.host=o.host),o.authenticator){if(o.apiKey)throw new Error("Can't specify both apiKey and authenticator.");if(typeof o.authenticator!="function")throw new Error("The authenticator must be a function receiving a request as the first parameter.");e.authenticator=o.authenticator}o.additionalHeaders&&(e.headers=o.additionalHeaders),o.streaming&&(e.streaming=!0)}}return e}function bs(t){let e=this,r=Object.prototype.hasOwnProperty.call(t,"constructor")?t.constructor:function(...o){e.apply(this,o)};return Object.assign(r,e),r.prototype=Object.create(e.prototype),Object.assign(r.prototype,t),r}function Kt(t){if(typeof t!="object")throw new Error("Argument must be an object");return Object.keys(t).reduce((e,r)=>(t[r]!=null&&(e[r]=t[r]),e),{})}function Rs(t){return t&&typeof t=="object"?Object.keys(t).reduce((e,r)=>(e[qc(r)]=t[r],e),{}):t}function qc(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()).join("-")}function Be(t,e){return e?t.then(r=>{setTimeout(()=>{e(null,r)},0)},r=>{setTimeout(()=>{e(r,null)},0)}):t}function As(t){return t==="OAuth"?"oauth":t[0].toLowerCase()+t.substring(1)}function ze(t){return typeof process.emitWarning!="function"?console.warn(`Stripe: ${t}`):process.emitWarning(t,"Stripe")}function jc(t){let e=typeof t;return(e==="function"||e==="object")&&!!t}function Cs(t){let e={},r=(o,s)=>{Object.entries(o).forEach(([i,a])=>{let l=s?`${s}[${i}]`:i;if(jc(a)){if(!(a instanceof Uint8Array)&&!Object.prototype.hasOwnProperty.call(a,"data"))return r(a,l);e[l]=a}else e[l]=String(a)})};return r(t,null),e}function Bt(t,e,r){if(!Number.isInteger(e)){if(r!==void 0)return r;throw new Error(`${t} must be an integer`)}return e}function Is(){return typeof process>"u"?{}:{lang_version:process.version,platform:process.platform}}function Ft(t){let e=r=>(r.headers.Authorization="Bearer "+t,Promise.resolve());return e._apiKey=t,e}function Ms(t){let e=t.reduce((s,i)=>s+i.length,0),r=new Uint8Array(e),o=0;return t.forEach(s=>{r.set(s,o),o+=s.length}),r}function Uc(t,e){return this[t]instanceof Date?Math.floor(this[t].getTime()/1e3).toString():e}function ks(t){return JSON.stringify(t,Uc)}function _e(t){return t&&t.startsWith("/v2")?"v2":"v1"}function zt(t){return Array.isArray(t)?t.join(", "):String(t)}function Ns(t){let e=Array.isArray(t)?t[0]:t;return Number(e)}function Ds(t){return Object.entries(t).map(([e,r])=>[e,zt(r)])}var Wt=class t extends D{constructor(e){if(super(),!e){if(!globalThis.fetch)throw new Error("fetch() function not provided and is not defined in the global scope. You must provide a fetch implementation.");e=globalThis.fetch}globalThis.AbortController?this._fetchFn=t.makeFetchWithAbortTimeout(e):this._fetchFn=t.makeFetchWithRaceTimeout(e)}static makeFetchWithRaceTimeout(e){return(r,o,s)=>{let i,a=new Promise((c,u)=>{i=setTimeout(()=>{i=null,u(D.makeTimeoutError())},s)}),l=e(r,o);return Promise.race([l,a]).finally(()=>{i&&clearTimeout(i)})}}static makeFetchWithAbortTimeout(e){return async(r,o,s)=>{let i=new AbortController,a=setTimeout(()=>{a=null,i.abort(D.makeTimeoutError())},s);try{return await e(r,Object.assign(Object.assign({},o),{signal:i.signal}))}catch(l){throw l.name==="AbortError"?D.makeTimeoutError():l}finally{a&&clearTimeout(a)}}}getClientName(){return"fetch"}async makeRequest(e,r,o,s,i,a,l,c){let u=l==="http",d=new URL(o,`${u?"http":"https"}://${e}`);d.port=r;let m=s=="POST"||s=="PUT"||s=="PATCH",h=a||(m?"":void 0),p=await this._fetchFn(d.toString(),{method:s,headers:Ds(i),body:typeof h=="object"?JSON.stringify(h):h},c);return new mo(p)}},mo=class t extends oe{constructor(e){super(e.status,t._transformHeadersToObject(e.headers)),this._res=e}getRawResponse(){return this._res}toStream(e){return e(),this._res.body}toJSON(){return this._res.json()}static _transformHeadersToObject(e){let r={};for(let o of e){if(!Array.isArray(o)||o.length!=2)throw new Error("Response objects produced by the fetch function given to FetchHttpClient do not have an iterable headers map. Response#headers should be an iterable object.");r[o[0]]=o[1]}return r}};var Jt=class extends re{constructor(e){super(),this.subtleCrypto=e||crypto.subtle}computeHMACSignature(e,r){throw new Pe("SubtleCryptoProvider cannot be used in a synchronous context.")}async computeHMACSignatureAsync(e,r){let o=new TextEncoder,s=await this.subtleCrypto.importKey("raw",o.encode(r),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=await this.subtleCrypto.sign("hmac",s,o.encode(e)),a=new Uint8Array(i),l=new Array(a.length);for(let c=0;c{let r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}secureCompare(e,r){if(e.length!==r.length)return!1;let o=e.length,s=0;for(let i=0;iSe,StripeAuthenticationError:()=>Ee,StripeCardError:()=>Xt,StripeConnectionError:()=>Ye,StripeError:()=>C,StripeIdempotencyError:()=>Qt,StripeInvalidGrantError:()=>Zt,StripeInvalidRequestError:()=>We,StripePermissionError:()=>Je,StripeRateLimitError:()=>xe,StripeSignatureVerificationError:()=>K,StripeUnknownError:()=>er,TemporarySessionExpiredError:()=>tr,generateV1Error:()=>Xe,generateV2Error:()=>po});var Xe=t=>{switch(t.type){case"card_error":return new Xt(t);case"invalid_request_error":return new We(t);case"api_error":return new Se(t);case"authentication_error":return new Ee(t);case"rate_limit_error":return new xe(t);case"idempotency_error":return new Qt(t);case"invalid_grant":return new Zt(t);default:return new er(t)}},po=t=>{switch(t.type){case"temporary_session_expired":return new tr(t)}switch(t.code){case"invalid_fields":return new We(t)}return Xe(t)},C=class extends Error{constructor(e={},r=null){var o;super(e.message),this.type=r||this.constructor.name,this.raw=e,this.rawType=e.type,this.code=e.code,this.doc_url=e.doc_url,this.param=e.param,this.detail=e.detail,this.headers=e.headers,this.requestId=e.requestId,this.statusCode=e.statusCode,this.message=(o=e.message)!==null&&o!==void 0?o:"",this.userMessage=e.user_message,this.charge=e.charge,this.decline_code=e.decline_code,this.payment_intent=e.payment_intent,this.payment_method=e.payment_method,this.payment_method_type=e.payment_method_type,this.setup_intent=e.setup_intent,this.source=e.source}};C.generate=Xe;var Xt=class extends C{constructor(e={}){super(e,"StripeCardError")}},We=class extends C{constructor(e={}){super(e,"StripeInvalidRequestError")}},Se=class extends C{constructor(e={}){super(e,"StripeAPIError")}},Ee=class extends C{constructor(e={}){super(e,"StripeAuthenticationError")}},Je=class extends C{constructor(e={}){super(e,"StripePermissionError")}},xe=class extends C{constructor(e={}){super(e,"StripeRateLimitError")}},Ye=class extends C{constructor(e={}){super(e,"StripeConnectionError")}},K=class extends C{constructor(e,r,o={}){super(o,"StripeSignatureVerificationError"),this.header=e,this.payload=r}},Qt=class extends C{constructor(e={}){super(e,"StripeIdempotencyError")}},Zt=class extends C{constructor(e={}){super(e,"StripeInvalidGrantError")}},er=class extends C{constructor(e={}){super(e,"StripeUnknownError")}},tr=class extends C{constructor(e={}){super(e,"TemporarySessionExpiredError")}};var Gs=()=>Promise.resolve({stdout:"",stderr:""});var fo=class extends C{},or=class extends Yt{constructor(){super(),this._exec=Gs,this._UNAME_CACHE=null}uuid4(){return void 0?(void 0)():super.uuid4()}getUname(){return this._UNAME_CACHE||(this._UNAME_CACHE=new Promise((e,r)=>{try{this._exec("uname -a",(o,s)=>{if(o)return e(null);e(s)})}catch{e(null)}})),this._UNAME_CACHE}secureCompare(e,r){if(!e||!r)throw new Error("secureCompare must receive two arguments");if(e.length!==r.length)return!1;if(void 0){let o=new TextEncoder,s=o.encode(e),i=o.encode(r);return(void 0)(s,i)}return super.secureCompare(e,r)}createEmitter(){return new Ve}tryBufferData(e){if(!(e.file.data instanceof Ve))return Promise.resolve(e);let r=[];return new Promise((o,s)=>{e.file.data.on("data",i=>{r.push(i)}).once("end",()=>{let i=Object.assign({},e);i.file.data=Ms(r),o(i)}).on("error",i=>{s(new fo({message:"An error occurred while attempting to process the file for upload.",detail:i}))})})}createNodeHttpClient(e){return new Ke(e)}createDefaultHttpClient(){return new Ke}createNodeCryptoProvider(){return new Ut}createDefaultCryptoProvider(){return this.createNodeCryptoProvider()}};var Fc=60,sr=class t{constructor(e,r){this._stripe=e,this._maxBufferedRequestMetric=r}_addHeadersDirectlyToObject(e,r){e.requestId=r["request-id"],e.stripeAccount=e.stripeAccount||r["stripe-account"],e.apiVersion=e.apiVersion||r["stripe-version"],e.idempotencyKey=e.idempotencyKey||r["idempotency-key"]}_makeResponseEvent(e,r,o){let s=Date.now(),i=s-e.request_start_time;return Kt({api_version:o["stripe-version"],account:o["stripe-account"],idempotency_key:o["idempotency-key"],method:e.method,path:e.path,status:r,request_id:this._getRequestId(o),elapsed:i,request_start_time:e.request_start_time,request_end_time:s})}_getRequestId(e){return e["request-id"]}_streamingResponseHandler(e,r,o){return s=>{let i=s.getHeaders(),a=()=>{let c=this._makeResponseEvent(e,s.getStatusCode(),i);this._stripe._emitter.emit("response",c),this._recordRequestMetrics(this._getRequestId(i),c.elapsed,r)},l=s.toStream(a);return this._addHeadersDirectlyToObject(l,i),o(null,l)}}_jsonResponseHandler(e,r,o,s){return i=>{let a=i.getHeaders(),l=this._getRequestId(a),c=i.getStatusCode(),u=this._makeResponseEvent(e,c,a);this._stripe._emitter.emit("response",u),i.toJSON().then(d=>{if(d.error){let m;throw typeof d.error=="string"&&(d.error={type:d.error,message:d.error_description}),d.error.headers=a,d.error.statusCode=c,d.error.requestId=l,c===401?m=new Ee(d.error):c===403?m=new Je(d.error):c===429?m=new xe(d.error):r==="v2"?m=po(d.error):m=Xe(d.error),m}return d},d=>{throw new Se({message:"Invalid JSON received from the Stripe API",exception:d,requestId:a["request-id"]})}).then(d=>{this._recordRequestMetrics(l,u.elapsed,o);let m=i.getRawResponse();this._addHeadersDirectlyToObject(m,a),Object.defineProperty(d,"lastResponse",{enumerable:!1,writable:!1,value:m}),s(null,d)},d=>s(d,null))}}static _generateConnectionErrorMessage(e){return`An error occurred with our connection to Stripe.${e>0?` Request was retried ${e} times.`:""}`}static _shouldRetry(e,r,o,s){return s&&r===0&&D.CONNECTION_CLOSED_ERROR_CODES.includes(s.code)?!0:r>=o?!1:e?e.getHeaders()["stripe-should-retry"]==="false"?!1:e.getHeaders()["stripe-should-retry"]==="true"||e.getStatusCode()===409||e.getStatusCode()>=500:!0}_getSleepTimeInMS(e,r=null){let o=this._stripe.getInitialNetworkRetryDelay(),s=this._stripe.getMaxNetworkRetryDelay(),i=Math.min(o*Math.pow(2,e-1),s);return i*=.5*(1+Math.random()),i=Math.max(o,i),Number.isInteger(r)&&r<=Fc&&(i=Math.max(i,r)),i*1e3}_getMaxNetworkRetries(e={}){return e.maxNetworkRetries!==void 0&&Number.isInteger(e.maxNetworkRetries)?e.maxNetworkRetries:this._stripe.getMaxNetworkRetries()}_defaultIdempotencyKey(e,r,o){let s=this._getMaxNetworkRetries(r),i=()=>`stripe-node-retry-${this._stripe._platformFunctions.uuid4()}`;if(o==="v2"){if(e==="POST"||e==="DELETE")return i()}else if(o==="v1"&&e==="POST"&&s>0)return i();return null}_makeHeaders({contentType:e,contentLength:r,apiVersion:o,clientUserAgent:s,method:i,userSuppliedHeaders:a,userSuppliedSettings:l,stripeAccount:c,stripeContext:u,apiMode:d}){let m={Accept:"application/json","Content-Type":e,"User-Agent":this._getUserAgentString(d),"X-Stripe-Client-User-Agent":s,"X-Stripe-Client-Telemetry":this._getTelemetryHeader(),"Stripe-Version":o,"Stripe-Account":c,"Stripe-Context":u,"Idempotency-Key":this._defaultIdempotencyKey(i,l,d)},h=i=="POST"||i=="PUT"||i=="PATCH";return(h||r)&&(h||ze(`${i} method had non-zero contentLength but no payload is expected for this verb`),m["Content-Length"]=r),Object.assign(Kt(m),Rs(a))}_getUserAgentString(e){let r=this._stripe.getConstant("PACKAGE_VERSION"),o=this._stripe._appInfo?this._stripe.getAppInfoAsString():"";return`Stripe/${e} NodeBindings/${r} ${o}`.trim()}_getTelemetryHeader(){if(this._stripe.getTelemetryEnabled()&&this._stripe._prevRequestMetrics.length>0){let e=this._stripe._prevRequestMetrics.shift();return JSON.stringify({last_request_metrics:e})}}_recordRequestMetrics(e,r,o){if(this._stripe.getTelemetryEnabled()&&e)if(this._stripe._prevRequestMetrics.length>this._maxBufferedRequestMetric)ze("Request metrics buffer is full, dropping telemetry message.");else{let s={request_id:e,request_duration_ms:r};o&&o.length>0&&(s.usage=o),this._stripe._prevRequestMetrics.push(s)}}_rawRequest(e,r,o,s){return new Promise((a,l)=>{let c;try{let p=e.toUpperCase();if(p!=="POST"&&o&&Object.keys(o).length!==0)throw new Error("rawRequest only supports params on POST requests. Please pass null and add your parameters to path.");let f=[].slice.call([o,s]),v=Te(f),g=p==="POST"?Object.assign({},v):null,y=Vt(f),O=y.headers,P=y.authenticator;c={requestMethod:p,requestPath:r,bodyData:g,queryData:{},authenticator:P,headers:O,host:y.host,streaming:!!y.streaming,settings:{},usage:["raw_request"]}}catch(p){l(p);return}function u(p,f){p?l(p):a(f)}let{headers:d,settings:m}=c,h=c.authenticator;this._request(c.requestMethod,c.host,r,c.bodyData,h,{headers:d,settings:m,streaming:c.streaming},c.usage,u)})}_request(e,r,o,s,i,a,l=[],c,u=null){var d;let m;i=(d=i??this._stripe._authenticator)!==null&&d!==void 0?d:null;let h=_e(o),p=(g,y,O,P,S)=>setTimeout(g,this._getSleepTimeInMS(P,S),y,O,P+1),f=(g,y,O)=>{let P=a.settings&&a.settings.timeout&&Number.isInteger(a.settings.timeout)&&a.settings.timeout>=0?a.settings.timeout:this._stripe.getApiField("timeout"),S={host:r||this._stripe.getApiField("host"),port:this._stripe.getApiField("port"),path:o,method:e,headers:Object.assign({},y),body:m,protocol:this._stripe.getApiField("protocol")};i(S).then(()=>{let N=this._stripe.getApiField("httpClient").makeRequest(S.host,S.port,S.path,S.method,S.headers,S.body,S.protocol,P),$=Date.now(),R=Kt({api_version:g,account:zt(y["Stripe-Account"]),idempotency_key:zt(y["Idempotency-Key"]),method:e,path:o,request_start_time:$}),G=O||0,H=this._getMaxNetworkRetries(a.settings||{});this._stripe._emitter.emit("request",R),N.then(U=>t._shouldRetry(U,G,H)?p(f,g,y,G,Ns(U.getHeaders()["retry-after"])):a.streaming&&U.getStatusCode()<400?this._streamingResponseHandler(R,l,c)(U):this._jsonResponseHandler(R,h,l,c)(U)).catch(U=>{if(t._shouldRetry(null,G,H,U))return p(f,g,y,G,null);{let qo=U.code&&U.code===D.TIMEOUT_ERROR_CODE;return c(new Ye({message:qo?`Request aborted due to timeout being reached (${P}ms)`:t._generateConnectionErrorMessage(G),detail:U}))}})}).catch(N=>{throw new C({message:"Unable to authenticate the request",exception:N})})},v=(g,y)=>{if(g)return c(g);m=y,this._stripe.getClientUserAgent(O=>{let P=this._stripe.getApiField("version"),S=this._makeHeaders({contentType:h=="v2"?"application/json":"application/x-www-form-urlencoded",contentLength:m.length,apiVersion:P,clientUserAgent:O,method:e,userSuppliedHeaders:a.headers,userSuppliedSettings:a.settings,stripeAccount:h=="v2"?null:this._stripe.getApiField("stripeAccount"),stripeContext:h=="v2"?this._stripe.getApiField("stripeContext"):null,apiMode:h});f(P,S,0)})};if(u)u(e,s,a.headers,v);else{let g;h=="v2"?g=s?ks(s):"":g=se(s||{},h),v(null,g)}}};var nr=class{constructor(e,r,o,s){this.index=0,this.pagePromise=e,this.promiseCache={currentPromise:null},this.requestArgs=r,this.spec=o,this.stripeResource=s}async iterate(e){if(!(e&&e.data&&typeof e.data.length=="number"))throw Error("Unexpected: Stripe API response does not have a well-formed `data` array.");let r=Ls(this.requestArgs);if(this.index{let r=await this._next();return this.promiseCache.currentPromise=null,r})();return this.promiseCache.currentPromise=e,e}},go=class extends nr{getNextPage(e){let r=Ls(this.requestArgs),o=Bc(e,r);return this.stripeResource._makeRequest(this.requestArgs,this.spec,{[r?"ending_before":"starting_after"]:o})}},yo=class extends nr{getNextPage(e){if(!e.next_page)throw Error("Unexpected: Stripe API response does not have a well-formed `next_page` field, but `has_more` was true.");return this.stripeResource._makeRequest(this.requestArgs,this.spec,{page:e.next_page})}},Po=class{constructor(e,r,o,s){this.currentPageIterator=(async()=>(await e).data[Symbol.iterator]())(),this.nextPageUrl=(async()=>(await e).next_page_url||null)(),this.requestArgs=r,this.spec=o,this.stripeResource=s}async turnPage(){let e=await this.nextPageUrl;if(!e)return null;this.spec.fullPath=e;let r=await this.stripeResource._makeRequest([],this.spec,{});return this.nextPageUrl=Promise.resolve(r.next_page_url),this.currentPageIterator=Promise.resolve(r.data[Symbol.iterator]()),this.currentPageIterator}async next(){{let o=(await this.currentPageIterator).next();if(!o.done)return{done:!1,value:o.value}}let e=await this.turnPage();if(!e)return{done:!0,value:void 0};let r=e.next();return r.done?{done:!0,value:void 0}:{done:!1,value:r.value}}},Hs=(t,e,r,o)=>{let s=_e(r.fullPath||r.path);return s!=="v2"&&r.methodType==="search"?vo(new yo(o,e,r,t)):s!=="v2"&&r.methodType==="list"?vo(new go(o,e,r,t)):s==="v2"&&r.methodType==="list"?vo(new Po(o,e,r,t)):null},vo=t=>{let e=zc((...s)=>t.next(...s)),r=Wc(e),o={autoPagingEach:e,autoPagingToArray:r,next:()=>t.next(),return:()=>({}),[$c()]:()=>o};return o};function $c(){return typeof Symbol<"u"&&Symbol.asyncIterator?Symbol.asyncIterator:"@@asyncIterator"}function Vc(t){if(t.length<2)return null;let e=t[1];if(typeof e!="function")throw Error(`The second argument to autoPagingEach, if present, must be a callback function; received ${typeof e}`);return e}function Kc(t){if(t.length===0)return;let e=t[0];if(typeof e!="function")throw Error(`The first argument to autoPagingEach, if present, must be a callback function; received ${typeof e}`);if(e.length===2)return e;if(e.length>2)throw Error(`The \`onItem\` callback function passed to autoPagingEach must accept at most two arguments; got ${e}`);return function(o,s){let i=e(o);s(i)}}function Bc(t,e){let r=e?0:t.data.length-1,o=t.data[r],s=o&&o.id;if(!s)throw Error("Unexpected: No `id` found on the last item while auto-paging a list.");return s}function zc(t){return function(){let r=[].slice.call(arguments),o=Kc(r),s=Vc(r);if(r.length>2)throw Error(`autoPagingEach takes up to two arguments; received ${r}`);let i=Jc(t,o);return Be(i,s)}}function Wc(t){return function(r,o){let s=r&&r.limit;if(!s)throw Error("You must pass a `limit` option to autoPagingToArray, e.g., `autoPagingToArray({limit: 1000});`.");if(s>1e4)throw Error("You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.");let i=new Promise((a,l)=>{let c=[];t(u=>{if(c.push(u),c.length>=s)return!1}).then(()=>{a(c)}).catch(l)});return Be(i,o)}}function Jc(t,e){return new Promise((r,o)=>{function s(i){if(i.done){r();return}let a=i.value;return new Promise(l=>{e(a,l)}).then(l=>l===!1?s({done:!0,value:void 0}):t().then(s))}t().then(s).catch(o)})}function Ls(t){let e=[].slice.call(t);return!!Te(e).ending_before}function qs(t){if(t.path!==void 0&&t.fullPath!==void 0)throw new Error(`Method spec specified both a 'path' (${t.path}) and a 'fullPath' (${t.fullPath}).`);return function(...e){let r=typeof e[e.length-1]=="function"&&e.pop();t.urlParams=Os(t.fullPath||this.createResourcePathWithSymbols(t.path||""));let o=Be(this._makeRequest(e,t,{}),r);return Object.assign(o,Hs(this,e,t,o)),o}}n.extend=bs;n.method=qs;n.MAX_BUFFERED_REQUEST_METRICS=100;function n(t,e){if(this._stripe=t,e)throw new Error("Support for curried url params was dropped in stripe-node v7.0.0. Instead, pass two ids.");this.basePath=$t(this.basePath||t.getApiField("basePath")),this.resourcePath=this.path,this.path=$t(this.path),this.initialize(...arguments)}n.prototype={_stripe:null,path:"",resourcePath:"",basePath:null,initialize(){},requestDataProcessor:null,validateRequest:null,createFullPath(t,e){let r=[this.basePath(e),this.path(e)];if(typeof t=="function"){let o=t(e);o&&r.push(o)}else r.push(t);return this._joinUrlParts(r)},createResourcePathWithSymbols(t){return t?`/${this._joinUrlParts([this.resourcePath,t])}`:`/${this.resourcePath}`},_joinUrlParts(t){return t.join("/").replace(/\/{2,}/g,"/")},_getRequestOpts(t,e,r){var o;let s=(e.method||"GET").toUpperCase(),i=e.usage||[],a=e.urlParams||[],l=e.encode||(R=>R),c=!!e.fullPath,u=$t(c?e.fullPath:e.path||""),d=c?e.fullPath:this.createResourcePathWithSymbols(e.path),m=[].slice.call(t),h=a.reduce((R,G)=>{let H=m.shift();if(typeof H!="string")throw new Error(`Stripe: Argument "${G}" must be a string, but got: ${H} (on API request to \`${s} ${d}\`)`);return R[G]=H,R},{}),p=Te(m),f=l(Object.assign({},p,r)),v=Vt(m),g=v.host||e.host,y=!!e.streaming||!!v.streaming;if(m.filter(R=>R!=null).length)throw new Error(`Stripe: Unknown arguments (${m}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to ${s} \`${d}\`)`);let O=c?u(h):this.createFullPath(u,h),P=Object.assign(v.headers,e.headers);e.validator&&e.validator(f,{headers:P});let S=e.method==="GET"||e.method==="DELETE";return{requestMethod:s,requestPath:O,bodyData:S?null:f,queryData:S?f:{},authenticator:(o=v.authenticator)!==null&&o!==void 0?o:null,headers:P,host:g??null,streaming:y,settings:v.settings,usage:i}},_makeRequest(t,e,r){return new Promise((o,s)=>{var i;let a;try{a=this._getRequestOpts(t,e,r)}catch(h){s(h);return}function l(h,p){h?s(h):o(e.transformResponseData?e.transformResponseData(p):p)}let c=Object.keys(a.queryData).length===0,u=[a.requestPath,c?"":"?",se(a.queryData,_e(a.requestPath))].join(""),{headers:d,settings:m}=a;this._stripe._requestSender._request(a.requestMethod,a.host,u,a.bodyData,a.authenticator,{headers:d,settings:m,streaming:a.streaming},a.usage,l,(i=this.requestDataProcessor)===null||i===void 0?void 0:i.bind(this))})}};function js(t){let e={DEFAULT_TOLERANCE:300,signature:null,constructEvent(d,m,h,p,f,v){try{if(!this.signature)throw new Error("ERR: missing signature helper, unable to verify");this.signature.verifyHeader(d,m,h,p||e.DEFAULT_TOLERANCE,f,v)}catch(y){throw y instanceof Pe&&(y.message+="\nUse `await constructEventAsync(...)` instead of `constructEvent(...)`"),y}return d instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(d)):JSON.parse(d)},async constructEventAsync(d,m,h,p,f,v){if(!this.signature)throw new Error("ERR: missing signature helper, unable to verify");return await this.signature.verifyHeaderAsync(d,m,h,p||e.DEFAULT_TOLERANCE,f,v),d instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(d)):JSON.parse(d)},generateTestHeaderString:function(d){let m=u(d),h=m.signature||m.cryptoProvider.computeHMACSignature(m.payloadString,m.secret);return m.generateHeaderString(h)},generateTestHeaderStringAsync:async function(d){let m=u(d),h=m.signature||await m.cryptoProvider.computeHMACSignatureAsync(m.payloadString,m.secret);return m.generateHeaderString(h)}},r={EXPECTED_SCHEME:"v1",verifyHeader(d,m,h,p,f,v){let{decodedHeader:g,decodedPayload:y,details:O,suspectPayloadType:P}=s(d,m,this.EXPECTED_SCHEME),S=/\s/.test(h);f=f||c();let N=f.computeHMACSignature(o(y,O),h);return i(y,g,O,N,p,P,S,v),!0},async verifyHeaderAsync(d,m,h,p,f,v){let{decodedHeader:g,decodedPayload:y,details:O,suspectPayloadType:P}=s(d,m,this.EXPECTED_SCHEME),S=/\s/.test(h);f=f||c();let N=await f.computeHMACSignatureAsync(o(y,O),h);return i(y,g,O,N,p,P,S,v)}};function o(d,m){return`${m.timestamp}.${d}`}function s(d,m,h){if(!d)throw new K(m,d,{message:"No webhook payload was provided."});let p=typeof d!="string"&&!(d instanceof Uint8Array),f=new TextDecoder("utf8"),v=d instanceof Uint8Array?f.decode(d):d;if(Array.isArray(m))throw new Error("Unexpected: An array was passed as a header, which should not be possible for the stripe-signature header.");if(m==null||m=="")throw new K(m,d,{message:"No stripe-signature header value was provided."});let g=m instanceof Uint8Array?f.decode(m):m,y=a(g,h);if(!y||y.timestamp===-1)throw new K(g,v,{message:"Unable to extract timestamp and signatures from header"});if(!y.signatures.length)throw new K(g,v,{message:"No signatures found with expected scheme"});return{decodedPayload:v,decodedHeader:g,details:y,suspectPayloadType:p}}function i(d,m,h,p,f,v,g,y){let O=!!h.signatures.filter(t.secureCompare.bind(t,p)).length,P=` +Learn more about webhook signing and explore webhook integration examples for various frameworks at https://docs.stripe.com/webhooks/signature`,S=g?` + +Note: The provided signing secret contains whitespace. This often indicates an extra newline or space is in the value`:"";if(!O)throw v?new K(m,d,{message:`Webhook payload must be provided as a string or a Buffer (https://nodejs.org/api/buffer.html) instance representing the _raw_ request body.Payload was provided as a parsed JavaScript object instead. +Signature verification is impossible without access to the original signed material. +`+P+` +`+S}):new K(m,d,{message:`No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? + If a webhook request is being forwarded by a third-party tool, ensure that the exact request body, including JSON formatting and new line style, is preserved. +`+P+` +`+S});let N=Math.floor((typeof y=="number"?y:Date.now())/1e3)-h.timestamp;if(f>0&&N>f)throw new K(m,d,{message:"Timestamp outside the tolerance zone"});return!0}function a(d,m){return typeof d!="string"?null:d.split(",").reduce((h,p)=>{let f=p.split("=");return f[0]==="t"&&(h.timestamp=parseInt(f[1],10)),f[0]===m&&h.signatures.push(f[1]),h},{timestamp:-1,signatures:[]})}let l=null;function c(){return l||(l=t.createDefaultCryptoProvider()),l}function u(d){if(!d)throw new C({message:"Options are required"});let m=Math.floor(d.timestamp)||Math.floor(Date.now()/1e3),h=d.scheme||r.EXPECTED_SCHEME,p=d.cryptoProvider||c(),f=`${m}.${d.payload}`,v=g=>`t=${m},${h}=${g}`;return Object.assign(Object.assign({},d),{timestamp:m,scheme:h,cryptoProvider:p,payloadString:f,generateHeaderString:v})}return e.signature=r,e}var To="2025-08-27.basil";var Ne={};Pt(Ne,{Account:()=>ko,AccountLinks:()=>xi,AccountSessions:()=>wi,Accounts:()=>ko,ApplePayDomains:()=>Oi,ApplicationFees:()=>bi,Apps:()=>Pl,Balance:()=>Ri,BalanceTransactions:()=>Ci,Billing:()=>Tl,BillingPortal:()=>_l,Charges:()=>Ii,Checkout:()=>Sl,Climate:()=>El,ConfirmationTokens:()=>Mi,CountrySpecs:()=>Ni,Coupons:()=>Di,CreditNotes:()=>Gi,CustomerSessions:()=>Hi,Customers:()=>Li,Disputes:()=>qi,Entitlements:()=>xl,EphemeralKeys:()=>Ui,Events:()=>$i,ExchangeRates:()=>Ki,FileLinks:()=>Bi,Files:()=>Wi,FinancialConnections:()=>wl,Forwarding:()=>Ol,Identity:()=>bl,InvoiceItems:()=>Ji,InvoicePayments:()=>Xi,InvoiceRenderingTemplates:()=>Qi,Invoices:()=>Zi,Issuing:()=>Rl,Mandates:()=>ea,OAuth:()=>ra,PaymentIntents:()=>oa,PaymentLinks:()=>sa,PaymentMethodConfigurations:()=>na,PaymentMethodDomains:()=>ia,PaymentMethods:()=>aa,Payouts:()=>ca,Plans:()=>la,Prices:()=>ua,Products:()=>da,PromotionCodes:()=>ma,Quotes:()=>ha,Radar:()=>Al,Refunds:()=>pa,Reporting:()=>Cl,Reviews:()=>fa,SetupAttempts:()=>va,SetupIntents:()=>ga,ShippingRates:()=>ya,Sigma:()=>Il,Sources:()=>Pa,SubscriptionItems:()=>Ta,SubscriptionSchedules:()=>_a,Subscriptions:()=>Sa,Tax:()=>Ml,TaxCodes:()=>xa,TaxIds:()=>wa,TaxRates:()=>Oa,Terminal:()=>kl,TestHelpers:()=>Nl,Tokens:()=>Ra,Topups:()=>Aa,Transfers:()=>Ca,Treasury:()=>Dl,V2:()=>Gl,WebhookEndpoints:()=>Ia});function Yc(t,e){for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let o=r[0].toLowerCase()+r.substring(1),s=new e[r](t);this[o]=s}}function b(t,e){return function(r){return new Yc(r,e)}}var de=n.method,Us=n.extend({retrieve:de({method:"GET",fullPath:"/v1/financial_connections/accounts/{account}"}),list:de({method:"GET",fullPath:"/v1/financial_connections/accounts",methodType:"list"}),disconnect:de({method:"POST",fullPath:"/v1/financial_connections/accounts/{account}/disconnect"}),listOwners:de({method:"GET",fullPath:"/v1/financial_connections/accounts/{account}/owners",methodType:"list"}),refresh:de({method:"POST",fullPath:"/v1/financial_connections/accounts/{account}/refresh"}),subscribe:de({method:"POST",fullPath:"/v1/financial_connections/accounts/{account}/subscribe"}),unsubscribe:de({method:"POST",fullPath:"/v1/financial_connections/accounts/{account}/unsubscribe"})});var Fs=n.method,$s=n.extend({retrieve:Fs({method:"GET",fullPath:"/v1/entitlements/active_entitlements/{id}"}),list:Fs({method:"GET",fullPath:"/v1/entitlements/active_entitlements",methodType:"list"})});var we=n.method,Vs=n.extend({create:we({method:"POST",fullPath:"/v1/billing/alerts"}),retrieve:we({method:"GET",fullPath:"/v1/billing/alerts/{id}"}),list:we({method:"GET",fullPath:"/v1/billing/alerts",methodType:"list"}),activate:we({method:"POST",fullPath:"/v1/billing/alerts/{id}/activate"}),archive:we({method:"POST",fullPath:"/v1/billing/alerts/{id}/archive"}),deactivate:we({method:"POST",fullPath:"/v1/billing/alerts/{id}/deactivate"})});var Qe=n.method,Ks=n.extend({retrieve:Qe({method:"GET",fullPath:"/v1/issuing/authorizations/{authorization}"}),update:Qe({method:"POST",fullPath:"/v1/issuing/authorizations/{authorization}"}),list:Qe({method:"GET",fullPath:"/v1/issuing/authorizations",methodType:"list"}),approve:Qe({method:"POST",fullPath:"/v1/issuing/authorizations/{authorization}/approve"}),decline:Qe({method:"POST",fullPath:"/v1/issuing/authorizations/{authorization}/decline"})});var me=n.method,Bs=n.extend({create:me({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations"}),capture:me({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations/{authorization}/capture"}),expire:me({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations/{authorization}/expire"}),finalizeAmount:me({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations/{authorization}/finalize_amount"}),increment:me({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations/{authorization}/increment"}),respond:me({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations/{authorization}/fraud_challenges/respond"}),reverse:me({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations/{authorization}/reverse"})});var _o=n.method,zs=n.extend({create:_o({method:"POST",fullPath:"/v1/tax/calculations"}),retrieve:_o({method:"GET",fullPath:"/v1/tax/calculations/{calculation}"}),listLineItems:_o({method:"GET",fullPath:"/v1/tax/calculations/{calculation}/line_items",methodType:"list"})});var ir=n.method,Ws=n.extend({create:ir({method:"POST",fullPath:"/v1/issuing/cardholders"}),retrieve:ir({method:"GET",fullPath:"/v1/issuing/cardholders/{cardholder}"}),update:ir({method:"POST",fullPath:"/v1/issuing/cardholders/{cardholder}"}),list:ir({method:"GET",fullPath:"/v1/issuing/cardholders",methodType:"list"})});var ar=n.method,Js=n.extend({create:ar({method:"POST",fullPath:"/v1/issuing/cards"}),retrieve:ar({method:"GET",fullPath:"/v1/issuing/cards/{card}"}),update:ar({method:"POST",fullPath:"/v1/issuing/cards/{card}"}),list:ar({method:"GET",fullPath:"/v1/issuing/cards",methodType:"list"})});var Ze=n.method,Ys=n.extend({deliverCard:Ze({method:"POST",fullPath:"/v1/test_helpers/issuing/cards/{card}/shipping/deliver"}),failCard:Ze({method:"POST",fullPath:"/v1/test_helpers/issuing/cards/{card}/shipping/fail"}),returnCard:Ze({method:"POST",fullPath:"/v1/test_helpers/issuing/cards/{card}/shipping/return"}),shipCard:Ze({method:"POST",fullPath:"/v1/test_helpers/issuing/cards/{card}/shipping/ship"}),submitCard:Ze({method:"POST",fullPath:"/v1/test_helpers/issuing/cards/{card}/shipping/submit"})});var cr=n.method,Xs=n.extend({create:cr({method:"POST",fullPath:"/v1/billing_portal/configurations"}),retrieve:cr({method:"GET",fullPath:"/v1/billing_portal/configurations/{configuration}"}),update:cr({method:"POST",fullPath:"/v1/billing_portal/configurations/{configuration}"}),list:cr({method:"GET",fullPath:"/v1/billing_portal/configurations",methodType:"list"})});var et=n.method,Qs=n.extend({create:et({method:"POST",fullPath:"/v1/terminal/configurations"}),retrieve:et({method:"GET",fullPath:"/v1/terminal/configurations/{configuration}"}),update:et({method:"POST",fullPath:"/v1/terminal/configurations/{configuration}"}),list:et({method:"GET",fullPath:"/v1/terminal/configurations",methodType:"list"}),del:et({method:"DELETE",fullPath:"/v1/terminal/configurations/{configuration}"})});var Xc=n.method,Zs=n.extend({create:Xc({method:"POST",fullPath:"/v1/test_helpers/confirmation_tokens"})});var Qc=n.method,en=n.extend({create:Qc({method:"POST",fullPath:"/v1/terminal/connection_tokens"})});var Zc=n.method,tn=n.extend({retrieve:Zc({method:"GET",fullPath:"/v1/billing/credit_balance_summary"})});var rn=n.method,on=n.extend({retrieve:rn({method:"GET",fullPath:"/v1/billing/credit_balance_transactions/{id}"}),list:rn({method:"GET",fullPath:"/v1/billing/credit_balance_transactions",methodType:"list"})});var Oe=n.method,sn=n.extend({create:Oe({method:"POST",fullPath:"/v1/billing/credit_grants"}),retrieve:Oe({method:"GET",fullPath:"/v1/billing/credit_grants/{id}"}),update:Oe({method:"POST",fullPath:"/v1/billing/credit_grants/{id}"}),list:Oe({method:"GET",fullPath:"/v1/billing/credit_grants",methodType:"list"}),expire:Oe({method:"POST",fullPath:"/v1/billing/credit_grants/{id}/expire"}),voidGrant:Oe({method:"POST",fullPath:"/v1/billing/credit_grants/{id}/void"})});var So=n.method,nn=n.extend({create:So({method:"POST",fullPath:"/v1/treasury/credit_reversals"}),retrieve:So({method:"GET",fullPath:"/v1/treasury/credit_reversals/{credit_reversal}"}),list:So({method:"GET",fullPath:"/v1/treasury/credit_reversals",methodType:"list"})});var el=n.method,an=n.extend({fundCashBalance:el({method:"POST",fullPath:"/v1/test_helpers/customers/{customer}/fund_cash_balance"})});var Eo=n.method,cn=n.extend({create:Eo({method:"POST",fullPath:"/v1/treasury/debit_reversals"}),retrieve:Eo({method:"GET",fullPath:"/v1/treasury/debit_reversals/{debit_reversal}"}),list:Eo({method:"GET",fullPath:"/v1/treasury/debit_reversals",methodType:"list"})});var tt=n.method,ln=n.extend({create:tt({method:"POST",fullPath:"/v1/issuing/disputes"}),retrieve:tt({method:"GET",fullPath:"/v1/issuing/disputes/{dispute}"}),update:tt({method:"POST",fullPath:"/v1/issuing/disputes/{dispute}"}),list:tt({method:"GET",fullPath:"/v1/issuing/disputes",methodType:"list"}),submit:tt({method:"POST",fullPath:"/v1/issuing/disputes/{dispute}/submit"})});var un=n.method,dn=n.extend({retrieve:un({method:"GET",fullPath:"/v1/radar/early_fraud_warnings/{early_fraud_warning}"}),list:un({method:"GET",fullPath:"/v1/radar/early_fraud_warnings",methodType:"list"})});var ne=n.method,mn=n.extend({create:ne({method:"POST",fullPath:"/v2/core/event_destinations"}),retrieve:ne({method:"GET",fullPath:"/v2/core/event_destinations/{id}"}),update:ne({method:"POST",fullPath:"/v2/core/event_destinations/{id}"}),list:ne({method:"GET",fullPath:"/v2/core/event_destinations",methodType:"list"}),del:ne({method:"DELETE",fullPath:"/v2/core/event_destinations/{id}"}),disable:ne({method:"POST",fullPath:"/v2/core/event_destinations/{id}/disable"}),enable:ne({method:"POST",fullPath:"/v2/core/event_destinations/{id}/enable"}),ping:ne({method:"POST",fullPath:"/v2/core/event_destinations/{id}/ping"})});var xo=n.method,hn=n.extend({retrieve(...t){return xo({method:"GET",fullPath:"/v2/core/events/{id}",transformResponseData:r=>this.addFetchRelatedObjectIfNeeded(r)}).apply(this,t)},list(...t){return xo({method:"GET",fullPath:"/v2/core/events",methodType:"list",transformResponseData:r=>Object.assign(Object.assign({},r),{data:r.data.map(this.addFetchRelatedObjectIfNeeded.bind(this))})}).apply(this,t)},addFetchRelatedObjectIfNeeded(t){return!t.related_object||!t.related_object.url?t:Object.assign(Object.assign({},t),{fetchRelatedObject:()=>xo({method:"GET",fullPath:t.related_object.url}).apply(this,[{stripeAccount:t.context}])})}});var lr=n.method,pn=n.extend({create:lr({method:"POST",fullPath:"/v1/entitlements/features"}),retrieve:lr({method:"GET",fullPath:"/v1/entitlements/features/{id}"}),update:lr({method:"POST",fullPath:"/v1/entitlements/features/{id}"}),list:lr({method:"GET",fullPath:"/v1/entitlements/features",methodType:"list"})});var he=n.method,fn=n.extend({create:he({method:"POST",fullPath:"/v1/treasury/financial_accounts"}),retrieve:he({method:"GET",fullPath:"/v1/treasury/financial_accounts/{financial_account}"}),update:he({method:"POST",fullPath:"/v1/treasury/financial_accounts/{financial_account}"}),list:he({method:"GET",fullPath:"/v1/treasury/financial_accounts",methodType:"list"}),close:he({method:"POST",fullPath:"/v1/treasury/financial_accounts/{financial_account}/close"}),retrieveFeatures:he({method:"GET",fullPath:"/v1/treasury/financial_accounts/{financial_account}/features"}),updateFeatures:he({method:"POST",fullPath:"/v1/treasury/financial_accounts/{financial_account}/features"})});var wo=n.method,vn=n.extend({fail:wo({method:"POST",fullPath:"/v1/test_helpers/treasury/inbound_transfers/{id}/fail"}),returnInboundTransfer:wo({method:"POST",fullPath:"/v1/test_helpers/treasury/inbound_transfers/{id}/return"}),succeed:wo({method:"POST",fullPath:"/v1/test_helpers/treasury/inbound_transfers/{id}/succeed"})});var ur=n.method,gn=n.extend({create:ur({method:"POST",fullPath:"/v1/treasury/inbound_transfers"}),retrieve:ur({method:"GET",fullPath:"/v1/treasury/inbound_transfers/{id}"}),list:ur({method:"GET",fullPath:"/v1/treasury/inbound_transfers",methodType:"list"}),cancel:ur({method:"POST",fullPath:"/v1/treasury/inbound_transfers/{inbound_transfer}/cancel"})});var rt=n.method,yn=n.extend({create:rt({method:"POST",fullPath:"/v1/terminal/locations"}),retrieve:rt({method:"GET",fullPath:"/v1/terminal/locations/{location}"}),update:rt({method:"POST",fullPath:"/v1/terminal/locations/{location}"}),list:rt({method:"GET",fullPath:"/v1/terminal/locations",methodType:"list"}),del:rt({method:"DELETE",fullPath:"/v1/terminal/locations/{location}"})});var tl=n.method,Pn=n.extend({create:tl({method:"POST",fullPath:"/v1/billing/meter_event_adjustments"})});var rl=n.method,Tn=n.extend({create:rl({method:"POST",fullPath:"/v2/billing/meter_event_adjustments"})});var ol=n.method,_n=n.extend({create:ol({method:"POST",fullPath:"/v2/billing/meter_event_session"})});var sl=n.method,Sn=n.extend({create:sl({method:"POST",fullPath:"/v2/billing/meter_event_stream",host:"meter-events.stripe.com"})});var nl=n.method,En=n.extend({create:nl({method:"POST",fullPath:"/v1/billing/meter_events"})});var il=n.method,xn=n.extend({create:il({method:"POST",fullPath:"/v2/billing/meter_events"})});var pe=n.method,wn=n.extend({create:pe({method:"POST",fullPath:"/v1/billing/meters"}),retrieve:pe({method:"GET",fullPath:"/v1/billing/meters/{id}"}),update:pe({method:"POST",fullPath:"/v1/billing/meters/{id}"}),list:pe({method:"GET",fullPath:"/v1/billing/meters",methodType:"list"}),deactivate:pe({method:"POST",fullPath:"/v1/billing/meters/{id}/deactivate"}),listEventSummaries:pe({method:"GET",fullPath:"/v1/billing/meters/{id}/event_summaries",methodType:"list"}),reactivate:pe({method:"POST",fullPath:"/v1/billing/meters/{id}/reactivate"})});var ot=n.method,On=n.extend({create:ot({method:"POST",fullPath:"/v1/climate/orders"}),retrieve:ot({method:"GET",fullPath:"/v1/climate/orders/{order}"}),update:ot({method:"POST",fullPath:"/v1/climate/orders/{order}"}),list:ot({method:"GET",fullPath:"/v1/climate/orders",methodType:"list"}),cancel:ot({method:"POST",fullPath:"/v1/climate/orders/{order}/cancel"})});var dr=n.method,bn=n.extend({update:dr({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_payments/{id}"}),fail:dr({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_payments/{id}/fail"}),post:dr({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_payments/{id}/post"}),returnOutboundPayment:dr({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_payments/{id}/return"})});var mr=n.method,Rn=n.extend({create:mr({method:"POST",fullPath:"/v1/treasury/outbound_payments"}),retrieve:mr({method:"GET",fullPath:"/v1/treasury/outbound_payments/{id}"}),list:mr({method:"GET",fullPath:"/v1/treasury/outbound_payments",methodType:"list"}),cancel:mr({method:"POST",fullPath:"/v1/treasury/outbound_payments/{id}/cancel"})});var hr=n.method,An=n.extend({update:hr({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}"}),fail:hr({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail"}),post:hr({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post"}),returnOutboundTransfer:hr({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return"})});var pr=n.method,Cn=n.extend({create:pr({method:"POST",fullPath:"/v1/treasury/outbound_transfers"}),retrieve:pr({method:"GET",fullPath:"/v1/treasury/outbound_transfers/{outbound_transfer}"}),list:pr({method:"GET",fullPath:"/v1/treasury/outbound_transfers",methodType:"list"}),cancel:pr({method:"POST",fullPath:"/v1/treasury/outbound_transfers/{outbound_transfer}/cancel"})});var fr=n.method,In=n.extend({create:fr({method:"POST",fullPath:"/v1/issuing/personalization_designs"}),retrieve:fr({method:"GET",fullPath:"/v1/issuing/personalization_designs/{personalization_design}"}),update:fr({method:"POST",fullPath:"/v1/issuing/personalization_designs/{personalization_design}"}),list:fr({method:"GET",fullPath:"/v1/issuing/personalization_designs",methodType:"list"})});var Oo=n.method,Mn=n.extend({activate:Oo({method:"POST",fullPath:"/v1/test_helpers/issuing/personalization_designs/{personalization_design}/activate"}),deactivate:Oo({method:"POST",fullPath:"/v1/test_helpers/issuing/personalization_designs/{personalization_design}/deactivate"}),reject:Oo({method:"POST",fullPath:"/v1/test_helpers/issuing/personalization_designs/{personalization_design}/reject"})});var kn=n.method,Nn=n.extend({retrieve:kn({method:"GET",fullPath:"/v1/issuing/physical_bundles/{physical_bundle}"}),list:kn({method:"GET",fullPath:"/v1/issuing/physical_bundles",methodType:"list"})});var Dn=n.method,Gn=n.extend({retrieve:Dn({method:"GET",fullPath:"/v1/climate/products/{product}"}),list:Dn({method:"GET",fullPath:"/v1/climate/products",methodType:"list"})});var q=n.method,Hn=n.extend({create:q({method:"POST",fullPath:"/v1/terminal/readers"}),retrieve:q({method:"GET",fullPath:"/v1/terminal/readers/{reader}"}),update:q({method:"POST",fullPath:"/v1/terminal/readers/{reader}"}),list:q({method:"GET",fullPath:"/v1/terminal/readers",methodType:"list"}),del:q({method:"DELETE",fullPath:"/v1/terminal/readers/{reader}"}),cancelAction:q({method:"POST",fullPath:"/v1/terminal/readers/{reader}/cancel_action"}),collectInputs:q({method:"POST",fullPath:"/v1/terminal/readers/{reader}/collect_inputs"}),collectPaymentMethod:q({method:"POST",fullPath:"/v1/terminal/readers/{reader}/collect_payment_method"}),confirmPaymentIntent:q({method:"POST",fullPath:"/v1/terminal/readers/{reader}/confirm_payment_intent"}),processPaymentIntent:q({method:"POST",fullPath:"/v1/terminal/readers/{reader}/process_payment_intent"}),processSetupIntent:q({method:"POST",fullPath:"/v1/terminal/readers/{reader}/process_setup_intent"}),refundPayment:q({method:"POST",fullPath:"/v1/terminal/readers/{reader}/refund_payment"}),setReaderDisplay:q({method:"POST",fullPath:"/v1/terminal/readers/{reader}/set_reader_display"})});var bo=n.method,Ln=n.extend({presentPaymentMethod:bo({method:"POST",fullPath:"/v1/test_helpers/terminal/readers/{reader}/present_payment_method"}),succeedInputCollection:bo({method:"POST",fullPath:"/v1/test_helpers/terminal/readers/{reader}/succeed_input_collection"}),timeoutInputCollection:bo({method:"POST",fullPath:"/v1/test_helpers/terminal/readers/{reader}/timeout_input_collection"})});var al=n.method,qn=n.extend({create:al({method:"POST",fullPath:"/v1/test_helpers/treasury/received_credits"})});var jn=n.method,Un=n.extend({retrieve:jn({method:"GET",fullPath:"/v1/treasury/received_credits/{id}"}),list:jn({method:"GET",fullPath:"/v1/treasury/received_credits",methodType:"list"})});var cl=n.method,Fn=n.extend({create:cl({method:"POST",fullPath:"/v1/test_helpers/treasury/received_debits"})});var $n=n.method,Vn=n.extend({retrieve:$n({method:"GET",fullPath:"/v1/treasury/received_debits/{id}"}),list:$n({method:"GET",fullPath:"/v1/treasury/received_debits",methodType:"list"})});var ll=n.method,Kn=n.extend({expire:ll({method:"POST",fullPath:"/v1/test_helpers/refunds/{refund}/expire"})});var vr=n.method,Bn=n.extend({create:vr({method:"POST",fullPath:"/v1/tax/registrations"}),retrieve:vr({method:"GET",fullPath:"/v1/tax/registrations/{id}"}),update:vr({method:"POST",fullPath:"/v1/tax/registrations/{id}"}),list:vr({method:"GET",fullPath:"/v1/tax/registrations",methodType:"list"})});var Ro=n.method,zn=n.extend({create:Ro({method:"POST",fullPath:"/v1/reporting/report_runs"}),retrieve:Ro({method:"GET",fullPath:"/v1/reporting/report_runs/{report_run}"}),list:Ro({method:"GET",fullPath:"/v1/reporting/report_runs",methodType:"list"})});var Wn=n.method,Jn=n.extend({retrieve:Wn({method:"GET",fullPath:"/v1/reporting/report_types/{report_type}"}),list:Wn({method:"GET",fullPath:"/v1/reporting/report_types",methodType:"list"})});var Ao=n.method,Yn=n.extend({create:Ao({method:"POST",fullPath:"/v1/forwarding/requests"}),retrieve:Ao({method:"GET",fullPath:"/v1/forwarding/requests/{id}"}),list:Ao({method:"GET",fullPath:"/v1/forwarding/requests",methodType:"list"})});var Xn=n.method,Qn=n.extend({retrieve:Xn({method:"GET",fullPath:"/v1/sigma/scheduled_query_runs/{scheduled_query_run}"}),list:Xn({method:"GET",fullPath:"/v1/sigma/scheduled_query_runs",methodType:"list"})});var gr=n.method,Zn=n.extend({create:gr({method:"POST",fullPath:"/v1/apps/secrets"}),list:gr({method:"GET",fullPath:"/v1/apps/secrets",methodType:"list"}),deleteWhere:gr({method:"POST",fullPath:"/v1/apps/secrets/delete"}),find:gr({method:"GET",fullPath:"/v1/apps/secrets/find"})});var ul=n.method,ei=n.extend({create:ul({method:"POST",fullPath:"/v1/billing_portal/sessions"})});var be=n.method,ti=n.extend({create:be({method:"POST",fullPath:"/v1/checkout/sessions"}),retrieve:be({method:"GET",fullPath:"/v1/checkout/sessions/{session}"}),update:be({method:"POST",fullPath:"/v1/checkout/sessions/{session}"}),list:be({method:"GET",fullPath:"/v1/checkout/sessions",methodType:"list"}),expire:be({method:"POST",fullPath:"/v1/checkout/sessions/{session}/expire"}),listLineItems:be({method:"GET",fullPath:"/v1/checkout/sessions/{session}/line_items",methodType:"list"})});var ri=n.method,oi=n.extend({create:ri({method:"POST",fullPath:"/v1/financial_connections/sessions"}),retrieve:ri({method:"GET",fullPath:"/v1/financial_connections/sessions/{session}"})});var si=n.method,ni=n.extend({retrieve:si({method:"GET",fullPath:"/v1/tax/settings"}),update:si({method:"POST",fullPath:"/v1/tax/settings"})});var ii=n.method,ai=n.extend({retrieve:ii({method:"GET",fullPath:"/v1/climate/suppliers/{supplier}"}),list:ii({method:"GET",fullPath:"/v1/climate/suppliers",methodType:"list"})});var st=n.method,ci=n.extend({create:st({method:"POST",fullPath:"/v1/test_helpers/test_clocks"}),retrieve:st({method:"GET",fullPath:"/v1/test_helpers/test_clocks/{test_clock}"}),list:st({method:"GET",fullPath:"/v1/test_helpers/test_clocks",methodType:"list"}),del:st({method:"DELETE",fullPath:"/v1/test_helpers/test_clocks/{test_clock}"}),advance:st({method:"POST",fullPath:"/v1/test_helpers/test_clocks/{test_clock}/advance"})});var Co=n.method,li=n.extend({retrieve:Co({method:"GET",fullPath:"/v1/issuing/tokens/{token}"}),update:Co({method:"POST",fullPath:"/v1/issuing/tokens/{token}"}),list:Co({method:"GET",fullPath:"/v1/issuing/tokens",methodType:"list"})});var ui=n.method,di=n.extend({retrieve:ui({method:"GET",fullPath:"/v1/treasury/transaction_entries/{id}"}),list:ui({method:"GET",fullPath:"/v1/treasury/transaction_entries",methodType:"list"})});var mi=n.method,hi=n.extend({retrieve:mi({method:"GET",fullPath:"/v1/financial_connections/transactions/{transaction}"}),list:mi({method:"GET",fullPath:"/v1/financial_connections/transactions",methodType:"list"})});var Io=n.method,pi=n.extend({retrieve:Io({method:"GET",fullPath:"/v1/issuing/transactions/{transaction}"}),update:Io({method:"POST",fullPath:"/v1/issuing/transactions/{transaction}"}),list:Io({method:"GET",fullPath:"/v1/issuing/transactions",methodType:"list"})});var yr=n.method,fi=n.extend({retrieve:yr({method:"GET",fullPath:"/v1/tax/transactions/{transaction}"}),createFromCalculation:yr({method:"POST",fullPath:"/v1/tax/transactions/create_from_calculation"}),createReversal:yr({method:"POST",fullPath:"/v1/tax/transactions/create_reversal"}),listLineItems:yr({method:"GET",fullPath:"/v1/tax/transactions/{transaction}/line_items",methodType:"list"})});var Mo=n.method,vi=n.extend({createForceCapture:Mo({method:"POST",fullPath:"/v1/test_helpers/issuing/transactions/create_force_capture"}),createUnlinkedRefund:Mo({method:"POST",fullPath:"/v1/test_helpers/issuing/transactions/create_unlinked_refund"}),refund:Mo({method:"POST",fullPath:"/v1/test_helpers/issuing/transactions/{transaction}/refund"})});var gi=n.method,yi=n.extend({retrieve:gi({method:"GET",fullPath:"/v1/treasury/transactions/{id}"}),list:gi({method:"GET",fullPath:"/v1/treasury/transactions",methodType:"list"})});var Pr=n.method,Pi=n.extend({create:Pr({method:"POST",fullPath:"/v1/radar/value_list_items"}),retrieve:Pr({method:"GET",fullPath:"/v1/radar/value_list_items/{item}"}),list:Pr({method:"GET",fullPath:"/v1/radar/value_list_items",methodType:"list"}),del:Pr({method:"DELETE",fullPath:"/v1/radar/value_list_items/{item}"})});var nt=n.method,Ti=n.extend({create:nt({method:"POST",fullPath:"/v1/radar/value_lists"}),retrieve:nt({method:"GET",fullPath:"/v1/radar/value_lists/{value_list}"}),update:nt({method:"POST",fullPath:"/v1/radar/value_lists/{value_list}"}),list:nt({method:"GET",fullPath:"/v1/radar/value_lists",methodType:"list"}),del:nt({method:"DELETE",fullPath:"/v1/radar/value_lists/{value_list}"})});var _i=n.method,Si=n.extend({retrieve:_i({method:"GET",fullPath:"/v1/identity/verification_reports/{report}"}),list:_i({method:"GET",fullPath:"/v1/identity/verification_reports",methodType:"list"})});var Re=n.method,Ei=n.extend({create:Re({method:"POST",fullPath:"/v1/identity/verification_sessions"}),retrieve:Re({method:"GET",fullPath:"/v1/identity/verification_sessions/{session}"}),update:Re({method:"POST",fullPath:"/v1/identity/verification_sessions/{session}"}),list:Re({method:"GET",fullPath:"/v1/identity/verification_sessions",methodType:"list"}),cancel:Re({method:"POST",fullPath:"/v1/identity/verification_sessions/{session}/cancel"}),redact:Re({method:"POST",fullPath:"/v1/identity/verification_sessions/{session}/redact"})});var I=n.method,ko=n.extend({create:I({method:"POST",fullPath:"/v1/accounts"}),retrieve(t,...e){return typeof t=="string"?I({method:"GET",fullPath:"/v1/accounts/{id}"}).apply(this,[t,...e]):(t==null&&[].shift.apply([t,...e]),I({method:"GET",fullPath:"/v1/account"}).apply(this,[t,...e]))},update:I({method:"POST",fullPath:"/v1/accounts/{account}"}),list:I({method:"GET",fullPath:"/v1/accounts",methodType:"list"}),del:I({method:"DELETE",fullPath:"/v1/accounts/{account}"}),createExternalAccount:I({method:"POST",fullPath:"/v1/accounts/{account}/external_accounts"}),createLoginLink:I({method:"POST",fullPath:"/v1/accounts/{account}/login_links"}),createPerson:I({method:"POST",fullPath:"/v1/accounts/{account}/persons"}),deleteExternalAccount:I({method:"DELETE",fullPath:"/v1/accounts/{account}/external_accounts/{id}"}),deletePerson:I({method:"DELETE",fullPath:"/v1/accounts/{account}/persons/{person}"}),listCapabilities:I({method:"GET",fullPath:"/v1/accounts/{account}/capabilities",methodType:"list"}),listExternalAccounts:I({method:"GET",fullPath:"/v1/accounts/{account}/external_accounts",methodType:"list"}),listPersons:I({method:"GET",fullPath:"/v1/accounts/{account}/persons",methodType:"list"}),reject:I({method:"POST",fullPath:"/v1/accounts/{account}/reject"}),retrieveCurrent:I({method:"GET",fullPath:"/v1/account"}),retrieveCapability:I({method:"GET",fullPath:"/v1/accounts/{account}/capabilities/{capability}"}),retrieveExternalAccount:I({method:"GET",fullPath:"/v1/accounts/{account}/external_accounts/{id}"}),retrievePerson:I({method:"GET",fullPath:"/v1/accounts/{account}/persons/{person}"}),updateCapability:I({method:"POST",fullPath:"/v1/accounts/{account}/capabilities/{capability}"}),updateExternalAccount:I({method:"POST",fullPath:"/v1/accounts/{account}/external_accounts/{id}"}),updatePerson:I({method:"POST",fullPath:"/v1/accounts/{account}/persons/{person}"})});var dl=n.method,xi=n.extend({create:dl({method:"POST",fullPath:"/v1/account_links"})});var ml=n.method,wi=n.extend({create:ml({method:"POST",fullPath:"/v1/account_sessions"})});var Tr=n.method,Oi=n.extend({create:Tr({method:"POST",fullPath:"/v1/apple_pay/domains"}),retrieve:Tr({method:"GET",fullPath:"/v1/apple_pay/domains/{domain}"}),list:Tr({method:"GET",fullPath:"/v1/apple_pay/domains",methodType:"list"}),del:Tr({method:"DELETE",fullPath:"/v1/apple_pay/domains/{domain}"})});var Ae=n.method,bi=n.extend({retrieve:Ae({method:"GET",fullPath:"/v1/application_fees/{id}"}),list:Ae({method:"GET",fullPath:"/v1/application_fees",methodType:"list"}),createRefund:Ae({method:"POST",fullPath:"/v1/application_fees/{id}/refunds"}),listRefunds:Ae({method:"GET",fullPath:"/v1/application_fees/{id}/refunds",methodType:"list"}),retrieveRefund:Ae({method:"GET",fullPath:"/v1/application_fees/{fee}/refunds/{id}"}),updateRefund:Ae({method:"POST",fullPath:"/v1/application_fees/{fee}/refunds/{id}"})});var hl=n.method,Ri=n.extend({retrieve:hl({method:"GET",fullPath:"/v1/balance"})});var Ai=n.method,Ci=n.extend({retrieve:Ai({method:"GET",fullPath:"/v1/balance_transactions/{id}"}),list:Ai({method:"GET",fullPath:"/v1/balance_transactions",methodType:"list"})});var Ce=n.method,Ii=n.extend({create:Ce({method:"POST",fullPath:"/v1/charges"}),retrieve:Ce({method:"GET",fullPath:"/v1/charges/{charge}"}),update:Ce({method:"POST",fullPath:"/v1/charges/{charge}"}),list:Ce({method:"GET",fullPath:"/v1/charges",methodType:"list"}),capture:Ce({method:"POST",fullPath:"/v1/charges/{charge}/capture"}),search:Ce({method:"GET",fullPath:"/v1/charges/search",methodType:"search"})});var pl=n.method,Mi=n.extend({retrieve:pl({method:"GET",fullPath:"/v1/confirmation_tokens/{confirmation_token}"})});var ki=n.method,Ni=n.extend({retrieve:ki({method:"GET",fullPath:"/v1/country_specs/{country}"}),list:ki({method:"GET",fullPath:"/v1/country_specs",methodType:"list"})});var it=n.method,Di=n.extend({create:it({method:"POST",fullPath:"/v1/coupons"}),retrieve:it({method:"GET",fullPath:"/v1/coupons/{coupon}"}),update:it({method:"POST",fullPath:"/v1/coupons/{coupon}"}),list:it({method:"GET",fullPath:"/v1/coupons",methodType:"list"}),del:it({method:"DELETE",fullPath:"/v1/coupons/{coupon}"})});var ie=n.method,Gi=n.extend({create:ie({method:"POST",fullPath:"/v1/credit_notes"}),retrieve:ie({method:"GET",fullPath:"/v1/credit_notes/{id}"}),update:ie({method:"POST",fullPath:"/v1/credit_notes/{id}"}),list:ie({method:"GET",fullPath:"/v1/credit_notes",methodType:"list"}),listLineItems:ie({method:"GET",fullPath:"/v1/credit_notes/{credit_note}/lines",methodType:"list"}),listPreviewLineItems:ie({method:"GET",fullPath:"/v1/credit_notes/preview/lines",methodType:"list"}),preview:ie({method:"GET",fullPath:"/v1/credit_notes/preview"}),voidCreditNote:ie({method:"POST",fullPath:"/v1/credit_notes/{id}/void"})});var fl=n.method,Hi=n.extend({create:fl({method:"POST",fullPath:"/v1/customer_sessions"})});var w=n.method,Li=n.extend({create:w({method:"POST",fullPath:"/v1/customers"}),retrieve:w({method:"GET",fullPath:"/v1/customers/{customer}"}),update:w({method:"POST",fullPath:"/v1/customers/{customer}"}),list:w({method:"GET",fullPath:"/v1/customers",methodType:"list"}),del:w({method:"DELETE",fullPath:"/v1/customers/{customer}"}),createBalanceTransaction:w({method:"POST",fullPath:"/v1/customers/{customer}/balance_transactions"}),createFundingInstructions:w({method:"POST",fullPath:"/v1/customers/{customer}/funding_instructions"}),createSource:w({method:"POST",fullPath:"/v1/customers/{customer}/sources"}),createTaxId:w({method:"POST",fullPath:"/v1/customers/{customer}/tax_ids"}),deleteDiscount:w({method:"DELETE",fullPath:"/v1/customers/{customer}/discount"}),deleteSource:w({method:"DELETE",fullPath:"/v1/customers/{customer}/sources/{id}"}),deleteTaxId:w({method:"DELETE",fullPath:"/v1/customers/{customer}/tax_ids/{id}"}),listBalanceTransactions:w({method:"GET",fullPath:"/v1/customers/{customer}/balance_transactions",methodType:"list"}),listCashBalanceTransactions:w({method:"GET",fullPath:"/v1/customers/{customer}/cash_balance_transactions",methodType:"list"}),listPaymentMethods:w({method:"GET",fullPath:"/v1/customers/{customer}/payment_methods",methodType:"list"}),listSources:w({method:"GET",fullPath:"/v1/customers/{customer}/sources",methodType:"list"}),listTaxIds:w({method:"GET",fullPath:"/v1/customers/{customer}/tax_ids",methodType:"list"}),retrieveBalanceTransaction:w({method:"GET",fullPath:"/v1/customers/{customer}/balance_transactions/{transaction}"}),retrieveCashBalance:w({method:"GET",fullPath:"/v1/customers/{customer}/cash_balance"}),retrieveCashBalanceTransaction:w({method:"GET",fullPath:"/v1/customers/{customer}/cash_balance_transactions/{transaction}"}),retrievePaymentMethod:w({method:"GET",fullPath:"/v1/customers/{customer}/payment_methods/{payment_method}"}),retrieveSource:w({method:"GET",fullPath:"/v1/customers/{customer}/sources/{id}"}),retrieveTaxId:w({method:"GET",fullPath:"/v1/customers/{customer}/tax_ids/{id}"}),search:w({method:"GET",fullPath:"/v1/customers/search",methodType:"search"}),updateBalanceTransaction:w({method:"POST",fullPath:"/v1/customers/{customer}/balance_transactions/{transaction}"}),updateCashBalance:w({method:"POST",fullPath:"/v1/customers/{customer}/cash_balance"}),updateSource:w({method:"POST",fullPath:"/v1/customers/{customer}/sources/{id}"}),verifySource:w({method:"POST",fullPath:"/v1/customers/{customer}/sources/{id}/verify"})});var _r=n.method,qi=n.extend({retrieve:_r({method:"GET",fullPath:"/v1/disputes/{dispute}"}),update:_r({method:"POST",fullPath:"/v1/disputes/{dispute}"}),list:_r({method:"GET",fullPath:"/v1/disputes",methodType:"list"}),close:_r({method:"POST",fullPath:"/v1/disputes/{dispute}/close"})});var ji=n.method,Ui=n.extend({create:ji({method:"POST",fullPath:"/v1/ephemeral_keys",validator:(t,e)=>{if(!e.headers||!e.headers["Stripe-Version"])throw new Error("Passing apiVersion in a separate options hash is required to create an ephemeral key. See https://stripe.com/docs/api/versioning?lang=node")}}),del:ji({method:"DELETE",fullPath:"/v1/ephemeral_keys/{key}"})});var Fi=n.method,$i=n.extend({retrieve:Fi({method:"GET",fullPath:"/v1/events/{id}"}),list:Fi({method:"GET",fullPath:"/v1/events",methodType:"list"})});var Vi=n.method,Ki=n.extend({retrieve:Vi({method:"GET",fullPath:"/v1/exchange_rates/{rate_id}"}),list:Vi({method:"GET",fullPath:"/v1/exchange_rates",methodType:"list"})});var Sr=n.method,Bi=n.extend({create:Sr({method:"POST",fullPath:"/v1/file_links"}),retrieve:Sr({method:"GET",fullPath:"/v1/file_links/{link}"}),update:Sr({method:"POST",fullPath:"/v1/file_links/{link}"}),list:Sr({method:"GET",fullPath:"/v1/file_links",methodType:"list"})});var vl=(t,e,r)=>{let o=(Math.round(Math.random()*1e16)+Math.round(Math.random()*1e16)).toString();r["Content-Type"]=`multipart/form-data; boundary=${o}`;let s=new TextEncoder,i=new Uint8Array(0),a=s.encode(`\r +`);function l(d){let m=i,h=d instanceof Uint8Array?d:new Uint8Array(s.encode(d));i=new Uint8Array(m.length+h.length+2),i.set(m),i.set(h,m.length),i.set(a,i.length-2)}function c(d){return`"${d.replace(/"|"/g,"%22").replace(/\r\n|\r|\n/g," ")}"`}let u=Cs(e);for(let d in u){if(!Object.prototype.hasOwnProperty.call(u,d))continue;let m=u[d];if(l(`--${o}`),Object.prototype.hasOwnProperty.call(m,"data")){let h=m;l(`Content-Disposition: form-data; name=${c(d)}; filename=${c(h.name||"blob")}`),l(`Content-Type: ${h.type||"application/octet-stream"}`),l(""),l(h.data)}else l(`Content-Disposition: form-data; name=${c(d)}`),l(""),l(m)}return l(`--${o}--`),i};function zi(t,e,r,o){if(e=e||{},t!=="POST")return o(null,se(e));this._stripe._platformFunctions.tryBufferData(e).then(s=>{let i=vl(t,s,r);return o(null,i)}).catch(s=>o(s,null))}var No=n.method,Wi=n.extend({create:No({method:"POST",fullPath:"/v1/files",headers:{"Content-Type":"multipart/form-data"},host:"files.stripe.com"}),retrieve:No({method:"GET",fullPath:"/v1/files/{file}"}),list:No({method:"GET",fullPath:"/v1/files",methodType:"list"}),requestDataProcessor:zi});var at=n.method,Ji=n.extend({create:at({method:"POST",fullPath:"/v1/invoiceitems"}),retrieve:at({method:"GET",fullPath:"/v1/invoiceitems/{invoiceitem}"}),update:at({method:"POST",fullPath:"/v1/invoiceitems/{invoiceitem}"}),list:at({method:"GET",fullPath:"/v1/invoiceitems",methodType:"list"}),del:at({method:"DELETE",fullPath:"/v1/invoiceitems/{invoiceitem}"})});var Yi=n.method,Xi=n.extend({retrieve:Yi({method:"GET",fullPath:"/v1/invoice_payments/{invoice_payment}"}),list:Yi({method:"GET",fullPath:"/v1/invoice_payments",methodType:"list"})});var Er=n.method,Qi=n.extend({retrieve:Er({method:"GET",fullPath:"/v1/invoice_rendering_templates/{template}"}),list:Er({method:"GET",fullPath:"/v1/invoice_rendering_templates",methodType:"list"}),archive:Er({method:"POST",fullPath:"/v1/invoice_rendering_templates/{template}/archive"}),unarchive:Er({method:"POST",fullPath:"/v1/invoice_rendering_templates/{template}/unarchive"})});var k=n.method,Zi=n.extend({create:k({method:"POST",fullPath:"/v1/invoices"}),retrieve:k({method:"GET",fullPath:"/v1/invoices/{invoice}"}),update:k({method:"POST",fullPath:"/v1/invoices/{invoice}"}),list:k({method:"GET",fullPath:"/v1/invoices",methodType:"list"}),del:k({method:"DELETE",fullPath:"/v1/invoices/{invoice}"}),addLines:k({method:"POST",fullPath:"/v1/invoices/{invoice}/add_lines"}),attachPayment:k({method:"POST",fullPath:"/v1/invoices/{invoice}/attach_payment"}),createPreview:k({method:"POST",fullPath:"/v1/invoices/create_preview"}),finalizeInvoice:k({method:"POST",fullPath:"/v1/invoices/{invoice}/finalize"}),listLineItems:k({method:"GET",fullPath:"/v1/invoices/{invoice}/lines",methodType:"list"}),markUncollectible:k({method:"POST",fullPath:"/v1/invoices/{invoice}/mark_uncollectible"}),pay:k({method:"POST",fullPath:"/v1/invoices/{invoice}/pay"}),removeLines:k({method:"POST",fullPath:"/v1/invoices/{invoice}/remove_lines"}),search:k({method:"GET",fullPath:"/v1/invoices/search",methodType:"search"}),sendInvoice:k({method:"POST",fullPath:"/v1/invoices/{invoice}/send"}),updateLines:k({method:"POST",fullPath:"/v1/invoices/{invoice}/update_lines"}),updateLineItem:k({method:"POST",fullPath:"/v1/invoices/{invoice}/lines/{line_item_id}"}),voidInvoice:k({method:"POST",fullPath:"/v1/invoices/{invoice}/void"})});var gl=n.method,ea=n.extend({retrieve:gl({method:"GET",fullPath:"/v1/mandates/{mandate}"})});var ta=n.method,Do="connect.stripe.com",ra=n.extend({basePath:"/",authorizeUrl(t,e){t=t||{},e=e||{};let r="oauth/authorize";return e.express&&(r=`express/${r}`),t.response_type||(t.response_type="code"),t.client_id||(t.client_id=this._stripe.getClientId()),t.scope||(t.scope="read_write"),`https://${Do}/${r}?${se(t)}`},token:ta({method:"POST",path:"oauth/token",host:Do}),deauthorize(t,...e){return t.client_id||(t.client_id=this._stripe.getClientId()),ta({method:"POST",path:"oauth/deauthorize",host:Do}).apply(this,[t,...e])}});var B=n.method,oa=n.extend({create:B({method:"POST",fullPath:"/v1/payment_intents"}),retrieve:B({method:"GET",fullPath:"/v1/payment_intents/{intent}"}),update:B({method:"POST",fullPath:"/v1/payment_intents/{intent}"}),list:B({method:"GET",fullPath:"/v1/payment_intents",methodType:"list"}),applyCustomerBalance:B({method:"POST",fullPath:"/v1/payment_intents/{intent}/apply_customer_balance"}),cancel:B({method:"POST",fullPath:"/v1/payment_intents/{intent}/cancel"}),capture:B({method:"POST",fullPath:"/v1/payment_intents/{intent}/capture"}),confirm:B({method:"POST",fullPath:"/v1/payment_intents/{intent}/confirm"}),incrementAuthorization:B({method:"POST",fullPath:"/v1/payment_intents/{intent}/increment_authorization"}),search:B({method:"GET",fullPath:"/v1/payment_intents/search",methodType:"search"}),verifyMicrodeposits:B({method:"POST",fullPath:"/v1/payment_intents/{intent}/verify_microdeposits"})});var ct=n.method,sa=n.extend({create:ct({method:"POST",fullPath:"/v1/payment_links"}),retrieve:ct({method:"GET",fullPath:"/v1/payment_links/{payment_link}"}),update:ct({method:"POST",fullPath:"/v1/payment_links/{payment_link}"}),list:ct({method:"GET",fullPath:"/v1/payment_links",methodType:"list"}),listLineItems:ct({method:"GET",fullPath:"/v1/payment_links/{payment_link}/line_items",methodType:"list"})});var xr=n.method,na=n.extend({create:xr({method:"POST",fullPath:"/v1/payment_method_configurations"}),retrieve:xr({method:"GET",fullPath:"/v1/payment_method_configurations/{configuration}"}),update:xr({method:"POST",fullPath:"/v1/payment_method_configurations/{configuration}"}),list:xr({method:"GET",fullPath:"/v1/payment_method_configurations",methodType:"list"})});var lt=n.method,ia=n.extend({create:lt({method:"POST",fullPath:"/v1/payment_method_domains"}),retrieve:lt({method:"GET",fullPath:"/v1/payment_method_domains/{payment_method_domain}"}),update:lt({method:"POST",fullPath:"/v1/payment_method_domains/{payment_method_domain}"}),list:lt({method:"GET",fullPath:"/v1/payment_method_domains",methodType:"list"}),validate:lt({method:"POST",fullPath:"/v1/payment_method_domains/{payment_method_domain}/validate"})});var Ie=n.method,aa=n.extend({create:Ie({method:"POST",fullPath:"/v1/payment_methods"}),retrieve:Ie({method:"GET",fullPath:"/v1/payment_methods/{payment_method}"}),update:Ie({method:"POST",fullPath:"/v1/payment_methods/{payment_method}"}),list:Ie({method:"GET",fullPath:"/v1/payment_methods",methodType:"list"}),attach:Ie({method:"POST",fullPath:"/v1/payment_methods/{payment_method}/attach"}),detach:Ie({method:"POST",fullPath:"/v1/payment_methods/{payment_method}/detach"})});var Me=n.method,ca=n.extend({create:Me({method:"POST",fullPath:"/v1/payouts"}),retrieve:Me({method:"GET",fullPath:"/v1/payouts/{payout}"}),update:Me({method:"POST",fullPath:"/v1/payouts/{payout}"}),list:Me({method:"GET",fullPath:"/v1/payouts",methodType:"list"}),cancel:Me({method:"POST",fullPath:"/v1/payouts/{payout}/cancel"}),reverse:Me({method:"POST",fullPath:"/v1/payouts/{payout}/reverse"})});var ut=n.method,la=n.extend({create:ut({method:"POST",fullPath:"/v1/plans"}),retrieve:ut({method:"GET",fullPath:"/v1/plans/{plan}"}),update:ut({method:"POST",fullPath:"/v1/plans/{plan}"}),list:ut({method:"GET",fullPath:"/v1/plans",methodType:"list"}),del:ut({method:"DELETE",fullPath:"/v1/plans/{plan}"})});var dt=n.method,ua=n.extend({create:dt({method:"POST",fullPath:"/v1/prices"}),retrieve:dt({method:"GET",fullPath:"/v1/prices/{price}"}),update:dt({method:"POST",fullPath:"/v1/prices/{price}"}),list:dt({method:"GET",fullPath:"/v1/prices",methodType:"list"}),search:dt({method:"GET",fullPath:"/v1/prices/search",methodType:"search"})});var Y=n.method,da=n.extend({create:Y({method:"POST",fullPath:"/v1/products"}),retrieve:Y({method:"GET",fullPath:"/v1/products/{id}"}),update:Y({method:"POST",fullPath:"/v1/products/{id}"}),list:Y({method:"GET",fullPath:"/v1/products",methodType:"list"}),del:Y({method:"DELETE",fullPath:"/v1/products/{id}"}),createFeature:Y({method:"POST",fullPath:"/v1/products/{product}/features"}),deleteFeature:Y({method:"DELETE",fullPath:"/v1/products/{product}/features/{id}"}),listFeatures:Y({method:"GET",fullPath:"/v1/products/{product}/features",methodType:"list"}),retrieveFeature:Y({method:"GET",fullPath:"/v1/products/{product}/features/{id}"}),search:Y({method:"GET",fullPath:"/v1/products/search",methodType:"search"})});var wr=n.method,ma=n.extend({create:wr({method:"POST",fullPath:"/v1/promotion_codes"}),retrieve:wr({method:"GET",fullPath:"/v1/promotion_codes/{promotion_code}"}),update:wr({method:"POST",fullPath:"/v1/promotion_codes/{promotion_code}"}),list:wr({method:"GET",fullPath:"/v1/promotion_codes",methodType:"list"})});var X=n.method,ha=n.extend({create:X({method:"POST",fullPath:"/v1/quotes"}),retrieve:X({method:"GET",fullPath:"/v1/quotes/{quote}"}),update:X({method:"POST",fullPath:"/v1/quotes/{quote}"}),list:X({method:"GET",fullPath:"/v1/quotes",methodType:"list"}),accept:X({method:"POST",fullPath:"/v1/quotes/{quote}/accept"}),cancel:X({method:"POST",fullPath:"/v1/quotes/{quote}/cancel"}),finalizeQuote:X({method:"POST",fullPath:"/v1/quotes/{quote}/finalize"}),listComputedUpfrontLineItems:X({method:"GET",fullPath:"/v1/quotes/{quote}/computed_upfront_line_items",methodType:"list"}),listLineItems:X({method:"GET",fullPath:"/v1/quotes/{quote}/line_items",methodType:"list"}),pdf:X({method:"GET",fullPath:"/v1/quotes/{quote}/pdf",host:"files.stripe.com",streaming:!0})});var mt=n.method,pa=n.extend({create:mt({method:"POST",fullPath:"/v1/refunds"}),retrieve:mt({method:"GET",fullPath:"/v1/refunds/{refund}"}),update:mt({method:"POST",fullPath:"/v1/refunds/{refund}"}),list:mt({method:"GET",fullPath:"/v1/refunds",methodType:"list"}),cancel:mt({method:"POST",fullPath:"/v1/refunds/{refund}/cancel"})});var Go=n.method,fa=n.extend({retrieve:Go({method:"GET",fullPath:"/v1/reviews/{review}"}),list:Go({method:"GET",fullPath:"/v1/reviews",methodType:"list"}),approve:Go({method:"POST",fullPath:"/v1/reviews/{review}/approve"})});var yl=n.method,va=n.extend({list:yl({method:"GET",fullPath:"/v1/setup_attempts",methodType:"list"})});var fe=n.method,ga=n.extend({create:fe({method:"POST",fullPath:"/v1/setup_intents"}),retrieve:fe({method:"GET",fullPath:"/v1/setup_intents/{intent}"}),update:fe({method:"POST",fullPath:"/v1/setup_intents/{intent}"}),list:fe({method:"GET",fullPath:"/v1/setup_intents",methodType:"list"}),cancel:fe({method:"POST",fullPath:"/v1/setup_intents/{intent}/cancel"}),confirm:fe({method:"POST",fullPath:"/v1/setup_intents/{intent}/confirm"}),verifyMicrodeposits:fe({method:"POST",fullPath:"/v1/setup_intents/{intent}/verify_microdeposits"})});var Or=n.method,ya=n.extend({create:Or({method:"POST",fullPath:"/v1/shipping_rates"}),retrieve:Or({method:"GET",fullPath:"/v1/shipping_rates/{shipping_rate_token}"}),update:Or({method:"POST",fullPath:"/v1/shipping_rates/{shipping_rate_token}"}),list:Or({method:"GET",fullPath:"/v1/shipping_rates",methodType:"list"})});var ht=n.method,Pa=n.extend({create:ht({method:"POST",fullPath:"/v1/sources"}),retrieve:ht({method:"GET",fullPath:"/v1/sources/{source}"}),update:ht({method:"POST",fullPath:"/v1/sources/{source}"}),listSourceTransactions:ht({method:"GET",fullPath:"/v1/sources/{source}/source_transactions",methodType:"list"}),verify:ht({method:"POST",fullPath:"/v1/sources/{source}/verify"})});var pt=n.method,Ta=n.extend({create:pt({method:"POST",fullPath:"/v1/subscription_items"}),retrieve:pt({method:"GET",fullPath:"/v1/subscription_items/{item}"}),update:pt({method:"POST",fullPath:"/v1/subscription_items/{item}"}),list:pt({method:"GET",fullPath:"/v1/subscription_items",methodType:"list"}),del:pt({method:"DELETE",fullPath:"/v1/subscription_items/{item}"})});var ke=n.method,_a=n.extend({create:ke({method:"POST",fullPath:"/v1/subscription_schedules"}),retrieve:ke({method:"GET",fullPath:"/v1/subscription_schedules/{schedule}"}),update:ke({method:"POST",fullPath:"/v1/subscription_schedules/{schedule}"}),list:ke({method:"GET",fullPath:"/v1/subscription_schedules",methodType:"list"}),cancel:ke({method:"POST",fullPath:"/v1/subscription_schedules/{schedule}/cancel"}),release:ke({method:"POST",fullPath:"/v1/subscription_schedules/{schedule}/release"})});var Z=n.method,Sa=n.extend({create:Z({method:"POST",fullPath:"/v1/subscriptions"}),retrieve:Z({method:"GET",fullPath:"/v1/subscriptions/{subscription_exposed_id}"}),update:Z({method:"POST",fullPath:"/v1/subscriptions/{subscription_exposed_id}"}),list:Z({method:"GET",fullPath:"/v1/subscriptions",methodType:"list"}),cancel:Z({method:"DELETE",fullPath:"/v1/subscriptions/{subscription_exposed_id}"}),deleteDiscount:Z({method:"DELETE",fullPath:"/v1/subscriptions/{subscription_exposed_id}/discount"}),migrate:Z({method:"POST",fullPath:"/v1/subscriptions/{subscription}/migrate"}),resume:Z({method:"POST",fullPath:"/v1/subscriptions/{subscription}/resume"}),search:Z({method:"GET",fullPath:"/v1/subscriptions/search",methodType:"search"})});var Ea=n.method,xa=n.extend({retrieve:Ea({method:"GET",fullPath:"/v1/tax_codes/{id}"}),list:Ea({method:"GET",fullPath:"/v1/tax_codes",methodType:"list"})});var br=n.method,wa=n.extend({create:br({method:"POST",fullPath:"/v1/tax_ids"}),retrieve:br({method:"GET",fullPath:"/v1/tax_ids/{id}"}),list:br({method:"GET",fullPath:"/v1/tax_ids",methodType:"list"}),del:br({method:"DELETE",fullPath:"/v1/tax_ids/{id}"})});var Rr=n.method,Oa=n.extend({create:Rr({method:"POST",fullPath:"/v1/tax_rates"}),retrieve:Rr({method:"GET",fullPath:"/v1/tax_rates/{tax_rate}"}),update:Rr({method:"POST",fullPath:"/v1/tax_rates/{tax_rate}"}),list:Rr({method:"GET",fullPath:"/v1/tax_rates",methodType:"list"})});var ba=n.method,Ra=n.extend({create:ba({method:"POST",fullPath:"/v1/tokens"}),retrieve:ba({method:"GET",fullPath:"/v1/tokens/{token}"})});var ft=n.method,Aa=n.extend({create:ft({method:"POST",fullPath:"/v1/topups"}),retrieve:ft({method:"GET",fullPath:"/v1/topups/{topup}"}),update:ft({method:"POST",fullPath:"/v1/topups/{topup}"}),list:ft({method:"GET",fullPath:"/v1/topups",methodType:"list"}),cancel:ft({method:"POST",fullPath:"/v1/topups/{topup}/cancel"})});var ae=n.method,Ca=n.extend({create:ae({method:"POST",fullPath:"/v1/transfers"}),retrieve:ae({method:"GET",fullPath:"/v1/transfers/{transfer}"}),update:ae({method:"POST",fullPath:"/v1/transfers/{transfer}"}),list:ae({method:"GET",fullPath:"/v1/transfers",methodType:"list"}),createReversal:ae({method:"POST",fullPath:"/v1/transfers/{id}/reversals"}),listReversals:ae({method:"GET",fullPath:"/v1/transfers/{id}/reversals",methodType:"list"}),retrieveReversal:ae({method:"GET",fullPath:"/v1/transfers/{transfer}/reversals/{id}"}),updateReversal:ae({method:"POST",fullPath:"/v1/transfers/{transfer}/reversals/{id}"})});var vt=n.method,Ia=n.extend({create:vt({method:"POST",fullPath:"/v1/webhook_endpoints"}),retrieve:vt({method:"GET",fullPath:"/v1/webhook_endpoints/{webhook_endpoint}"}),update:vt({method:"POST",fullPath:"/v1/webhook_endpoints/{webhook_endpoint}"}),list:vt({method:"GET",fullPath:"/v1/webhook_endpoints",methodType:"list"}),del:vt({method:"DELETE",fullPath:"/v1/webhook_endpoints/{webhook_endpoint}"})});var Pl=b("apps",{Secrets:Zn}),Tl=b("billing",{Alerts:Vs,CreditBalanceSummary:tn,CreditBalanceTransactions:on,CreditGrants:sn,MeterEventAdjustments:Pn,MeterEvents:En,Meters:wn}),_l=b("billingPortal",{Configurations:Xs,Sessions:ei}),Sl=b("checkout",{Sessions:ti}),El=b("climate",{Orders:On,Products:Gn,Suppliers:ai}),xl=b("entitlements",{ActiveEntitlements:$s,Features:pn}),wl=b("financialConnections",{Accounts:Us,Sessions:oi,Transactions:hi}),Ol=b("forwarding",{Requests:Yn}),bl=b("identity",{VerificationReports:Si,VerificationSessions:Ei}),Rl=b("issuing",{Authorizations:Ks,Cardholders:Ws,Cards:Js,Disputes:ln,PersonalizationDesigns:In,PhysicalBundles:Nn,Tokens:li,Transactions:pi}),Al=b("radar",{EarlyFraudWarnings:dn,ValueListItems:Pi,ValueLists:Ti}),Cl=b("reporting",{ReportRuns:zn,ReportTypes:Jn}),Il=b("sigma",{ScheduledQueryRuns:Qn}),Ml=b("tax",{Calculations:zs,Registrations:Bn,Settings:ni,Transactions:fi}),kl=b("terminal",{Configurations:Qs,ConnectionTokens:en,Locations:yn,Readers:Hn}),Nl=b("testHelpers",{ConfirmationTokens:Zs,Customers:an,Refunds:Kn,TestClocks:ci,Issuing:b("issuing",{Authorizations:Bs,Cards:Ys,PersonalizationDesigns:Mn,Transactions:vi}),Terminal:b("terminal",{Readers:Ln}),Treasury:b("treasury",{InboundTransfers:vn,OutboundPayments:bn,OutboundTransfers:An,ReceivedCredits:qn,ReceivedDebits:Fn})}),Dl=b("treasury",{CreditReversals:nn,DebitReversals:cn,FinancialAccounts:fn,InboundTransfers:gn,OutboundPayments:Rn,OutboundTransfers:Cn,ReceivedCredits:Un,ReceivedDebits:Vn,TransactionEntries:di,Transactions:yi}),Gl=b("v2",{Billing:b("billing",{MeterEventAdjustments:Tn,MeterEventSession:_n,MeterEventStream:Sn,MeterEvents:xn}),Core:b("core",{EventDestinations:mn,Events:hn})});var Ma="api.stripe.com",ka="443",Na="/v1/",Da=To,Ga=8e4,Ha=5,La=.5,Hl=["name","version","url","partner_id"],qa=["authenticator","apiVersion","typescript","maxNetworkRetries","httpAgent","httpClient","timeout","host","port","protocol","telemetry","appInfo","stripeAccount","stripeContext"],Ll=t=>new sr(t,n.MAX_BUFFERED_REQUEST_METRICS);function ja(t,e=Ll){r.PACKAGE_VERSION="18.5.0",r.API_VERSION=To,r.USER_AGENT=Object.assign({bindings_version:r.PACKAGE_VERSION,lang:"node",publisher:"stripe",uname:null,typescript:!1},Is()),r.StripeResource=n,r.resources=Ne,r.HttpClient=D,r.HttpClientResponse=oe,r.CryptoProvider=re,r.webhooks=js(t);function r(o,s={}){if(!(this instanceof r))return new r(o,s);let i=this._getPropsFromConfig(s);this._platformFunctions=t,Object.defineProperty(this,"_emitter",{value:this._platformFunctions.createEmitter(),enumerable:!1,configurable:!1,writable:!1}),this.VERSION=r.PACKAGE_VERSION,this.on=this._emitter.on.bind(this._emitter),this.once=this._emitter.once.bind(this._emitter),this.off=this._emitter.removeListener.bind(this._emitter);let a=i.httpAgent||null;this._api={host:i.host||Ma,port:i.port||ka,protocol:i.protocol||"https",basePath:Na,version:i.apiVersion||Da,timeout:Bt("timeout",i.timeout,Ga),maxNetworkRetries:Bt("maxNetworkRetries",i.maxNetworkRetries,2),agent:a,httpClient:i.httpClient||(a?this._platformFunctions.createNodeHttpClient(a):this._platformFunctions.createDefaultHttpClient()),dev:!1,stripeAccount:i.stripeAccount||null,stripeContext:i.stripeContext||null};let l=i.typescript||!1;l!==r.USER_AGENT.typescript&&(r.USER_AGENT.typescript=l),i.appInfo&&this._setAppInfo(i.appInfo),this._prepResources(),this._setAuthenticator(o,i.authenticator),this.errors=rr,this.webhooks=r.webhooks,this._prevRequestMetrics=[],this._enableTelemetry=i.telemetry!==!1,this._requestSender=e(this),this.StripeResource=r.StripeResource}return r.errors=rr,r.createNodeHttpClient=t.createNodeHttpClient,r.createFetchHttpClient=t.createFetchHttpClient,r.createNodeCryptoProvider=t.createNodeCryptoProvider,r.createSubtleCryptoProvider=t.createSubtleCryptoProvider,r.prototype={_appInfo:void 0,on:null,off:null,once:null,VERSION:null,StripeResource:null,webhooks:null,errors:null,_api:null,_prevRequestMetrics:null,_emitter:null,_enableTelemetry:null,_requestSender:null,_platformFunctions:null,rawRequest(o,s,i,a){return this._requestSender._rawRequest(o,s,i,a)},_setAuthenticator(o,s){if(o&&s)throw new Error("Can't specify both apiKey and authenticator");if(!o&&!s)throw new Error("Neither apiKey nor config.authenticator provided");this._authenticator=o?Ft(o):s},_setAppInfo(o){if(o&&typeof o!="object")throw new Error("AppInfo must be an object.");if(o&&!o.name)throw new Error("AppInfo.name is required");o=o||{},this._appInfo=Hl.reduce((s,i)=>(typeof o[i]=="string"&&(s=s||{},s[i]=o[i]),s),{})},_setApiField(o,s){this._api[o]=s},getApiField(o){return this._api[o]},setClientId(o){this._clientId=o},getClientId(){return this._clientId},getConstant:o=>{switch(o){case"DEFAULT_HOST":return Ma;case"DEFAULT_PORT":return ka;case"DEFAULT_BASE_PATH":return Na;case"DEFAULT_API_VERSION":return Da;case"DEFAULT_TIMEOUT":return Ga;case"MAX_NETWORK_RETRY_DELAY_SEC":return Ha;case"INITIAL_NETWORK_RETRY_DELAY_SEC":return La}return r[o]},getMaxNetworkRetries(){return this.getApiField("maxNetworkRetries")},_setApiNumberField(o,s,i){let a=Bt(o,s,i);this._setApiField(o,a)},getMaxNetworkRetryDelay(){return Ha},getInitialNetworkRetryDelay(){return La},getClientUserAgent(o){return this.getClientUserAgentSeeded(r.USER_AGENT,o)},getClientUserAgentSeeded(o,s){this._platformFunctions.getUname().then(i=>{var a;let l={};for(let u in o)Object.prototype.hasOwnProperty.call(o,u)&&(l[u]=encodeURIComponent((a=o[u])!==null&&a!==void 0?a:"null"));l.uname=encodeURIComponent(i||"UNKNOWN");let c=this.getApiField("httpClient");c&&(l.httplib=encodeURIComponent(c.getClientName())),this._appInfo&&(l.application=this._appInfo),s(JSON.stringify(l))})},getAppInfoAsString(){if(!this._appInfo)return"";let o=this._appInfo.name;return this._appInfo.version&&(o+=`/${this._appInfo.version}`),this._appInfo.url&&(o+=` (${this._appInfo.url})`),o},getTelemetryEnabled(){return this._enableTelemetry},_prepResources(){for(let o in Ne)Object.prototype.hasOwnProperty.call(Ne,o)&&(this[As(o)]=new Ne[o](this))},_getPropsFromConfig(o){if(!o)return{};let s=typeof o=="string";if(!(o===Object(o)&&!Array.isArray(o))&&!s)throw new Error("Config must either be an object or a string");if(s)return{apiVersion:o};if(Object.keys(o).filter(l=>!qa.includes(l)).length>0)throw new Error(`Config object may only contain the following: ${qa.join(", ")}`);return o},parseThinEvent(o,s,i,a,l,c){return this.webhooks.constructEvent(o,s,i,a,l,c)}},r}var ql=ja(new or),Ua=ql;var j=class{constructor(e,r){this.stripe=new Ua(e),this.siteUrl=r}async createProduct(e){let r=Array.isArray(e.images)?e.images:e.imageUrl?[e.imageUrl]:[],o={name:e.name,images:r.slice(0,8),type:"good",tax_code:"txcd_99999999"};return e.description&&String(e.description).trim()!==""&&(o.description=String(e.description)),await this.stripe.products.create(o)}async updateProduct(e,r){let o={name:r.name,images:r.images?.slice(0,8)||[]};if(typeof r.description=="string"){let s=r.description.trim();s&&(o.description=s)}return await this.stripe.products.update(e,o)}async archiveProduct(e){return await this.stripe.products.update(e,{active:!1})}async createPrice(e){return await this.stripe.prices.create({unit_amount:Math.round(e.amount*100),currency:e.currency,product:e.productId,nickname:e.nickname,metadata:e.metadata||{}})}async archivePrice(e){return await this.stripe.prices.update(e,{active:!1})}async createCheckoutSession(e){return await this.stripe.checkout.sessions.create({payment_method_types:["card"],line_items:[{price:e,quantity:1}],mode:"payment",shipping_address_collection:{allowed_countries:Rt},billing_address_collection:"required",success_url:`${this.siteUrl}/success?session_id={CHECKOUT_SESSION_ID}`,cancel_url:`${this.siteUrl}/`})}async createCartCheckoutSession(e){let r=e.map(s=>({price:s.stripePriceId,quantity:s.quantity||1})),o={order_type:"cart_checkout",item_count:e.length.toString(),total_quantity:e.reduce((s,i)=>s+i.quantity,0).toString()};return e.forEach((s,i)=>{let a=s.name||`Item ${i+1}`;o[`item_${i}_name`]=a,s.selectedVariant?.name&&(o[`item_${i}_variant1`]=s.selectedVariant.name),s.selectedVariant2?.name&&(o[`item_${i}_variant2`]=s.selectedVariant2.name)}),await this.stripe.checkout.sessions.create({payment_method_types:["card"],line_items:r,mode:"payment",shipping_address_collection:{allowed_countries:Rt},billing_address_collection:"required",success_url:`${this.siteUrl}/success?session_id={CHECKOUT_SESSION_ID}`,cancel_url:`${this.siteUrl}/`,metadata:o})}async getCheckoutSession(e){let r=await this.stripe.checkout.sessions.retrieve(e);return{id:r.id,amount_total:r.amount_total,currency:r.currency,customer_email:r.customer_details?.email,payment_status:r.payment_status,created:r.created}}async listCheckoutSessions(e={}){let r={limit:Math.min(e.limit||25,50)};return e.cursor&&(e.direction==="prev"?r.ending_before=e.cursor:r.starting_after=e.cursor),await this.stripe.checkout.sessions.list(r)}async getCheckoutSessionLineItems(e){return await this.stripe.checkout.sessions.listLineItems(e,{limit:100,expand:["data.price"]})}async getPaymentIntent(e){return await this.stripe.paymentIntents.retrieve(e,{expand:["shipping"]})}async listPaymentIntents(e){return await this.stripe.paymentIntents.list({created:{gte:Math.floor(e.getTime()/1e3)},limit:100})}};var Ar=new E;Ar.post("/create-checkout-session",T(async t=>{let{priceId:e}=await t.req.json();if(!e||typeof e!="string")throw new x("Valid price ID is required");let r=e.trim();if(r.length===0)throw new x("Valid price ID is required");if(!r.startsWith("price_"))throw new x("Invalid price ID format");if(r.length>255)throw new x("Price ID is too long");let s=await new j(t.env.STRIPE_SECRET_KEY,t.env.SITE_URL).createCheckoutSession(r);return t.json({sessionId:s.id})}));Ar.post("/create-cart-checkout-session",T(async t=>{let{items:e}=await t.req.json();if(!e||!Array.isArray(e)||e.length===0)throw new x("Cart items are required");if(e.length>100)throw new x("Cart size exceeds maximum allowed items");let r=e.map((i,a)=>{if(!i||typeof i!="object")throw new x(`Invalid cart item format at index ${a}`);let l=i.stripePriceId||i.priceId;if(!l||typeof l!="string"||!l.startsWith("price_"))throw new x(`Invalid price ID in cart item at index ${a}`);let c=i.quantity;if(c==null&&(c=1),c=Number.parseInt(c,10),!Number.isInteger(c)||c<1||c>100)throw new x(`Invalid quantity in cart item at index ${a} (must be 1-100, got ${c})`);return{...i,stripePriceId:l.trim(),quantity:c}}),s=await new j(t.env.STRIPE_SECRET_KEY,t.env.SITE_URL).createCartCheckoutSession(r);return t.json({sessionId:s.id})}));Ar.get("/checkout-session/:sessionId",T(async t=>{let e=t.req.param("sessionId");if(!e||typeof e!="string")throw new x("Invalid session ID format");let r=e.trim();if(!r.startsWith("cs_"))throw new x("Invalid session ID format");if(r.length>255)throw new x("Session ID is too long");let s=await new j(t.env.STRIPE_SECRET_KEY,t.env.SITE_URL).getCheckoutSession(r);return t.json(s)}));var Fa=Ar;var $a=new E;$a.get("/",T(async t=>{let e=t.req.query("src");if(!e)throw new x("Missing src");let r;try{let a=new URL(e);if(!zr.some(c=>a.hostname===c||a.hostname.endsWith("."+c)))throw new x("Host not allowed");if(a.hostname.endsWith("drive.google.com")){let c=a.pathname.match(/\/file\/d\/([a-zA-Z0-9_-]+)/),u=a.searchParams.get("id"),d=c&&c[1]||u;if(!d)throw new x("Missing Google Drive file id");r=`https://drive.usercontent.google.com/download?id=${d}&export=view`}else if(a.hostname.endsWith("drive.usercontent.google.com")){let c=a.searchParams.get("id");if(!c)throw new x("Missing Google Drive file id");let u=new URL("https://drive.usercontent.google.com/download");u.searchParams.set("id",c),u.searchParams.set("export","view"),r=u.toString()}else r=a.toString()}catch(a){throw a instanceof x?a:new x("Invalid src url")}let o=await fetch(r,{redirect:"follow",headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123 Safari/537.36",Accept:"image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8","Accept-Language":"en-US,en;q=0.9",Referer:"https://drive.google.com/"},cf:{cacheEverything:!0}});if(!o.ok)throw new Error(`Upstream error: ${o.status}`);let s=new Headers,i=o.headers.get("content-type")||"image/jpeg";return s.set("Content-Type",i),s.set("Cache-Control","public, max-age=86400"),s.set("Access-Control-Allow-Origin","*"),s.set("Cross-Origin-Resource-Policy","cross-origin"),new Response(o.body,{headers:s})}));var Va=$a;var Ka=new E;Ka.get("/",T(async t=>{let e=_(t.env),o=await new W(e).getSettings();return t.json(o)}));var Ba=Ka,Ho=new E;Ho.get("/",T(async t=>{let e=_(t.env),o=await new W(e).getContactEmail();return t.json(o)}));var De=class{constructor(e){this.env=e,this.bucket=e.IMAGES}async uploadFile(e,r,o){if(!this.bucket)throw new Error("R2 bucket not configured");let s=atob(r),i=new Uint8Array(s.length);for(let u=0;u{let e=t.req.param("key"),r=new De(t.env);try{let o=await r.getFile(e);if(!o)return t.notFound();let s=new Headers;return o.writeHttpMetadata(s),s.set("etag",o.httpEtag),s.set("Cache-Control","public, max-age=31536000, immutable"),new Response(o.body,{headers:s})}catch(o){return console.error("Error fetching image:",o),t.notFound()}});var Wa=za;var Ja=new E;Ja.post("/login",T(async t=>{let{password:e}=await t.req.json();if(!e||typeof e!="string")throw new x("Password is required");let r=_(t.env),s=`rate_limit:login:${t.req.header("CF-Connecting-IP")||t.req.header("X-Forwarded-For")||"unknown"}`,i=await r.get(s),a=i?parseInt(i,10):0;if(a>=5)throw new Mt("Too many login attempts. Please try again later.");let l=`${Q.ADMIN_TOKEN_PREFIX}password_hash`,c=await r.get(l),u=t.env.ADMIN_PASSWORD||"admin123";if(c||(c=await ls(u),await r.put(l,c)),!await cs(e,c))throw await r.put(s,(a+1).toString(),{expirationTtl:900}),new It("Invalid password");await r.delete(s);let m=Dt(),h=await Gt(m);return await r.put(`${Q.ADMIN_TOKEN_PREFIX}${h}`,Date.now().toString(),{expirationTtl:Wr}),t.json({token:m})}));var Ya=Ja;var gt=class{constructor(e){this.stripe=e}async createProductWithPrices(e){let r=await this.stripe.createProduct({name:e.name,description:e.description,images:Array.isArray(e.images)?e.images:e.imageUrl?[e.imageUrl]:[]}),o=Array.isArray(e.variants)?e.variants:[],s=Array.isArray(e.variants2)?e.variants2:[],i=null,a={};if(o.length===0&&s.length===0)i=await this.stripe.createPrice({amount:e.price,currency:e.currency,productId:r.id,nickname:`${e.name} - Base`,metadata:{price_type:"base",product_name:e.name}});else{let l=[];if(o.length>0&&s.length>0)for(let c of o)for(let u of s){let d=`${e.name} - ${c.name} - ${u.name}`,m=c.hasCustomPrice&&c.price?c.price:u.hasCustomPrice&&u.price?u.price:e.price;l.push({name:d,price:m,variant1:c,variant2:u,description:d,variantCombo:`${c.id||c.name}-${u.id||u.name}`})}else if(o.length>0)for(let c of o){let u=`${e.name} - ${c.name}`,d=c.hasCustomPrice&&c.price?c.price:e.price;l.push({name:u,price:d,variant1:c,description:u,variantCombo:`${c.id||c.name}`})}else if(s.length>0)for(let c of s){let u=`${e.name} - ${c.name}`,d=c.hasCustomPrice&&c.price?c.price:e.price;l.push({name:u,price:d,variant2:c,description:u,variantCombo:`${c.id||c.name}`})}for(let c of l){let u=await this.stripe.createPrice({amount:c.price,currency:e.currency,productId:r.id,nickname:c.name,metadata:{price_type:"variant_combo",product_name:e.name,variant1_name:c.variant1?.name||"",variant2_name:c.variant2?.name||"",variant1_id:c.variant1?.id||"",variant2_id:c.variant2?.id||"",variant1_style:e.variantStyle||"Variant",variant2_style:e.variantStyle2||"Variant",variant_combo:c.variantCombo}});c.variant1&&c.variant2?a[`${c.variant1.id}-${c.variant2.id}`]=u.id:c.variant1?a[c.variant1.id]=u.id:c.variant2&&(a[c.variant2.id]=u.id)}i=await this.stripe.createPrice({amount:e.price,currency:e.currency,productId:r.id,nickname:`${e.name} - Base`,metadata:{price_type:"base",product_name:e.name}})}return{stripeProduct:r,basePrice:i,variantPrices:a}}async updateProductVariants(e,r,o){let s=r.stripePriceId||e.stripePriceId,i=[],a=[];if(Array.isArray(r.variants)){let l=r.variants,c=Array.isArray(e.variants)?e.variants:[];for(let u of l){let d=u.id?c.find(h=>h.id===u.id):void 0;if(!!u.hasCustomPrice&&typeof u.price=="number"&&u.price>0){let h=Math.round(u.price*100),p=d?.stripePriceId,f=!!d?.hasCustomPrice&&typeof d?.price=="number",v=f?Math.round(d.price*100):null;if(!p||!f||v!==h){let g=await o.createPrice({amount:u.price,currency:r.currency||e.currency,productId:e.stripeProductId,nickname:`${r.name||e.name} - ${u.name}`,metadata:{price_type:"variant_primary",variant_id:u.id||"",variant_name:u.name||""}});if(d?.stripePriceId&&f)try{await o.archivePrice(d.stripePriceId)}catch{}p=g.id}i.push({...u,stripePriceId:p,hasCustomPrice:!0})}else{if(d?.stripePriceId&&d?.hasCustomPrice)try{await o.archivePrice(d.stripePriceId)}catch{}i.push({...u,stripePriceId:s,hasCustomPrice:!1,price:void 0})}}}if(Array.isArray(r.variants2)){let l=r.variants2,c=Array.isArray(e.variants2)?e.variants2:[];for(let u of l){let d=u.id?c.find(h=>h.id===u.id):void 0;if(!!u.hasCustomPrice&&typeof u.price=="number"&&u.price>0){let h=Math.round(u.price*100),p=d?.stripePriceId,f=!!d?.hasCustomPrice&&typeof d?.price=="number",v=f?Math.round(d.price*100):null;if(!p||!f||v!==h){let g=await o.createPrice({amount:u.price,currency:r.currency||e.currency,productId:e.stripeProductId,nickname:`${r.name||e.name}${r.variantStyle2||e.variantStyle2?` - ${r.variantStyle2||e.variantStyle2}: ${u.name}`:` - ${u.name}`}`,metadata:{price_type:"variant_secondary",variant_id:u.id||"",variant_name:u.name||"",variant2_name:u.name||""}});if(d?.stripePriceId&&f)try{await o.archivePrice(d.stripePriceId)}catch{}p=g.id}a.push({...u,stripePriceId:p,hasCustomPrice:!0})}else{if(d?.stripePriceId&&d?.hasCustomPrice)try{await o.archivePrice(d.stripePriceId)}catch{}a.push({...u,stripePriceId:s,hasCustomPrice:!1,price:void 0})}}}return{variants:i.length>0?i:e.variants,variants2:a.length>0?a:e.variants2}}};var Ge=new E;Ge.get("/",T(async t=>{let e=_(t.env),o=await new L(e).getAllProductsAdmin();return t.json(o)}));Ge.post("/",T(async t=>{let e=await t.req.json(),r=_(t.env),o=new L(r),s=new j(t.env.STRIPE_SECRET_KEY,t.env.SITE_URL),i=new gt(s),{stripeProduct:a,basePrice:l,variantPrices:c}=await i.createProductWithPrices(e),u={...e,stripePriceId:l?.id||Object.values(c)[0]||"",stripeProductId:a.id,variantPrices:c,variants:Array.isArray(e.variants)?e.variants:[],variants2:Array.isArray(e.variants2)?e.variants2:[]},d=await o.createProduct(u);return t.json(d,201)}));Ge.get("/:id",T(async t=>{let e=_(t.env),o=await new L(e).getProduct(t.req.param("id"));return t.json(o)}));Ge.put("/:id",T(async t=>{let e=await t.req.json(),r=_(t.env),o=new L(r),s=new j(t.env.STRIPE_SECRET_KEY,t.env.SITE_URL),i=new gt(s),a=await o.getProduct(t.req.param("id"));if(e.name||e.description!==void 0||e.images||e.imageUrl){let c=Array.isArray(e.images)?e.images:e.imageUrl?[e.imageUrl]:Array.isArray(a.images)?a.images:a.imageUrl?[a.imageUrl]:[];await s.updateProduct(a.stripeProductId,{name:e.name||a.name,description:e.description,images:c.slice(0,8)})}if(typeof e.price<"u"&&e.price!==a.price){let c=typeof e.price=="number"?e.price:parseFloat(String(e.price)),u=await s.createPrice({amount:c,currency:e.currency||a.currency,productId:a.stripeProductId,nickname:`${e.name||a.name} - Base`,metadata:{}});a.stripePriceId&&await s.archivePrice(a.stripePriceId),e.stripePriceId=u.id,e.price=c}if(Array.isArray(e.variants)||Array.isArray(e.variants2)){let c=await i.updateProductVariants(a,e,s);e.variants=c.variants,e.variants2=c.variants2}let l=await o.updateProduct(t.req.param("id"),e);return t.json(l)}));Ge.delete("/:id",T(async t=>{let e=_(t.env),r=new L(e),o=new j(t.env.STRIPE_SECRET_KEY,t.env.SITE_URL),s=await r.getProduct(t.req.param("id"));return s.stripePriceId&&await o.archivePrice(s.stripePriceId),s.stripeProductId&&await o.archiveProduct(s.stripeProductId),await r.deleteProduct(t.req.param("id")),t.json({success:!0})}));var Xa=Ge;var He=new E;He.get("/",T(async t=>{let e=_(t.env),o=await new F(e).getAllCollectionsAdmin();return t.json(o)}));He.post("/",T(async t=>{let e=await t.req.json(),r=_(t.env),s=await new F(r).createCollection(e);return t.json(s,201)}));He.get("/:id",T(async t=>{let e=_(t.env),o=await new F(e).getCollection(t.req.param("id"));return t.json(o)}));He.put("/:id",T(async t=>{let e=await t.req.json(),r=_(t.env),s=await new F(r).updateCollection(t.req.param("id"),e);return t.json(s)}));He.delete("/:id",T(async t=>{let e=_(t.env);return await new F(e).deleteCollection(t.req.param("id")),t.json({success:!0})}));var Qa=He;var yt=class{constructor(e){this.stripe=e}async getAnalytics(e="30d"){let o={"1d":1,"7d":7,"30d":30,"90d":90,"1y":365}[e]||30,s=new Date,i=new Date(s.getTime()-o*24*60*60*1e3),l=(await this.stripe.listPaymentIntents(i)).data.filter(h=>h.status==="succeeded"),c=l.reduce((h,p)=>h+p.amount,0)/100,u=l.length,d=u>0?c/u:0,m=[];if(e==="1d"){let h={},p={};l.forEach(y=>{let O=new Date(y.created*1e3),P=new Date(O);P.setMinutes(0,0,0);let S=P.toISOString();h[S]=(h[S]||0)+1,p[S]=(p[S]||0)+y.amount/100});let f=new Date(s);f.setMinutes(0,0,0);let v=new Date(f.getTime()-23*60*60*1e3),g=new Date(v);for(;g<=f;){let y=new Date(g).toISOString();m.push({date:y,orders:h[y]||0,revenue:Math.round(((p[y]||0)+Number.EPSILON)*100)/100,formattedDate:new Date(g).toLocaleTimeString("en-US",{hour:"numeric"})}),g.setHours(g.getHours()+1)}}else{let h={},p={};l.forEach(v=>{let g=new Date(v.created*1e3).toISOString().split("T")[0];h[g]=(h[g]||0)+1,p[g]=(p[g]||0)+v.amount/100});let f=new Date(i);for(;f<=s;){let v=f.toISOString().split("T")[0];m.push({date:v,orders:h[v]||0,revenue:p[v]||0,formattedDate:f.toLocaleDateString("en-US",{month:"short",day:"numeric"})}),f.setDate(f.getDate()+1)}}return{period:e,totalRevenue:Math.round(c*100)/100,totalOrders:u,averageOrderValue:Math.round(d*100)/100,chartData:m,recentOrders:[],dateRange:{start:i.toISOString(),end:s.toISOString()}}}async getOrders(e={}){let r=Math.min(e.limit||25,50),o=e.direction||"next",s=e.cursor,i=e.showFulfilled===!0,a={limit:r};s&&(o==="prev"?a.ending_before=s:a.starting_after=s);let l=await this.stripe.listCheckoutSessions(a),c=[];for(let p of l.data)if(p.payment_status==="paid"||p.status==="complete"||p.status==="completed"){let f=!0;if(e.kvNamespace){let v=`order_fulfillment:${p.id}`,g=await e.kvNamespace.get(v),y=g?JSON.parse(g):{fulfilled:!1};i?y.fulfilled||(f=!1):y.fulfilled&&(f=!1)}f&&c.push(p)}let u=c.reverse(),d=[];for(let p of u)try{let f=await this.stripe.getCheckoutSessionLineItems(p.id),v=null;if(p.shipping_details)v=p.shipping_details;else if(p.payment_intent)try{let P=await this.stripe.getPaymentIntent(p.payment_intent);P.shipping&&(v={address:P.shipping.address,name:P.shipping.name})}catch(P){console.log("Error fetching payment intent shipping:",P.message)}let g=`order_fulfillment:${p.id}`,y=e.kvNamespace?await e.kvNamespace.get(g):null,O=y?JSON.parse(y):{fulfilled:!1,fulfilledAt:null,fulfilledBy:null};d.push({id:p.id,created:p.created,amount_total:p.amount_total,currency:p.currency,customer_email:p.customer_details?.email||p.customer_email||null,customer_name:p.customer_details?.name||null,shipping:v,payment_intent:p.payment_intent||null,billing:{name:p.customer_details?.name||null,email:p.customer_details?.email||null,address:p.customer_details?.address||null},fulfillment:O,items:f.data.map(P=>{let S=P.price?.nickname||"",N="Unknown Product",$="",R="";if(S.includes(" - ")){let G=S.split(" - ");N=G[0],G.length>=2&&($=G[1]),G.length>=3&&(R=G[2])}else N=S;return{id:P.id,description:N,quantity:P.quantity,amount_total:P.amount_total,currency:P.currency,price_nickname:S,variant1_name:$||P.price?.metadata?.variant1_name||null,variant1_style:P.price?.metadata?.variant1_style||"Variant",variant2_name:R||P.price?.metadata?.variant2_name||null,variant2_style:P.price?.metadata?.variant2_style||"Variant"}})})}catch(f){console.error("Error fetching line items for session",p.id,f);let v={fulfilled:!1,fulfilledAt:null,fulfilledBy:null};if(e.kvNamespace){let g=`order_fulfillment:${p.id}`,y=await e.kvNamespace.get(g);v=y?JSON.parse(y):{fulfilled:!1,fulfilledAt:null,fulfilledBy:null}}d.push({id:p.id,created:p.created,amount_total:p.amount_total,currency:p.currency,customer_email:p.customer_details?.email||p.customer_email||null,customer_name:p.customer_details?.name||null,shipping:p.shipping_details||null,billing:{name:p.customer_details?.name||null,email:p.customer_details?.email||null,address:p.customer_details?.address||null},fulfillment:v,items:[]})}let m=u.length>0?u[0].id:null,h=u.length>0?u[u.length-1].id:null;return{limit:r,orders:d,cursors:{next:m,prev:h},has_more:l.has_more}}};var Cr=new E;Cr.get("/",T(async t=>{let e=t.req.query("period")||"30d",r=new j(t.env.STRIPE_SECRET_KEY,t.env.SITE_URL),s=await new yt(r).getAnalytics(e);return t.json(s)}));Cr.get("/orders",T(async t=>{let e=Math.min(parseInt(t.req.query("limit")||"25",10),50),r=t.req.query("direction")||"next",o=t.req.query("cursor")||void 0,s=t.req.query("showFulfilled")==="true",i=new j(t.env.STRIPE_SECRET_KEY,t.env.SITE_URL),a=new yt(i),l=_(t.env),c=await a.getOrders({limit:e,direction:r,cursor:o,showFulfilled:s,kvNamespace:l});return t.json(c)}));Cr.post("/orders/:orderId/fulfill",T(async t=>{let e=t.req.param("orderId"),r=_(t.env);if(!r)throw new Error("KV namespace not available");let o=`order_fulfillment:${e}`,s={fulfilled:!0,fulfilledAt:new Date().toISOString(),fulfilledBy:"admin"};return await r.put(o,JSON.stringify(s)),t.json({success:!0,fulfillment:s})}));var Za=Cr;var Le=class{constructor(e){this.kv=new z(e)}generateServerId(){let e=Nt(4);return`${Date.now().toString(36)}-${e}`}async getAllMediaItems(){return[...await this.kv.getAllMediaItems()].sort((r,o)=>(o.createdAt||0)-(r.createdAt||0))}async createMediaItem(e){let r={id:e.id||this.generateServerId(),url:String(e.url||""),source:e.source||"link",filename:e.filename||"",mimeType:e.mimeType||"",driveFileId:e.driveFileId||"",createdAt:typeof e.createdAt=="number"?e.createdAt:Date.now()};return await this.kv.createMediaItem(r)}async deleteMediaItem(e){await this.kv.deleteMediaItem(e)}};var Ir=new E;Ir.get("/",T(async t=>{let e=_(t.env),o=await new Le(e).getAllMediaItems();return t.json(o)}));Ir.post("/",T(async t=>{let e=await t.req.json(),r=e?.url;if(!r||typeof r!="string"||r.trim()==="")throw new x("url is required");let o=_(t.env),i=await new Le(o).createMediaItem(e);return t.json(i,201)}));Ir.delete("/:id",T(async t=>{let e=t.req.param("id");if(!e)throw new x("Missing id");let r=_(t.env);return await new Le(r).deleteMediaItem(e),t.json({success:!0})}));var ec=Ir;var tc=new E;tc.post("/upload",T(async t=>{let{mimeType:e,dataBase64:r,filename:o}=await t.req.json();if(!e||!r)throw new x("Missing mimeType or dataBase64");let i=await new De(t.env).uploadFile(e,r,o||"image");return t.json(i)}));var rc=tc;function oc(t){return typeof t!="string"?!1:/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t.trim())}function sc(t,e,r){let o=Number(t);return Number.isFinite(o)&&o>=e&&o<=r}function Lo(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}var jl=new Set(oo.map(t=>t.id));function nc(t){if(!Lo(t))return{valid:!1,message:"Invalid theme payload"};let e=t.colors;if(!Lo(e))return{valid:!1,message:"Missing colors object"};for(let o of Yr){let s=typeof e[o]=="string"?e[o].trim():"";if(!oc(s))return{valid:!1,message:`Invalid ${o} color`}}let r=t.typography?.fontId??t.typography?.font??t.fontId??t.font;if(r&&!jl.has(r))return{valid:!1,message:"Invalid font selection"};if(t.corners){if(t.corners.radiusMultiplier!==void 0&&!sc(t.corners.radiusMultiplier,At,Ct))return{valid:!1,message:`Radius multiplier must be between ${At} and ${Ct}`};if(t.corners.enabled!==void 0&&typeof t.corners.enabled!="boolean")return{valid:!1,message:"Corners enabled must be a boolean"}}return{valid:!0}}var qe=new E;qe.get("/storefront/theme",T(async t=>{let r=await new te(t.env).getTheme();return t.json(r)}));qe.put("/storefront/theme",T(async t=>{let e=await t.req.json(),r=nc(e);if(!r.valid)throw new x(r.message);let s=await new te(t.env).updateTheme(e);return t.json(s)}));qe.delete("/storefront/theme",T(async t=>{let r=await new te(t.env).resetTheme();return t.json(r)}));qe.get("/store-settings",T(async t=>{let e=_(t.env),o=await new W(e).getSettings();return(o.productLimit===null||o.productLimit===void 0||o.productLimit==="")&&t.env.PRODUCT_LIMIT&&(o.productLimit=t.env.PRODUCT_LIMIT),t.json(o)}));qe.put("/store-settings",T(async t=>{let e=await t.req.json(),r=_(t.env),s=await new W(r).updateSettings(e);return t.json(s)}));var ic=qe;var ac=new E;ac.post("/generate-image",T(async t=>{let{prompt:e,inputs:r}=await t.req.json();if(!e||typeof e!="string")throw new x("Missing prompt");let o=t.env.GEMINI_API_KEY;if(!o)throw new Error("GEMINI_API_KEY not configured");let s=[];if(s.push({text:e}),Array.isArray(r))for(let m of r.slice(0,4))m&&m.dataBase64&&m.mimeType&&s.push({inline_data:{mime_type:m.mimeType,data:m.dataBase64}});let a=await fetch("https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent",{method:"POST",headers:{"x-goog-api-key":o,"Content-Type":"application/json"},body:JSON.stringify({contents:[{parts:s}]})});if(!a.ok){let m=await a.text();throw console.error("Gemini API error",a.status,m),new Error(`Gemini API failed: ${m}`)}let c=(await a.json())?.candidates||[],u=null,d="image/png";for(let m of c){let h=m?.content?.parts||[];for(let p of h){let f=p?.inlineData||p?.inline_data;if(f&&f.data){u=f.data,d=f.mimeType||f.mime_type||d;break}}if(u)break}if(!u)throw new Error("No image returned from Gemini");return t.json({mimeType:d,dataBase64:u})}));var cc=ac;function lc(t){t.get("/api/health",e=>e.json({status:"healthy",timestamp:new Date().toISOString()})),t.route("/api/products",ms),t.route("/api/collections",hs),t.route("/api/storefront",Ts),t.route("/api",Fa),t.route("/api/image-proxy",Va),t.route("/api/store-settings",Ba),t.route("/api/contact-email",Ho),t.route("/api/images",Wa),t.route("/api/admin",Ya),t.route("/api/admin/products",Xa),t.route("/api/admin/collections",Qa),t.route("/api/admin/analytics",Za),t.route("/api/admin/media",ec),t.route("/api/admin/storage",rc),t.route("/api/admin",ic),t.route("/api/admin/ai",cc)}var ce=new E;ce.use("*",async(t,e)=>{await e(),t.header("X-Content-Type-Options","nosniff"),t.header("X-Frame-Options","DENY"),t.header("X-XSS-Protection","1; mode=block"),t.header("Referrer-Policy","strict-origin-when-cross-origin"),t.header("Permissions-Policy","geolocation=(), microphone=(), camera=()");let r=["default-src 'self'","script-src 'self' 'unsafe-inline' 'unsafe-eval' https://js.stripe.com","style-src 'self' 'unsafe-inline'","img-src 'self' data: https: blob:","font-src 'self' data:","connect-src 'self' https://api.stripe.com https://*.stripe.com https://oauth2.googleapis.com https://www.googleapis.com","frame-src https://js.stripe.com https://hooks.stripe.com","frame-ancestors 'none'","base-uri 'self'","form-action 'self'","upgrade-insecure-requests"].join("; ");t.header("Content-Security-Policy",r),new URL(t.req.url).protocol==="https:"&&t.header("Strict-Transport-Security","max-age=31536000; includeSubDomains; preload")});ce.use("*",async(t,e)=>await is(t.env)(t,e));ce.use("/api/admin/*",async(t,e)=>{if(new Set(["/api/admin/login","/api/admin/drive/oauth/start","/api/admin/drive/oauth/callback"]).has(t.req.path))return e();try{let o=await us(t.req,t.env);return o.isValid?e():(console.error("Auth failed:",o.error),t.json({error:o.error,status:o.status},o.status))}catch(o){return console.error("Auth middleware error:",o),t.json({error:"Authentication middleware failed",status:500},500)}});ce.use("/api/admin/*",ds);lc(ce);ce.onError(Xr);ce.get("*",async t=>{let r=new URL(t.req.url).pathname;if(r.startsWith("/api/"))return t.notFound();try{if(r!=="/"&&!r.startsWith("/admin")&&!r.startsWith("/collections")&&!r.startsWith("/products")&&!r.startsWith("/success")){let a=await t.env.ASSETS.fetch(t.req);if(a.ok)return a}let o=new URL(t.req.url);o.pathname="/index.html";let s=new Request(o,t.req),i=await t.env.ASSETS.fetch(s);if(i.ok)return i;throw new Error("index.html not found")}catch(o){return console.error("Error serving static asset:",o,"for path:",r),t.html(` @@ -13724,11 +54,4 @@ app.get("*", async (c) => { - `, 500); - } -}); -var worker_default = app; -export { - worker_default as default -}; -//# sourceMappingURL=worker.js.map + `,500)}});var fS=ce;export{fS as default}; diff --git a/src/components/admin/AdminLogin.jsx b/src/components/admin/AdminLogin.jsx index 02877aa..53d6c7b 100644 --- a/src/components/admin/AdminLogin.jsx +++ b/src/components/admin/AdminLogin.jsx @@ -15,11 +15,11 @@ export function AdminLogin({ onLoginSuccess }) { setError('') try { - const success = await adminLogin(password) - if (success) { + const result = await adminLogin(password) + if (result.success) { onLoginSuccess() } else { - setError('Invalid password. Please try again.') + setError(result.error || 'Invalid password. Please try again.') } } catch (error) { setError('Login failed. Please try again.') diff --git a/src/lib/auth.js b/src/lib/auth.js index b1aabec..306cc4b 100644 --- a/src/lib/auth.js +++ b/src/lib/auth.js @@ -95,12 +95,13 @@ export async function adminLogin(password) { if (response.ok) { const { token } = await response.json() setAdminToken(token) - return true + return { success: true } } else { - return false + const data = await response.json().catch(() => ({})) + return { success: false, error: data.error || 'Login failed' } } } catch (error) { console.error('Admin login error:', error) - return false + return { success: false, error: 'Network error' } } } diff --git a/src/routes/admin/auth.js b/src/routes/admin/auth.js index a3f76c3..ffb8d02 100644 --- a/src/routes/admin/auth.js +++ b/src/routes/admin/auth.js @@ -5,7 +5,7 @@ import { hashToken, verifyPassword, hashPasswordWithSalt } from '../../utils/cry import { getKVNamespace } from '../../utils/kv.js' import { ADMIN_TOKEN_TTL, KV_KEYS } from '../../config/index.js' import { asyncHandler } from '../../middleware/errorHandler.js' -import { ValidationError, AuthenticationError } from '../../utils/errors.js' +import { ValidationError, AuthenticationError, RateLimitError } from '../../utils/errors.js' const router = new Hono() @@ -26,7 +26,7 @@ router.post('/login', asyncHandler(async (c) => { const attemptCount = attempts ? parseInt(attempts, 10) : 0 if (attemptCount >= 5) { - throw new AuthenticationError('Too many login attempts. Please try again later.') + throw new RateLimitError('Too many login attempts. Please try again later.') } // Get stored password hash or use default (will be hashed on first use) diff --git a/src/utils/errors.js b/src/utils/errors.js index 22f0b99..7ddc079 100644 --- a/src/utils/errors.js +++ b/src/utils/errors.js @@ -40,6 +40,16 @@ export class AuthenticationError extends APIError { } } +/** + * Rate limit error + */ +export class RateLimitError extends APIError { + constructor(message = 'Too many requests') { + super(message, 429) + this.name = 'RateLimitError' + } +} + /** * Authorization error */ diff --git a/tests/integration/admin-auth.test.js b/tests/integration/admin-auth.test.js index 4e6a4ee..a582b0e 100644 --- a/tests/integration/admin-auth.test.js +++ b/tests/integration/admin-auth.test.js @@ -133,7 +133,7 @@ describe('Admin Authentication', () => { const response = await executeRequest(app, request, env) const data = await parseJsonResponse(response) - expect(response.status).toBe(401) + expect(response.status).toBe(429) expect(data.error).toContain('Too many login attempts') })