import{o as e}from"./chunk-Bdh3yLIe.js";import{t}from"./main-jD9cMbPj.js";import{n}from"./source-DkXWTsmk.js";import{n as r,t as i}from"./install-fm-addon-DJ5bEmch.js";import{r as a}from"./state-NQaDy_hK.js";import{i as o}from"./parseSettings-DJgpSIYp.js";import{t as s}from"./otto-_Y_2cS-B.js";import{n as c}from"./esm-D-w37dcy.js";import l from"node:path";var u=e(t(),1);async function d({dataApiKey:e,fmFile:t,server:n}){return m((await c({adapter:new s({auth:{apiKey:e},db:t,server:n}),layout:``}).layouts()).layouts)}function f(e){return`isFolder`in e?(e.folderLayoutNames??[]).flatMap(f):[e.name]}const p=[`API_`,`API `,`dapi_`,`dapi`];function m(e){return e.flatMap(f).sort((e,t)=>{let n=p.find(t=>e.startsWith(t)),r=p.find(e=>t.startsWith(e));return n&&r?e.localeCompare(t):n?-1:r?1:e.localeCompare(t)})}async function h(e=a.projectDir){let t=o(e),n=await r({addonName:`wv`}),i=t.dataSources.filter(e=>e.type===`fm`).find(e=>e.name===`filemaker`);if(!i)return{inspection:n};t.envFile&&u.default.config({path:l.join(e,t.envFile)});let s=process.env[i.envNames.apiKey],c=process.env[i.envNames.database],f=process.env[i.envNames.server];if(!(s&&c&&f))return{inspection:n};let p=await d({dataApiKey:s,fmFile:c,server:f});return{hasRequiredLayouts:[`ProofKitWV`].every(e=>p.some(t=>t===e)),inspection:n}}function g({hasRequiredLayouts:e,inspection:t}){let r={info:[],warn:[],nextSteps:[]};if(e&&r.info.push(`Successfully detected all required layouts for ProofKit Web Viewer in your FileMaker file.`),t.status===`installed-outdated`){let e=t.installedVersion&&t.latestVersion?` Local version: ${t.installedVersion}. Latest version: ${t.latestVersion}.`:``;r.warn.push(`New ProofKit Web Viewer add-on available. Run \`${t.installCommand}\` to download and open it.${e}`),r.nextSteps.push(t.installCommand)}if(t.status===`unknown`&&t.reason===`unsupported-platform`&&r.warn.push(`Could not inspect the local ProofKit Web Viewer add-on on this platform.`),e===!1){let e=i(`wv`);r.warn.push(`ProofKit Web Viewer layouts were not detected in your FileMaker file. The add-on may not be installed in the file yet.`),t.status===`missing`&&(r.warn.push(`Local ProofKit Web Viewer add-on file was not found. Run \`${t.installCommand}\` to download and open it.`),r.nextSteps.push(t.installCommand)),t.status===`unknown`&&t.reason!==`unsupported-platform`&&(r.warn.push(`Could not determine the local ProofKit Web Viewer add-on version. Reinstall it explicitly if you need the latest local files.`),r.nextSteps.push(t.installCommand)),r.info.push(n.bgYellow(` ACTION REQUIRED: `)+` Install or update the ProofKit Web Viewer add-on in your FileMaker file. ${n.dim(`(Learn more: ${e.docsUrl})`)}`);for(let t of e.steps)r.info.push(t)}return r}export{h as checkForWebViewerLayouts,g as getWebViewerAddonMessages};
//# sourceMappingURL=proofkit-webviewer-7seVsiza.js.map