@aglyn/aglyn 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-entity-json-ld.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n type ContentAuthorImageContext,\n type HostSeoEntity,\n type SiteEntityHost,\n AUTHOR_NAME_MAX_LENGTH,\n SITE_ENTITY_FRAGMENT,\n contentAuthorSchemaType,\n hostSeoEntityImageJsonLd,\n siteProfileUrls,\n} from './content-authors'\nimport {\n type LocalBusinessType,\n PAYMENT_ACCEPTED_MAX_LENGTH,\n PRICE_RANGE_MAX_LENGTH,\n localBusinessType,\n normalizeAreaServed,\n parseOpeningHours,\n} from './local-business'\n\n/*\n * The SITE entity's JSON-LD: the nested `publisher` and the standalone node.\n *\n * ⛔ Kept apart from `content-authors`, which the compose pipeline reads and\n * therefore ships whole in the site runtime a published page downloads\n * (`check:tenant-wire-weight`). Only the tenant page's server render calls\n * these, and the LocalBusiness allow-list and hours parser they carry\n * (AGL-3383) have no business in a visitor's bundle. Reached through\n * `@aglyn/aglyn/server` only.\n */\n\n/** `content-authors`' trim-and-cap, for the fields this module reads. */\nconst text = (value: unknown, max = AUTHOR_NAME_MAX_LENGTH): string =>\n typeof value === 'string' ? value.trim().slice(0, max) : ''\n\n/**\n * The `@type` the SITE entity publishes under — {@link contentAuthorSchemaType}\n * with one refinement (AGL-3383): an entity that is not a Person and names a\n * business type on the allow-list publishes as that type.\n *\n * Person wins over a business type, because `schema.org` gives a Person none\n * of the properties a business type exists to carry. The stored `type` stays\n * Organization or Person either way; every LocalBusiness subtype IS an\n * Organization, so a consumer reading this as one is still right.\n *\n * Shared by the standalone node and the nested `publisher`, which carry the\n * same `@id` and must therefore not disagree about what they are.\n */\nexport function siteEntitySchemaType(\n entity: HostSeoEntity | null | undefined,\n): 'Person' | 'Organization' | LocalBusinessType {\n const base = contentAuthorSchemaType(entity?.type)\n if (base === 'Person') return base\n return localBusinessType(entity?.businessType) ?? base\n}\n\n/**\n * `schema.org` JSON-LD for the SITE entity (`host.seo.entity`) — the value\n * `Article.publisher` and `WebSite.publisher` are built from.\n *\n * Lives beside {@link contentAuthorJsonLd} on purpose (AGL-2486): a site\n * entity and a post author answer the same question about two different\n * subjects, and the reason the Person branch was broken for two years is that\n * the answer was written inline at its one call site where nothing could\n * test it. One module, two entry points, one `Person`/`Organization`\n * decision — {@link contentAuthorSchemaType}.\n *\n * `logo` is emitted verbatim on BOTH branches, unchanged from what the tenant\n * has always published. It is `host.seo.entity.logo`, a plain URL field on\n * the Setup form rather than a media-picker target, and re-keying it to\n * `image` for a Person would change the publisher block on every page of\n * every site that set one — a separate decision from this one.\n *\n * Given the site's origin, the node carries the standalone entity's `@id`\n * (AGL-3398). Without it a consumer reads this name-only node as a SECOND\n * entity: Google's Rich Results Test listed a site's LocalBusiness twice, the\n * nested one missing telephone, address, price range and image. With it, the\n * two are one entity described in two places.\n */\nexport function hostSeoEntityJsonLd(\n entity: HostSeoEntity | null | undefined,\n context?: { origin?: string },\n): Record<string, unknown> | undefined {\n const name = text(entity?.name, 400)\n if (!name) return undefined\n const origin = context?.origin?.replace(/\\/+$/, '') ?? ''\n return {\n '@type': siteEntitySchemaType(entity),\n ...(origin ? { '@id': `${origin}/${SITE_ENTITY_FRAGMENT}` } : {}),\n name,\n }\n}\n\n/**\n * The site's publisher as a STANDALONE, fully populated `schema.org` node\n * (AGL-2716).\n *\n * ## Why this exists next to {@link hostSeoEntityJsonLd}\n *\n * That function builds the value `publisher` takes: a `@type` and a `name`,\n * nested inside a `WebSite` or an `Article`, gated on the author having filled\n * in the Entity form. It is deliberately narrow, and every call site nests it.\n *\n * A consumer asking \"who runs this site, and how do I reach them\" — an AI\n * assistant answering a contact question, a readiness audit checking whether a\n * business is identifiable — looks for a TOP-LEVEL node of type `Organization`\n * carrying `name`, `description`, `contactPoint` and `address`. A publisher\n * nested two levels inside a `WebSite` answers a different question, and a\n * publisher that is absent because nobody filled in a form answers none.\n *\n * So this one:\n *\n * - is emitted as its own `<script type=\"application/ld+json\">`, at the top\n * level, where it can be found without walking into another node;\n * - FALLS BACK to the site's own identity when the Entity form is empty, so\n * every site on the platform publishes a complete entity rather than only\n * the sites whose author found the form;\n * - carries the contact and address fields, which are what turn \"a name\" into\n * \"a business a consumer can verify\".\n *\n * ## Why the fallback is safe\n *\n * It changes nothing that already exists: `hostSeoEntityJsonLd` still gates on\n * `entity.name`, so `publisher` appears exactly where it appeared before. The\n * fallback only decides what THIS node says, and a site's display name is its\n * publisher's name on the overwhelming majority of sites — the two differ when\n * a company's trading name differs from its site's, which is precisely the case\n * the Entity form exists to express.\n *\n * ## `@id`\n *\n * Both this node and the nested `publisher` carry the same `@id` when an\n * origin is known, so a consumer merges them into one entity instead of\n * reading a site that names its publisher twice with different detail.\n *\n * Returns `undefined` only when there is no name to be had from anywhere —\n * a host document with no entity, no display name and no SEO title.\n */\nexport function siteEntityJsonLd(\n host: SiteEntityHost | null | undefined,\n context?: ContentAuthorImageContext,\n): Record<string, unknown> | undefined {\n const entity = host?.seo?.entity ?? undefined\n const name =\n text(entity?.name, 400) ||\n text(host?.displayName, 400) ||\n text(host?.seo?.title, 400)\n if (!name) return undefined\n\n const origin = context?.origin?.replace(/\\/+$/, '') ?? ''\n const description =\n text(entity?.description, 800) || text(host?.seo?.description, 800)\n const url = text(entity?.url, 800) || origin\n\n /*\n `sameAs` is de-duplicated and https-only, matching the author serializer:\n a profile URL that is not fetchable teaches a consumer nothing, and the\n same profile listed twice reads as two identities.\n\n Through `siteProfileUrls` (AGL-3148) so the site's rendered social links\n count as profiles it claims, rather than only the SEO field that no host\n on the platform had filled in.\n */\n const sameAs = siteProfileUrls(host)\n\n /*\n A contactPoint needs something to contact. `contactType` alone is a label\n on nothing, so the point is emitted only when an address or a number is\n present — `schema.org` requires neither, and a consumer that finds a\n ContactPoint with no channel has been told less than it would learn from\n its absence.\n */\n const email = text(entity?.email, 320)\n const telephone = text(entity?.telephone, 64)\n const contactType = text(entity?.contactType, 120) || 'customer support'\n const contactPoint =\n email || telephone\n ? {\n '@type': 'ContactPoint',\n contactType,\n ...(email ? { email } : {}),\n ...(telephone ? { telephone } : {}),\n }\n : undefined\n\n const addressFields = {\n streetAddress: text(entity?.address?.streetAddress, 200),\n addressLocality: text(entity?.address?.addressLocality, 120),\n addressRegion: text(entity?.address?.addressRegion, 120),\n postalCode: text(entity?.address?.postalCode, 40),\n addressCountry: text(entity?.address?.addressCountry, 120),\n }\n const address = Object.entries(addressFields).filter(([, value]) => value)\n const schemaType = siteEntitySchemaType(entity)\n const picture = hostSeoEntityImageJsonLd(entity, context)\n const business =\n schemaType !== 'Person' && schemaType !== 'Organization'\n ? localBusinessJsonLd(entity, telephone, picture.logo)\n : {}\n\n return {\n '@context': 'https://schema.org',\n '@type': schemaType,\n ...(origin ? { '@id': `${origin}/${SITE_ENTITY_FRAGMENT}` } : {}),\n name,\n ...(description ? { description } : {}),\n ...(url ? { url } : {}),\n // `logo` for an Organization, `image` for a Person — the one field whose\n // KEY the branch changes. Shared with the nested publisher so the two\n // nodes cannot describe the same entity with different pictures.\n ...picture,\n ...(sameAs.length ? { sameAs } : {}),\n ...(contactPoint ? { contactPoint } : {}),\n ...(address.length\n ? { address: { '@type': 'PostalAddress', ...Object.fromEntries(address) } }\n : {}),\n ...business,\n }\n}\n\n/**\n * The properties only a LocalBusiness carries (AGL-3383), spread after\n * everything an Organization publishes so an Organization's output is\n * unchanged key for key.\n *\n * - `telephone` on the node itself as well as on its `contactPoint`: a\n * LocalBusiness has the property directly, and it is where a local result\n * reads the number from.\n * - `areaServed` as named `City` places. A service-area business commonly has\n * no street address to publish, and this is what says where it works.\n * - `openingHoursSpecification` from the hours text, invalid lines dropped.\n * - `image`, the entity logo (AGL-3398): Google recommends a picture of a\n * LocalBusiness and reads `image`, not the Organization-only `logo`, which\n * stays as well.\n *\n * Every one of them is omitted when empty, never published as `[]` or `''`.\n */\nfunction localBusinessJsonLd(\n entity: HostSeoEntity | null | undefined,\n telephone: string,\n logo: string | undefined,\n): Record<string, unknown> {\n const areaServed = normalizeAreaServed(entity?.areaServed)\n const hours = parseOpeningHours(entity?.openingHours)\n const priceRange = text(entity?.priceRange, PRICE_RANGE_MAX_LENGTH)\n const paymentAccepted = text(\n entity?.paymentAccepted,\n PAYMENT_ACCEPTED_MAX_LENGTH,\n )\n return {\n ...(telephone ? { telephone } : {}),\n ...(areaServed.length\n ? { areaServed: areaServed.map((name) => ({ '@type': 'City', name })) }\n : {}),\n ...(hours.length\n ? {\n openingHoursSpecification: hours.map((row) => ({\n '@type': 'OpeningHoursSpecification',\n dayOfWeek: row.days,\n opens: row.opens,\n closes: row.closes,\n })),\n }\n : {}),\n ...(priceRange ? { priceRange } : {}),\n ...(paymentAccepted ? { paymentAccepted } : {}),\n ...(logo ? { image: logo } : {}),\n }\n}\n"],"names":["AUTHOR_NAME_MAX_LENGTH","SITE_ENTITY_FRAGMENT","contentAuthorSchemaType","hostSeoEntityImageJsonLd","siteProfileUrls","PAYMENT_ACCEPTED_MAX_LENGTH","PRICE_RANGE_MAX_LENGTH","localBusinessType","normalizeAreaServed","parseOpeningHours","text","value","max","trim","slice","siteEntitySchemaType","entity","base","type","businessType","hostSeoEntityJsonLd","context","name","undefined","origin","replace","siteEntityJsonLd","host","seo","displayName","title","description","url","sameAs","email","telephone","contactType","contactPoint","addressFields","streetAddress","address","addressLocality","addressRegion","postalCode","addressCountry","Object","entries","filter","schemaType","picture","business","localBusinessJsonLd","logo","length","fromEntries","areaServed","hours","openingHours","priceRange","paymentAccepted","map","openingHoursSpecification","row","dayOfWeek","days","opens","closes","image"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAIEA,sBAAsB,EACtBC,oBAAoB,EACpBC,uBAAuB,EACvBC,wBAAwB,EACxBC,eAAe,QACV,uBAAmB;AAC1B,SAEEC,2BAA2B,EAC3BC,sBAAsB,EACtBC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,QACZ,sBAAkB;AAEzB;;;;;;;;;CASC,GAED,uEAAuE,GACvE,MAAMC,OAAO,CAACC,OAAgBC,MAAMZ,sBAAsB,GACxD,OAAOW,UAAU,WAAWA,MAAME,IAAI,GAAGC,KAAK,CAAC,GAAGF,OAAO;AAE3D;;;;;;;;;;;;CAYC,GACD,OAAO,SAASG,qBACdC,MAAwC;QAIjCT;IAFP,MAAMU,OAAOf,wBAAwBc,0BAAAA,OAAQE,IAAI;IACjD,IAAID,SAAS,UAAU,OAAOA;IAC9B,QAAOV,qBAAAA,kBAAkBS,0BAAAA,OAAQG,YAAY,aAAtCZ,qBAA2CU;AACpD;AAEA;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,SAASG,oBACdJ,MAAwC,EACxCK,OAA6B;;QAIdA;IAFf,MAAMC,OAAOZ,KAAKM,0BAAAA,OAAQM,IAAI,EAAE;IAChC,IAAI,CAACA,MAAM,OAAOC;IAClB,MAAMC,iBAASH,4BAAAA,kBAAAA,QAASG,MAAM,qBAAfH,gBAAiBI,OAAO,CAAC,QAAQ,sBAAO;IACvD,OAAO;QACL,SAASV,qBAAqBC;OAC1BQ,SAAS;QAAE,OAAO,GAAGA,OAAO,CAAC,EAAEvB,sBAAsB;IAAC,IAAI,CAAC;QAC/DqB;;AAEJ;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CC,GACD,OAAO,SAASI,iBACdC,IAAuC,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tBM,0BAAAA,OAAQ2C,eAAe,EACvBtD;IAEF,OAAO,aACD8B,YAAY;QAAEA;IAAU,IAAI,CAAC,GAC7BoB,WAAWF,MAAM,GACjB;QAAEE,YAAYA,WAAWK,GAAG,CAAC,CAACtC,OAAU,CAAA;gBAAE,SAAS;gBAAQA;YAAK,CAAA;IAAI,IACpE,CAAC,GACDkC,MAAMH,MAAM,GACZ;QACEQ,2BAA2BL,MAAMI,GAAG,CAAC,CAACE,MAAS,CAAA;gBAC7C,SAAS;gBACTC,WAAWD,IAAIE,IAAI;gBACnBC,OAAOH,IAAIG,KAAK;gBAChBC,QAAQJ,IAAII,MAAM;YACpB,CAAA;IACF,IACA,CAAC,GACDR,aAAa;QAAEA;IAAW,IAAI,CAAC,GAC/BC,kBAAkB;QAAEA;IAAgB,IAAI,CAAC,GACzCP,OAAO;QAAEe,OAAOf;IAAK,IAAI,CAAC;AAElC"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-entity-json-ld.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n type ContentAuthorImageContext,\n type HostSeoEntity,\n type SiteEntityHost,\n AUTHOR_NAME_MAX_LENGTH,\n SITE_ENTITY_FRAGMENT,\n contentAuthorSchemaType,\n hostSeoEntityImageJsonLd,\n siteProfileUrls,\n} from './content-authors'\nimport { SITE_SLOGAN_MAX_LENGTH } from './business-details'\nimport { siteContactEmail } from './host-tokens'\nimport {\n type LocalBusinessType,\n PAYMENT_ACCEPTED_MAX_LENGTH,\n PRICE_RANGE_MAX_LENGTH,\n localBusinessType,\n normalizeAreaServed,\n parseOpeningHours,\n} from './local-business'\n\n/*\n * The SITE entity's JSON-LD: the nested `publisher` and the standalone node.\n *\n * ⛔ Kept apart from `content-authors`, which the compose pipeline reads and\n * therefore ships whole in the site runtime a published page downloads\n * (`check:tenant-wire-weight`). Only the tenant page's server render calls\n * these, and the LocalBusiness allow-list and hours parser they carry\n * (AGL-3383) have no business in a visitor's bundle. Reached through\n * `@aglyn/aglyn/server` only.\n */\n\n/** `content-authors`' trim-and-cap, for the fields this module reads. */\nconst text = (value: unknown, max = AUTHOR_NAME_MAX_LENGTH): string =>\n typeof value === 'string' ? value.trim().slice(0, max) : ''\n\n/**\n * The `@type` the SITE entity publishes under — {@link contentAuthorSchemaType}\n * with one refinement (AGL-3383): an entity that is not a Person and names a\n * business type on the allow-list publishes as that type.\n *\n * Person wins over a business type, because `schema.org` gives a Person none\n * of the properties a business type exists to carry. The stored `type` stays\n * Organization or Person either way; every LocalBusiness subtype IS an\n * Organization, so a consumer reading this as one is still right.\n *\n * Shared by the standalone node and the nested `publisher`, which carry the\n * same `@id` and must therefore not disagree about what they are.\n */\nexport function siteEntitySchemaType(\n entity: HostSeoEntity | null | undefined,\n): 'Person' | 'Organization' | LocalBusinessType {\n const base = contentAuthorSchemaType(entity?.type)\n if (base === 'Person') return base\n return localBusinessType(entity?.businessType) ?? base\n}\n\n/**\n * `schema.org` JSON-LD for the SITE entity (`host.seo.entity`) — the value\n * `Article.publisher` and `WebSite.publisher` are built from.\n *\n * Lives beside {@link contentAuthorJsonLd} on purpose (AGL-2486): a site\n * entity and a post author answer the same question about two different\n * subjects, and the reason the Person branch was broken for two years is that\n * the answer was written inline at its one call site where nothing could\n * test it. One module, two entry points, one `Person`/`Organization`\n * decision — {@link contentAuthorSchemaType}.\n *\n * `logo` is emitted verbatim on BOTH branches, unchanged from what the tenant\n * has always published. It is `host.seo.entity.logo`, a plain URL field on\n * the Setup form rather than a media-picker target, and re-keying it to\n * `image` for a Person would change the publisher block on every page of\n * every site that set one — a separate decision from this one.\n *\n * Given the site's origin, the node carries the standalone entity's `@id`\n * (AGL-3398). Without it a consumer reads this name-only node as a SECOND\n * entity: Google's Rich Results Test listed a site's LocalBusiness twice, the\n * nested one missing telephone, address, price range and image. With it, the\n * two are one entity described in two places.\n */\nexport function hostSeoEntityJsonLd(\n entity: HostSeoEntity | null | undefined,\n context?: { origin?: string },\n): Record<string, unknown> | undefined {\n const name = text(entity?.name, 400)\n if (!name) return undefined\n const origin = context?.origin?.replace(/\\/+$/, '') ?? ''\n return {\n '@type': siteEntitySchemaType(entity),\n ...(origin ? { '@id': `${origin}/${SITE_ENTITY_FRAGMENT}` } : {}),\n name,\n }\n}\n\n/**\n * The site's publisher as a STANDALONE, fully populated `schema.org` node\n * (AGL-2716).\n *\n * ## Why this exists next to {@link hostSeoEntityJsonLd}\n *\n * That function builds the value `publisher` takes: a `@type` and a `name`,\n * nested inside a `WebSite` or an `Article`, gated on the author having filled\n * in the Entity form. It is deliberately narrow, and every call site nests it.\n *\n * A consumer asking \"who runs this site, and how do I reach them\" — an AI\n * assistant answering a contact question, a readiness audit checking whether a\n * business is identifiable — looks for a TOP-LEVEL node of type `Organization`\n * carrying `name`, `description`, `contactPoint` and `address`. A publisher\n * nested two levels inside a `WebSite` answers a different question, and a\n * publisher that is absent because nobody filled in a form answers none.\n *\n * So this one:\n *\n * - is emitted as its own `<script type=\"application/ld+json\">`, at the top\n * level, where it can be found without walking into another node;\n * - FALLS BACK to the site's own identity when the Entity form is empty, so\n * every site on the platform publishes a complete entity rather than only\n * the sites whose author found the form;\n * - carries the contact and address fields, which are what turn \"a name\" into\n * \"a business a consumer can verify\".\n *\n * ## Why the fallback is safe\n *\n * It changes nothing that already exists: `hostSeoEntityJsonLd` still gates on\n * `entity.name`, so `publisher` appears exactly where it appeared before. The\n * fallback only decides what THIS node says, and a site's display name is its\n * publisher's name on the overwhelming majority of sites — the two differ when\n * a company's trading name differs from its site's, which is precisely the case\n * the Entity form exists to express.\n *\n * ## `@id`\n *\n * Both this node and the nested `publisher` carry the same `@id` when an\n * origin is known, so a consumer merges them into one entity instead of\n * reading a site that names its publisher twice with different detail.\n *\n * Returns `undefined` only when there is no name to be had from anywhere —\n * a host document with no entity, no display name and no SEO title.\n */\nexport function siteEntityJsonLd(\n host: SiteEntityHost | null | undefined,\n context?: ContentAuthorImageContext,\n): Record<string, unknown> | undefined {\n const entity = host?.seo?.entity ?? undefined\n const name =\n text(entity?.name, 400) ||\n text(host?.displayName, 400) ||\n text(host?.seo?.title, 400)\n if (!name) return undefined\n\n const origin = context?.origin?.replace(/\\/+$/, '') ?? ''\n const description =\n text(entity?.description, 800) || text(host?.seo?.description, 800)\n const url = text(entity?.url, 800) || origin\n\n /*\n `sameAs` is de-duplicated and https-only, matching the author serializer:\n a profile URL that is not fetchable teaches a consumer nothing, and the\n same profile listed twice reads as two identities.\n\n Through `siteProfileUrls` (AGL-3148) so the site's rendered social links\n count as profiles it claims, rather than only the SEO field that no host\n on the platform had filled in.\n */\n const sameAs = siteProfileUrls(host)\n\n /*\n A contactPoint needs something to contact. `contactType` alone is a label\n on nothing, so the point is emitted only when an address or a number is\n present — `schema.org` requires neither, and a consumer that finds a\n ContactPoint with no channel has been told less than it would learn from\n its absence.\n\n The email is the site's one email (AGL-4136): what Setup → Business\n profile saves to the entity, else the older one-block copy, so a site\n whose email lives only there still says how to reach it.\n */\n // `SiteEntityHost` names only the social links under `business`; the host\n // document handed here is the whole document, older email copy included.\n const email = text(\n siteContactEmail(host as Parameters<typeof siteContactEmail>[0]) ?? '',\n 320,\n )\n const telephone = text(entity?.telephone, 64)\n const contactType = text(entity?.contactType, 120) || 'customer support'\n const contactPoint =\n email || telephone\n ? {\n '@type': 'ContactPoint',\n contactType,\n ...(email ? { email } : {}),\n ...(telephone ? { telephone } : {}),\n }\n : undefined\n\n const addressFields = {\n streetAddress: text(entity?.address?.streetAddress, 200),\n addressLocality: text(entity?.address?.addressLocality, 120),\n addressRegion: text(entity?.address?.addressRegion, 120),\n postalCode: text(entity?.address?.postalCode, 40),\n addressCountry: text(entity?.address?.addressCountry, 120),\n }\n const address = Object.entries(addressFields).filter(([, value]) => value)\n const schemaType = siteEntitySchemaType(entity)\n const picture = hostSeoEntityImageJsonLd(entity, context)\n /*\n The business's slogan from Setup → Business profile (AGL-4136). `slogan` is an\n Organization property, which every LocalBusiness type inherits; a Person\n has none, so a site published by a person never carries it.\n */\n const slogan =\n schemaType === 'Person' ? '' : text(entity?.slogan, SITE_SLOGAN_MAX_LENGTH)\n const business =\n schemaType !== 'Person' && schemaType !== 'Organization'\n ? localBusinessJsonLd(entity, telephone, picture.logo)\n : {}\n\n return {\n '@context': 'https://schema.org',\n '@type': schemaType,\n ...(origin ? { '@id': `${origin}/${SITE_ENTITY_FRAGMENT}` } : {}),\n name,\n ...(description ? { description } : {}),\n ...(slogan ? { slogan } : {}),\n ...(url ? { url } : {}),\n // `logo` for an Organization, `image` for a Person — the one field whose\n // KEY the branch changes. Shared with the nested publisher so the two\n // nodes cannot describe the same entity with different pictures.\n ...picture,\n ...(sameAs.length ? { sameAs } : {}),\n ...(contactPoint ? { contactPoint } : {}),\n ...(address.length\n ? { address: { '@type': 'PostalAddress', ...Object.fromEntries(address) } }\n : {}),\n ...business,\n }\n}\n\n/**\n * The properties only a LocalBusiness carries (AGL-3383), spread after\n * everything an Organization publishes so an Organization's output is\n * unchanged key for key.\n *\n * - `telephone` on the node itself as well as on its `contactPoint`: a\n * LocalBusiness has the property directly, and it is where a local result\n * reads the number from.\n * - `areaServed` as named `City` places. A service-area business commonly has\n * no street address to publish, and this is what says where it works.\n * - `openingHoursSpecification` from the hours text, invalid lines dropped.\n * - `image`, the entity logo (AGL-3398): Google recommends a picture of a\n * LocalBusiness and reads `image`, not the Organization-only `logo`, which\n * stays as well.\n *\n * Every one of them is omitted when empty, never published as `[]` or `''`.\n */\nfunction localBusinessJsonLd(\n entity: HostSeoEntity | null | undefined,\n telephone: string,\n logo: string | undefined,\n): Record<string, unknown> {\n const areaServed = normalizeAreaServed(entity?.areaServed)\n const hours = parseOpeningHours(entity?.openingHours)\n const priceRange = text(entity?.priceRange, PRICE_RANGE_MAX_LENGTH)\n const paymentAccepted = text(\n entity?.paymentAccepted,\n PAYMENT_ACCEPTED_MAX_LENGTH,\n )\n return {\n ...(telephone ? { telephone } : {}),\n ...(areaServed.length\n ? { areaServed: areaServed.map((name) => ({ '@type': 'City', name })) }\n : {}),\n ...(hours.length\n ? {\n openingHoursSpecification: hours.map((row) => ({\n '@type': 'OpeningHoursSpecification',\n dayOfWeek: row.days,\n opens: row.opens,\n closes: row.closes,\n })),\n }\n : {}),\n ...(priceRange ? { priceRange } : {}),\n ...(paymentAccepted ? { paymentAccepted } : {}),\n ...(logo ? { image: logo } : {}),\n }\n}\n"],"names":["AUTHOR_NAME_MAX_LENGTH","SITE_ENTITY_FRAGMENT","contentAuthorSchemaType","hostSeoEntityImageJsonLd","siteProfileUrls","SITE_SLOGAN_MAX_LENGTH","siteContactEmail","PAYMENT_ACCEPTED_MAX_LENGTH","PRICE_RANGE_MAX_LENGTH","localBusinessType","normalizeAreaServed","parseOpeningHours","text","value","max","trim","slice","siteEntitySchemaType","entity","base","type","businessType","hostSeoEntityJsonLd","context","name","undefined","origin","replace","siteEntityJsonLd","host","seo","displayName","title","description","url","sameAs","email","telephone","contactType","contactPoint","addressFields","streetAddress","address","addressLocality","addressRegion","postalCode","addressCountry","Object","entries","filter","schemaType","picture","slogan","business","localBusinessJsonLd","logo","length","fromEntries","areaServed","hours","openingHours","priceRange","paymentAccepted","map","openingHoursSpecification","row","dayOfWeek","days","opens","closes","image"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAIEA,sBAAsB,EACtBC,oBAAoB,EACpBC,uBAAuB,EACvBC,wBAAwB,EACxBC,eAAe,QACV,uBAAmB;AAC1B,SAASC,sBAAsB,QAAQ,wBAAoB;AAC3D,SAASC,gBAAgB,QAAQ,mBAAe;AAChD,SAEEC,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