/**
 * Minified by jsDelivr using Terser v5.48.0.
 * Original file: /npm/@shopify/shopify-app-express@8.0.5/dist/cjs/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var compareVersions=require("compare-versions");require("@shopify/shopify-api/adapters/node");var shopifyApi=require("@shopify/shopify-api"),shopifyAppSessionStorageMemory=require("@shopify/shopify-app-session-storage-memory"),version=require("./version.js"),idempotentPromiseHandler=require("./helpers/idempotent-promise-handler.js"),registerWebhooks=require("./helpers/register-webhooks.js"),flags=require("./future/flags.js"),validateAuthenticatedSession=require("./middlewares/validate-authenticated-session.js"),ensureInstalledOnShop=require("./middlewares/ensure-installed-on-shop.js"),cspHeaders=require("./middlewares/csp-headers.js"),redirectToShopifyOrAppRoot=require("./middlewares/redirect-to-shopify-or-app-root.js"),index$1=require("./auth/index.js"),index=require("./webhooks/index.js"),redirectOutOfApp=require("./redirect-out-of-app.js"),ensureValidOfflineSession=require("./helpers/ensure-valid-offline-session.js");function shopifyApp(e){const{api:r,...i}=e,s=shopifyApi.shopifyApi(apiConfigWithDefaults(r)),o=validateAppConfig(i,s);if(o.future?.tokenExchange&&!s.config.isEmbeddedApp)throw new shopifyApi.ShopifyError("tokenExchange requires an embedded app (isEmbeddedApp: true). Token exchange is not available for non-embedded apps; remove the flag or set isEmbeddedApp to true.");return flags.logDisabledFutureFlags(o,s.logger),{config:o,api:s,auth:index$1.auth({api:s,config:o}),processWebhooks:index.processWebhooks({api:s,config:o}),validateAuthenticatedSession:validateAuthenticatedSession.validateAuthenticatedSession({api:s,config:o}),cspHeaders:cspHeaders.cspHeaders({api:s}),ensureInstalledOnShop:ensureInstalledOnShop.ensureInstalled({api:s,config:o}),redirectToShopifyOrAppRoot:redirectToShopifyOrAppRoot.redirectToShopifyOrAppRoot({api:s,config:o}),redirectOutOfApp:redirectOutOfApp.redirectOutOfApp({api:s,config:o}),ensureValidOfflineSession:e=>ensureValidOfflineSession.ensureValidOfflineSession({api:s,config:o},e),registerWebhooks:({session:e})=>registerWebhooks.registerWebhooks(o,s,e)}}function apiConfigWithDefaults(e){let r=`Shopify Express Library v${version.SHOPIFY_EXPRESS_LIBRARY_VERSION}`;return e?.userAgentPrefix&&(r=`${e.userAgentPrefix} | ${r}`),{apiKey:process.env.SHOPIFY_API_KEY,apiSecretKey:process.env.SHOPIFY_API_SECRET,scopes:process.env.SCOPES?.split(","),hostScheme:process.env.HOST?.split("://")[0],hostName:process.env.HOST?.replace(/https?:\/\//,""),isEmbeddedApp:!0,...e,userAgentPrefix:r}}function validateAppConfig(e,r){const{sessionStorage:i,...s}=e;return{logger:overrideLoggerPackage(r.logger),useOnlineTokens:!1,exitIframePath:"/exitiframe",future:{},hooks:{},idempotentPromiseHandler:new idempotentPromiseHandler.IdempotentPromiseHandler,sessionStorage:i??new shopifyAppSessionStorageMemory.MemorySessionStorage,...s,auth:e.auth,webhooks:e.webhooks}}function overrideLoggerPackage(e){const r={package:"shopify-app"},i=(i,s={})=>e.warning(i,{...r,...s});return{...e,log:(i,s,o={})=>e.log(i,s,{...r,...o}),debug:(i,s={})=>e.debug(i,{...r,...s}),info:(i,s={})=>e.info(i,{...r,...s}),warning:i,error:(i,s={})=>e.error(i,{...r,...s}),deprecated:deprecated(i)}}function deprecated(e){return function(r,i){if(compareVersions.compare(version.SHOPIFY_EXPRESS_LIBRARY_VERSION,r,">="))throw new shopifyApi.FeatureDeprecatedError(`Feature was deprecated in version ${r}`);return e(`[Deprecated | ${r}] ${i}`)}}Object.defineProperty(exports,"ApiVersion",{enumerable:!0,get:function(){return shopifyApi.ApiVersion}}),exports.shopifyApp=shopifyApp;
//# sourceMappingURL=/sm/594c1c822a98f3464b7dd02b14375022d012a210741868e33ddb1a1add3bd233.map