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AE;gBACtD,oHAAoH;gBACpH,+DAA+D;gBAC/D,OAAO,CAAC,IAAI,CACV,gCACE,KAAK,CAAC,MACR,+FAA+F,OAAO;qBACnG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,GAAG,CAAC;qBAC5B,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;aACH;SACF;QACD,kCAAkC;QAClC,OAAO,KAAK,CAAC,MAAM,CAAC;KACrB;IACD,kFAAkF;IAClF,mFAAmF;IACnF,kFAAkF;IAClF,mCAAmC;IAEnC,2CAA2C;IAC3C,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,eAAe,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;QAC/D,qDAAqD;QACrD,2EAA2E;QAC3E,OAAO,CAAC,IAAI,CACV,2PAA2P,WAAW,kBAAkB,iBAAiB,EAAE,CAC5S,CAAC;QACF,OAAO,WAAW,CAAC;KACpB;IACD,qFAAqF;IACrF,yFAAyF;IACzF,yFAAyF;IACzF,kEAAkE;IAClE,+DAA+D;IAC/D,MAAM,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,GAAG,eAAe,CAAC;IAElD,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,YAAY,GAAG,0NAA0N,iBAAiB,EAAE,CAAC;QACnQ,4GAA4G;QAC5G,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;KAC/B;IACD,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;QAC1C,OAAO,CAAC,IAAI,CACV,4EAA4E,MAAM,gBAAgB;YAChG,GAAG,YAAY;YACf,WAAW;SACZ;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,+DAA+D,CAC7E,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { Platform } from '@unimodules/core';\nimport Constants, { ExecutionEnvironment } from 'expo-constants';\n\nconst LINKING_GUIDE_URL = `https://docs.expo.io/guides/linking/`;\n\nexport function hasCustomScheme(): boolean {\n if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {\n // Bare always uses a custom scheme.\n return true;\n } else if (Constants.executionEnvironment === ExecutionEnvironment.Standalone) {\n // Standalone uses a custom scheme when one is defined.\n const manifestSchemes = collectManifestSchemes();\n return !!manifestSchemes.length;\n }\n // Store client uses the default scheme.\n return false;\n}\n\ntype SchemeConfig = {\n scheme?: string | string[];\n};\n\nfunction getSchemes(config: SchemeConfig): string[] {\n if (config) {\n if (Array.isArray(config.scheme)) {\n const validate = (value: any): value is string => {\n return typeof value === 'string';\n };\n return config.scheme.filter(validate);\n } else if (typeof config.scheme === 'string') {\n return [config.scheme];\n }\n }\n return [];\n}\n\n// Valid schemes for the Expo client.\nconst EXPO_CLIENT_SCHEMES = Platform.select({\n // Results from `npx uri-scheme list --info-path ios/Exponent/Supporting/Info.plist`\n ios: [\n 'exp',\n 'exps',\n 'fb1696089354000816',\n 'host.exp.exponent',\n 'com.googleusercontent.apps.603386649315-vp4revvrcgrcjme51ebuhbkbspl048l9',\n ],\n // Collected manually\n android: ['exp', 'exps'],\n});\n\n/**\n * Collect a list of platform schemes from the manifest.\n *\n * This method is based on the `Scheme` modules from `@expo/config-plugins`\n * which are used for collecting the schemes before prebuilding a native app.\n *\n * - iOS: scheme -> ios.scheme -> ios.bundleIdentifier\n * - Android: scheme -> android.scheme -> android.package\n */\nexport function collectManifestSchemes(): string[] {\n // ios.scheme, android.scheme, and scheme as an array are not yet added to the\n // Expo config spec, but there's no harm in adding them early.\n // They'll be added when we drop support for `expo build` or decide\n // to have them only work with `eas build`.\n const platformManifest =\n (Platform.select({\n ios: Constants.manifest?.ios,\n android: Constants.manifest?.android,\n web: {},\n }) as SchemeConfig) ?? {};\n\n const schemes = getSchemes(Constants.manifest as any);\n\n // Add the detached scheme after the manifest scheme for legacy ExpoKit support.\n if (Constants.manifest?.detach?.scheme) {\n schemes.push(Constants.manifest.detach.scheme);\n }\n\n // Add the unimplemented platform schemes last.\n schemes.push(...getSchemes(platformManifest));\n\n return schemes;\n}\n\nfunction getNativeAppIdScheme(): string | null {\n // Add the native application identifier to the list of schemes for parity with `expo build`.\n // The native app id has been added to builds for a long time to support Google Sign-In.\n return (\n Platform.select({\n ios: Constants.manifest?.ios?.bundleIdentifier,\n // TODO: This may change to android.applicationId in the future.\n android: Constants.manifest?.android?.package,\n }) ?? null\n );\n}\n\nexport function hasConstantsManifest(): boolean {\n // Ensure the user has linked the expo-constants manifest in bare workflow.\n return (\n !!Object.keys(Constants.manifest ?? {}).length ||\n !!Object.keys(Constants.manifest2 ?? {}).length\n );\n}\n\nexport function resolveScheme(props: { scheme?: string; isSilent?: boolean }): string {\n if (\n Constants.executionEnvironment !== ExecutionEnvironment.StoreClient &&\n !hasConstantsManifest()\n ) {\n throw new Error(\n `expo-linking needs access to the expo-constants manifest (app.json or app.config.js) to determine what URI scheme to use. Setup the manifest and rebuild: https://github.com/expo/expo/blob/master/packages/expo-constants/README.md`\n );\n }\n\n const manifestSchemes = collectManifestSchemes();\n const nativeAppId = getNativeAppIdScheme();\n\n if (!manifestSchemes.length) {\n if (__DEV__ && !props.isSilent) {\n // Assert a config warning if no scheme is setup yet. `isSilent` is used for warnings, but we'll ignore it for exceptions.\n console.warn(\n `Linking requires a build-time setting \\`scheme\\` in the project's Expo config (app.config.js or app.json) for production apps, if it's left blank, your app may crash. The scheme does not apply to development in the Expo client but you should add it as soon as you start working with Linking to avoid creating a broken build. Learn more: ${LINKING_GUIDE_URL}`\n );\n } else if (!__DEV__ || Constants.executionEnvironment !== ExecutionEnvironment.StoreClient) {\n // Throw in production or when not in store client. Use the __DEV__ flag so users can test this functionality with `expo start --no-dev`,\n throw new Error(\n 'Cannot make a deep link into a standalone app with no custom scheme defined'\n );\n }\n }\n\n // In the Expo client...\n if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n if (props.scheme) {\n // This enables users to use the fb or google redirects on iOS in the Expo client.\n if (EXPO_CLIENT_SCHEMES.includes(props.scheme)) {\n return props.scheme;\n }\n // Silently ignore to make bare workflow development easier.\n }\n // Fallback to the default client scheme.\n return 'exp';\n }\n\n const schemes = [...manifestSchemes, nativeAppId].filter(Boolean);\n\n if (props.scheme) {\n if (__DEV__) {\n // Bare workflow development assertion about the provided scheme matching the Expo config.\n if (!schemes.includes(props.scheme) && !props.isSilent) {\n // TODO: Will this cause issues for things like Facebook or Google that use `reversed-client-id://` or `fb:/`?\n // Traditionally these APIs don't use the Linking API directly.\n console.warn(\n `The provided Linking scheme '${\n props.scheme\n }' does not appear in the list of possible URI schemes in your Expo config. Expected one of: ${schemes\n .map(scheme => `'${scheme}'`)\n .join(', ')}`\n );\n }\n }\n // Return the user provided value.\n return props.scheme;\n }\n // If no scheme is provided, we'll guess what the scheme is based on the manifest.\n // This is to attempt to keep managed apps working across expo build and EAS build.\n // EAS build ejects the app before building it so we can assume that the user will\n // be using one of defined schemes.\n\n // If the native app id is the only scheme,\n if (!!nativeAppId && !manifestSchemes.length && !props.isSilent) {\n // Assert a config warning if no scheme is setup yet.\n // This warning only applies to managed workflow EAS apps, as bare workflow\n console.warn(\n `Linking requires a build-time setting \\`scheme\\` in the project's Expo config (app.config.js or app.json) for bare or production apps. Manually providing a \\`scheme\\` property can circumvent this warning. Using native app identifier as the scheme '${nativeAppId}'. Learn more: ${LINKING_GUIDE_URL}`\n );\n return nativeAppId;\n }\n // When the native app id is defined, it'll be added to the list of schemes, for most\n // users this will be unexpected behavior and cause all apps to warn when the Linking API\n // is used without a predefined scheme. For now, if the native app id is defined, require\n // at least one more scheme to be added before throwing a warning.\n // i.e. `scheme: ['foo', 'bar']` (unimplemented functionality).\n const [scheme, ...extraSchemes] = manifestSchemes;\n\n if (!scheme) {\n const errorMessage = `Linking requires a build-time setting \\`scheme\\` in the project's Expo config (app.config.js or app.json) for bare or production apps. Manually providing a \\`scheme\\` property can circumvent this error. Learn more: ${LINKING_GUIDE_URL}`;\n // Throw in production, use the __DEV__ flag so users can test this functionality with `expo start --no-dev`\n throw new Error(errorMessage);\n }\n if (extraSchemes.length && !props.isSilent) {\n console.warn(\n `Linking found multiple possible URI schemes in your Expo config.\\nUsing '${scheme}'. Ignoring: ${[\n ...extraSchemes,\n nativeAppId,\n ]\n .filter(Boolean)\n .join(', ')}.\\nPlease supply the preferred URI scheme to the Linking API.`\n );\n }\n return scheme;\n}\n"]}