{"version":3,"sources":["jsdelivr-header.js","/npm/creative-commons-web-component@1.0.2/ccLicense.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACAA,SAAS,gBAAgB,EAAU,EAAW,EAAW,IAEvD,OAAO,EAAS,QADF,cACiB,GAChB,EAAM,MAAM,GAAI,GAAG,OACpB,MAAM,KAAK,QAAO,CAAC,EAAK,IAAQ,EAAI,IAAQ,GAAU,IAEtE,CAKA,SAAS,YAAY,GAQnB,OAPkB,EAAK,MAAM,KACS,KAAI,CAAC,EAAM,IACrC,IAAN,EACK,EAAK,OAAO,GAAG,cAAgB,EAAK,MAAM,GAE5C,IAEkB,KAAK,GAClC,CAEA,IAAI,WACF,uRAEE,aAAe,+CAenB,MAAM,kBAAkB,YACtB,WAAA,GACE,QAIA,KAAK,oBAAsB,CACzB,UACA,cACA,aACA,OACA,aACA,SACA,oBACA,kBACA,cACA,UAKF,KAAK,gBAAkB,CACrB,YACA,SACA,mBACA,iBACA,cACA,UAKF,KAAK,QAAU,CACb,MAAO,oCACP,MAAO,0CACP,MAAO,yCACP,KAAM,mCACN,QAAS,sCACT,YAAa,kDAEjB,CAOA,UAAA,CAAW,EAAS,GAClB,IAAI,EACA,EACA,EACJ,OAAQ,GACN,IAAK,KACH,EAAQ,cACR,MAEF,IAAK,QACH,EAAQ,4BACR,MAEF,IAAK,WACH,EAAQ,0CACR,MAEF,IAAK,WACH,EAAQ,uCACR,MAEF,IAAK,QACH,EAAQ,4BACR,MAEF,IAAK,QACH,EAAQ,yBACR,MAEF,QACE,EAAU,KACV,EAAQ,cAGZ,OAAQ,GACN,IAAK,QACL,IAAK,QAAS,CACZ,MAAM,EAAa,EAAS,MAAM,KAClC,EAAc,SAAS,EAAW,IAClC,EAAa,SAAS,EAAW,IACjC,KACF,CACA,QACE,EAAW,QACX,EAAc,GACd,EAAa,GAGjB,MAAO,CACL,IAAK,uCAAuC,SAC5C,MAAO,mCAAmC,SAAe,QACzD,cACA,aACA,MAAO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AO,aAAc","file":"/npm/creative-commons-web-component@1.0.2/ccLicense.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/creative-commons-web-component@1.0.2/ccLicense.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Replace the variables in the template\n * @param {string} template - The html template\n * @param {object} variables - The variables that going to be replaced in the document\n * @param {string} [fallback=''] - A fallback to replace the variable in case it's not included in the variables parameter\n */\nfunction prepareTemplate(template, variables, fallback = '') {\n  const regex = /\\${[^{]+}/g;\n  return template.replace(regex, match => {\n    const path = match.slice(2, -1).trim();\n    return path.split('.').reduce((res, key) => res[key] || fallback, variables);\n  });\n}\n/**\n * Conver an attribute (separated by -) to camel case string\n * @param {string} attr - The attribute to convert\n */\nfunction attrToCamel(attr) {\n  const attrParts = attr.split('-');\n  const arrrPartsCapitalice = attrParts.map((part, i) => {\n    if (i !== 0) {\n      return part.charAt(0).toUpperCase() + part.slice(1);\n    }\n    return part;\n  });\n  return arrrPartsCapitalice.join('');\n}\n\nvar cc_license =\n  '<a rel=\"license\" href=\"${url}\" class=\"image\"><img width=\"${imageWidth}\" height=\"${imageHeight}\" alt=\"Creative Commons License\" src=\"${image}\"></a><br>${work} ${attribution} is licensed under a <a rel=\"license\" href=\"${url}\" class=\"title\">${title}</a>. ${source} ${permissions}';\n\nvar cc_license$1 = 'cc-license img{border-width:0;font-size:8px}';\n\n/**\n * The Creative Commons web component\n * @attr {'by' | 'by-nc' | 'by-nc-nd' | 'by-nc-sa' | 'by-nd' | 'by-sa'} license - Choose the license (overwrites adaptations & commercial)\n * @attr {'yes' | 'no' | 'share-alike'} adaptations - Allow adaptations of your work to be shared?\n * @attr {Boolean} commercial - Allow commercial uses of your work?\n * @attr {'88x31' | '80x15'} icon - The icon size\n * @attr {String} work-title - The title of the work you are licensing.\n * @attr {String} source - The URL of the work upon which this work is based or derived.\n * @attr {String} attribution-title - The name of the person who should receive attribution for the work. Most often, this is the author.\n * @attr {String} attribution-url - The URL to which the work should be attributed.\n * @attr {String} permissions - A URL where a user can find information about obtaining rights that are not already permitted by the CC license.\n * @attr {'audio' | 'video' | 'image' | 'text' | 'dataset' | 'interactive'} format - Describes what kind of work is being licensed.\n **/\nclass CcLicense extends HTMLElement {\n  constructor() {\n    super();\n    /**\n     * Allowed attributes that can be passed to the component.\n     */\n    this.componentAttributes = [\n      'license',\n      'adaptations',\n      'commercial',\n      'icon',\n      'work-title',\n      'source',\n      'attribution-title',\n      'attribution-url',\n      'permissions',\n      'format',\n    ];\n    /**\n     * Available fields in license metadata.\n     */\n    this.licenseMetadata = [\n      'workTitle',\n      'source',\n      'attributionTitle',\n      'attributionUrl',\n      'permissions',\n      'format',\n    ];\n    /**\n     * Available format to describes what kind of work is being licensed.\n     */\n    this.formats = {\n      audio: 'http://purl.org/dc/dcmitype/Sound',\n      video: 'http://purl.org/dc/dcmitype/MovingImage',\n      image: 'http://purl.org/dc/dcmitype/StillImage',\n      text: 'http://purl.org/dc/dcmitype/Text',\n      dataset: 'http://purl.org/dc/dcmitype/Dataset',\n      interactive: 'http://purl.org/dc/dcmitype/InteractiveResource',\n    };\n  }\n  /**\n   * Get the correct license based on the license shortname.\n   * @param license - options: \"by\" (default if sting is not one of the availables)\n   *               | \"by-nc\" | \"by-nc-nd\" | \"by-nc-sa\" | \"by-nd\" | \"by-sa\"\n   * @param iconSize - The size of the icon. options: 88x31(default if null) | 80x15\n   */\n  getLicense(license, iconSize) {\n    let title;\n    let imageHeight;\n    let imageWidth;\n    switch (license) {\n      case 'by': {\n        title = 'Attribution';\n        break;\n      }\n      case 'by-nc': {\n        title = 'Attribution-NonCommercial';\n        break;\n      }\n      case 'by-nc-nd': {\n        title = 'Attribution-NonCommercial-NoDerivatives';\n        break;\n      }\n      case 'by-nc-sa': {\n        title = 'Attribution-NonCommercial-ShareAlike';\n        break;\n      }\n      case 'by-nd': {\n        title = 'Attribution-NoDerivatives';\n        break;\n      }\n      case 'by-sa': {\n        title = 'Attribution-ShareAlike';\n        break;\n      }\n      default: {\n        license = 'by';\n        title = 'Attribution';\n      }\n    }\n    switch (iconSize) {\n      case '80x15':\n      case '88x31': {\n        const imageSizes = iconSize.split('x');\n        imageHeight = parseInt(imageSizes[1]);\n        imageWidth = parseInt(imageSizes[0]);\n        break;\n      }\n      default: {\n        iconSize = '88x31';\n        imageHeight = 31;\n        imageWidth = 88;\n      }\n    }\n    return {\n      url: `http://creativecommons.org/licenses/${license}/4.0/`,\n      image: `https://i.creativecommons.org/l/${license}/4.0/${iconSize}.png`,\n      imageHeight,\n      imageWidth,\n      title: `Creative Commons ${title} 4.0 International License`,\n    };\n  }\n  /**\n   * Choose the correct license based on the attributes pased to the element.\n   * @param adaptations - options: 'yes' | 'no' | 'share-alike'\n   * @param commercial\n   * @param icon\n   */\n  chooseLicense(adaptations, commercial, icon) {\n    switch (adaptations) {\n      case 'yes': {\n        if (commercial) {\n          return this.getLicense('by', icon);\n        } else {\n          return this.getLicense('by-nc', icon);\n        }\n      }\n      case 'no': {\n        if (commercial) {\n          return this.getLicense('by-nd', icon);\n        } else {\n          return this.getLicense('by-nc-nd', icon);\n        }\n      }\n      case 'share-alike': {\n        if (commercial) {\n          return this.getLicense('by-sa', icon);\n        } else {\n          return this.getLicense('by-nc-sa', icon);\n        }\n      }\n    }\n    return this.getLicense('by', icon);\n  }\n  /**\n   * Recover the license metadata from the attributes passed to the element\n   * @param attributes\n   */\n  getMetadata(attributes) {\n    const metadata = {};\n    this.licenseMetadata.forEach(dataAttribute => {\n      if (attributes[dataAttribute]) {\n        if (dataAttribute === 'format') {\n          const attrLowerCase = attributes[dataAttribute].toLowerCase();\n          metadata.format = this.formats[attrLowerCase];\n        } else {\n          metadata[dataAttribute] = attributes[dataAttribute];\n        }\n      }\n    });\n    return metadata;\n  }\n  /**\n   * Generate the license data based on the attributes of the element\n   * @param attributes\n   */\n  generateLicense(attributes) {\n    let license;\n    const icon = attributes.icon;\n    if (attributes.license) {\n      // If the attribute license is defined use it\n      license = this.getLicense(attributes.license, icon);\n    } else {\n      // If no attribute license try to build the license from other attributes\n      const adaptations = attributes.adaptations;\n      const commercial = attributes.commercial\n        ? // if commercial attribute exists transform to boolean\n          attributes.commercial === 'true'\n        : // if not return true\n          true;\n      license = this.chooseLicense(adaptations, commercial, icon);\n    }\n    // Get license metadata\n    const metadata = this.getMetadata(attributes);\n    if (Object.entries(metadata).length !== 0) {\n      license.metadata = metadata;\n    }\n    return license;\n  }\n  /**\n   * Generate the temaplte variables based on the license data\n   * @param license\n   */\n  generateTemplateVariables(license) {\n    var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n    const variables = {\n      url: license.url,\n      imageWidth: license.imageWidth,\n      imageHeight: license.imageHeight,\n      image: license.image,\n      title: license.title,\n      work: 'This work',\n      attribution: '',\n      source: '',\n      permissions: '',\n    };\n    // Put the correct title and format if defined\n    if (\n      ((_a = license.metadata) === null || _a === void 0 ? void 0 : _a.workTitle) ||\n      ((_b = license.metadata) === null || _b === void 0 ? void 0 : _b.format)\n    ) {\n      let typeMetaData = '';\n      if ((_c = license.metadata) === null || _c === void 0 ? void 0 : _c.format) {\n        typeMetaData = `href=\"${license.metadata.format}\" rel=\"dct:type\"`;\n      }\n      if ((_d = license.metadata) === null || _d === void 0 ? void 0 : _d.workTitle) {\n        variables.work = `<span xmlns:dct=\"http://purl.org/dc/terms/\" property=\"dct:title\" ${typeMetaData}>${license.metadata.workTitle}</span>`;\n      } else {\n        variables.work = `This <span ${typeMetaData}>work</span>`;\n      }\n    }\n    // Put the correct attribution data if defined\n    if (\n      ((_e = license.metadata) === null || _e === void 0 ? void 0 : _e.attributionTitle) ||\n      ((_f = license.metadata) === null || _f === void 0 ? void 0 : _f.attributionUrl)\n    ) {\n      const attributionMetaData =\n        'xmlns:cc=\"http://creativecommons.org/ns#\" property=\"cc:attributionName\"';\n      if ((_g = license.metadata) === null || _g === void 0 ? void 0 : _g.attributionUrl) {\n        variables.attribution = `\n        by\n        <a \n          ${attributionMetaData}\n          href=\"${license.metadata.attributionUrl}\" \n          rel=\"cc:attributionURL\"\n        >${license.metadata.attributionTitle || license.metadata.attributionUrl}</a>`;\n      } else {\n        variables.attribution = `\n        by\n        <span ${attributionMetaData}>${license.metadata.attributionTitle}</span>`;\n      }\n    }\n    // Put the correct source work if defined\n    if ((_h = license.metadata) === null || _h === void 0 ? void 0 : _h.source) {\n      variables.source = `\n      <br />\n      Based on a work at \n      <a \n        xmlns:dct=\"http://purl.org/dc/terms/\"\n        href=\"${license.metadata.source}\"\n        rel=\"dct:source\"\n      >${license.metadata.source}</a>.`;\n    }\n    // Put the correct permissions url if defined\n    if ((_j = license.metadata) === null || _j === void 0 ? void 0 : _j.permissions) {\n      variables.permissions = `\n      <br />\n      Permissions beyond the scope of this license may be available at\n      <a \n        xmlns:cc=\"http://creativecommons.org/ns#\"\n        href=\"${license.metadata.permissions}\"\n        rel=\"cc:morePermissions\"\n      >${license.metadata.permissions}</a>.`;\n    }\n    return variables;\n  }\n  /**\n   * Executed when the custom element is added to the page.\n   */\n  connectedCallback() {\n    // Add the main template to the component\n    const templateElement = document.createElement('template');\n    // Add stylesheet\n    templateElement.innerHTML = `<style>${cc_license$1}</style>`;\n    // Recover all the attributes so we can add them to the template\n    // All attributes are converted to cameCase.\n    // ex: data-attribute => dataAttribute\n    const attributes = {};\n    this.componentAttributes.forEach(attribute => {\n      const key = attrToCamel(attribute);\n      attributes[key] = this.getAttribute(attribute);\n    });\n    // Generate the license date\n    const license = this.generateLicense(attributes);\n    // Generate the template variables based on the license data\n    const templateVariables = this.generateTemplateVariables(license);\n    // Prepare template\n    templateElement.innerHTML += prepareTemplate(cc_license, templateVariables, '');\n    // Attach template content to the dom inside the element\n    this.appendChild(templateElement.content.cloneNode(true));\n  }\n}\n\nwindow.customElements.define('cc-license', CcLicense);\n"]}