{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.getAttributes = exports.getBaseAttributes = exports.getRoleAttributes = exports.isStructTreeNodeWithOnlyContentChild = exports.isStructTreeNode = exports.isPdfRole = void 0;\nconst constants_js_1 = require(\"./constants.js\");\nfunction isPdfRole(role) {\n  return role in constants_js_1.PDF_ROLE_TO_HTML_ROLE;\n}\nexports.isPdfRole = isPdfRole;\nfunction isStructTreeNode(node) {\n  return 'children' in node;\n}\nexports.isStructTreeNode = isStructTreeNode;\nfunction isStructTreeNodeWithOnlyContentChild(node) {\n  if (!isStructTreeNode(node)) {\n    return false;\n  }\n  return node.children.length === 1 && 0 in node.children && 'id' in node.children[0];\n}\nexports.isStructTreeNodeWithOnlyContentChild = isStructTreeNodeWithOnlyContentChild;\nfunction getRoleAttributes(node) {\n  const attributes = {};\n  if (isStructTreeNode(node)) {\n    const {\n      role\n    } = node;\n    const matches = role.match(constants_js_1.HEADING_PATTERN);\n    if (matches) {\n      attributes.role = 'heading';\n      attributes['aria-level'] = Number(matches[1]);\n    } else if (isPdfRole(role)) {\n      const htmlRole = constants_js_1.PDF_ROLE_TO_HTML_ROLE[role];\n      if (htmlRole) {\n        attributes.role = htmlRole;\n      }\n    }\n  }\n  return attributes;\n}\nexports.getRoleAttributes = getRoleAttributes;\nfunction getBaseAttributes(node) {\n  const attributes = {};\n  if (isStructTreeNode(node)) {\n    if (node.alt !== undefined) {\n      attributes['aria-label'] = node.alt;\n    }\n    if (node.lang !== undefined) {\n      attributes.lang = node.lang;\n    }\n    if (isStructTreeNodeWithOnlyContentChild(node)) {\n      const [child] = node.children;\n      if (child) {\n        const childAttributes = getBaseAttributes(child);\n        return Object.assign(Object.assign({}, attributes), childAttributes);\n      }\n    }\n  } else {\n    if ('id' in node) {\n      attributes['aria-owns'] = node.id;\n    }\n  }\n  return attributes;\n}\nexports.getBaseAttributes = getBaseAttributes;\nfunction getAttributes(node) {\n  if (!node) {\n    return null;\n  }\n  return Object.assign(Object.assign({}, getRoleAttributes(node)), getBaseAttributes(node));\n}\nexports.getAttributes = getAttributes;","map":{"version":3,"names":["Object","defineProperty","exports","value","getAttributes","getBaseAttributes","getRoleAttributes","isStructTreeNodeWithOnlyContentChild","isStructTreeNode","isPdfRole","constants_js_1","require","role","PDF_ROLE_TO_HTML_ROLE","node","children","length","attributes","matches","match","HEADING_PATTERN","Number","htmlRole","alt","undefined","lang","child","childAttributes","assign","id"],"sources":["/Users/shanyi/Desktop/Projects/UC_Trains_Voice/react-demo/node_modules/react-pdf/dist/cjs/shared/structTreeUtils.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getAttributes = exports.getBaseAttributes = exports.getRoleAttributes = exports.isStructTreeNodeWithOnlyContentChild = exports.isStructTreeNode = exports.isPdfRole = void 0;\nconst constants_js_1 = require(\"./constants.js\");\nfunction isPdfRole(role) {\n    return role in constants_js_1.PDF_ROLE_TO_HTML_ROLE;\n}\nexports.isPdfRole = isPdfRole;\nfunction isStructTreeNode(node) {\n    return 'children' in node;\n}\nexports.isStructTreeNode = isStructTreeNode;\nfunction isStructTreeNodeWithOnlyContentChild(node) {\n    if (!isStructTreeNode(node)) {\n        return false;\n    }\n    return node.children.length === 1 && 0 in node.children && 'id' in node.children[0];\n}\nexports.isStructTreeNodeWithOnlyContentChild = isStructTreeNodeWithOnlyContentChild;\nfunction getRoleAttributes(node) {\n    const attributes = {};\n    if (isStructTreeNode(node)) {\n        const { role } = node;\n        const matches = role.match(constants_js_1.HEADING_PATTERN);\n        if (matches) {\n            attributes.role = 'heading';\n            attributes['aria-level'] = Number(matches[1]);\n        }\n        else if (isPdfRole(role)) {\n            const htmlRole = constants_js_1.PDF_ROLE_TO_HTML_ROLE[role];\n            if (htmlRole) {\n                attributes.role = htmlRole;\n            }\n        }\n    }\n    return attributes;\n}\nexports.getRoleAttributes = getRoleAttributes;\nfunction getBaseAttributes(node) {\n    const attributes = {};\n    if (isStructTreeNode(node)) {\n        if (node.alt !== undefined) {\n            attributes['aria-label'] = node.alt;\n        }\n        if (node.lang !== undefined) {\n            attributes.lang = node.lang;\n        }\n        if (isStructTreeNodeWithOnlyContentChild(node)) {\n            const [child] = node.children;\n            if (child) {\n                const childAttributes = getBaseAttributes(child);\n                return Object.assign(Object.assign({}, attributes), childAttributes);\n            }\n        }\n    }\n    else {\n        if ('id' in node) {\n            attributes['aria-owns'] = node.id;\n        }\n    }\n    return attributes;\n}\nexports.getBaseAttributes = getBaseAttributes;\nfunction getAttributes(node) {\n    if (!node) {\n        return null;\n    }\n    return Object.assign(Object.assign({}, getRoleAttributes(node)), getBaseAttributes(node));\n}\nexports.getAttributes = getAttributes;\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,aAAa,GAAGF,OAAO,CAACG,iBAAiB,GAAGH,OAAO,CAACI,iBAAiB,GAAGJ,OAAO,CAACK,oCAAoC,GAAGL,OAAO,CAACM,gBAAgB,GAAGN,OAAO,CAACO,SAAS,GAAG,KAAK,CAAC;AACpL,MAAMC,cAAc,GAAGC,OAAO,CAAC,gBAAgB,CAAC;AAChD,SAASF,SAASA,CAACG,IAAI,EAAE;EACrB,OAAOA,IAAI,IAAIF,cAAc,CAACG,qBAAqB;AACvD;AACAX,OAAO,CAACO,SAAS,GAAGA,SAAS;AAC7B,SAASD,gBAAgBA,CAACM,IAAI,EAAE;EAC5B,OAAO,UAAU,IAAIA,IAAI;AAC7B;AACAZ,OAAO,CAACM,gBAAgB,GAAGA,gBAAgB;AAC3C,SAASD,oCAAoCA,CAACO,IAAI,EAAE;EAChD,IAAI,CAACN,gBAAgB,CAACM,IAAI,CAAC,EAAE;IACzB,OAAO,KAAK;EAChB;EACA,OAAOA,IAAI,CAACC,QAAQ,CAACC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAIF,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