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CAAyB,EAAM,EAAU,GAC1B,QAAT,GAAkB,IAAa,GACjC,KAAK,WAET,EAIF,eAAe,OAAO,0BAA2B,uBAEjD,QAAQ,IAAI","file":"/npm/@synapsmedia/ghost-activitypub-embed@0.3.0/ghap-embed.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@synapsmedia/ghost-activitypub-embed@0.3.0/ghap-embed.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const styles = `\n:host {\n  display: block;\n}\n.feed-container {\n  --background-color: var(--ghap-background-color, #fff);\n  --text-color: var(--ghap-text-color, #000);\n  --padding: var(--ghap-padding, 1rem);\n\n  font-family: var(--ghap-font-family, var(--gh-font-body, Inter -apple-system BlinkMacSystemFont 'avenir next' avenir 'helvetica neue' helvetica ubuntu roboto noto 'segoe ui' arial sans-serif));\n  font-size: var(--ghap-font-size, 10px);\n  max-width: 100%;\n  border-radius: var(--ghap-border-radius, 10px);\n  border-color: var(--ghap-border-color, rgb(229, 233, 235));\n  border-style: solid;\n  border-width: var(--ghap-border-width, 1px);\n  overflow: hidden;\n}\n.feed-container :where(*:not(dialog)) {\n  box-sizing: border-box;\n  margin: 0;\n  padding: 0;\n}\n.profile-header {\n  border-bottom: 1px solid var(--ghap-border-color, rgb(229, 233, 235));\n  padding-bottom: var(--padding);\n}\n.profile-image {\n  width: 100%;\n  height: 300px;\n  object-fit: cover;\n}\n.profile-icon {\n  --icon-size: var(--profile-icon-size, 90px);\n  --icon-border-size: var(--profile-icon-border-size, 5px);\n  width: var(--icon-size);\n  height: var(--icon-size);\n  border-radius: 50%;\n  border: var(--icon-border-size) solid var(--ghap-background-color);\n  margin-top: calc((var(--icon-size) / -2) - var(--icon-border-size));\n  background-color: #fff;\n  margin-left: var(--padding);\n  outline: #15171a1a;\n}\n.profile-name {\n  font-size: 2.2em;\n  padding-inline: var(--padding);\n}\n.profile-username,\n.profile-description {\n  font-size: 1.5em;\n  padding-inline: var(--padding);\n}\n.feed-item {\n  --icon-size: var(--ghap-feed-item-icon-size, 40px);\n  display: flex;\n  flex-direction: column;\n  margin-bottom: 1rem;\n  padding: var(--ghap-feed-vertical-gap, 1rem);\n  border-bottom: 1px solid var(--ghap-border-color, rgb(229, 233, 235));\n}\n.feed-item:last-child {\n  border-bottom: none;\n}\n.feed-author {\n  display: flex;\n  gap: 1rem;\n}\n.feed-author .feed-author-avatar {\n  width: var(--icon-size);\n}\n.feed-author .feed-author-avatar img {\n  width: var(--icon-size);\n  height: var(--icon-size);\n  border-radius: 50%;\n}\n.feed-author .feed-author-meta {\n  display: flex;\n  flex-direction: column;\n}\n.feed-author .feed-author-meta .feed-author-name {\n  font-weight: 600;\n  font-size: 1.4em;\n  color: rgb(21, 23, 26);\n}\n.feed-author .feed-author-meta .feed-author-username {\n  color: rgb(124 139 154);\n  font-size: 1.3em;\n}\n.feed-item-content {\n  margin: 0.5em 0;\n  padding-left: calc(var(--icon-size) + 1em);\n  font-size: 1.4em;\n  color: rgb(57, 64, 71);\n}\n.feed-item-date {\n  color: rgb(124 139 154);\n  font-size: 1.3em;\n}\n.feed-item .feed-item-image {\n  max-width: 100%;\n  max-height: 200px;\n  height: auto;\n  margin-top: 0.5rem;\n  border-radius: 4px;\n}\n.loading {\n  padding: 1rem;\n  text-align: center;\n  color: #666;\n}\n.error {\n  padding: 1rem;\n  color: #e53935;\n  border: 1px solid #e53935;\n  border-radius: 4px;\n}\ndialog {\n  border: none;\n  padding: 0;\n  background: transparent;\n  width: 100%;\n}\ndialog::backdrop {\n  background-color: rgba(0, 0, 0, 0.7);\n}\ndialog button {\n  position: fixed;\n  top: 20px;\n  right: 20px;\n  font-size: 20px;\n  background-color: rgba(21, 23, 26, 0.5);\n  color: #fff;\n  border: none;\n  border-radius: 50%;\n  width: 44px;\n  height: 44px;\n  display: flex;\n  justify-content: center;\n  vertical-align: middle;\n  align-items: center;\n}\ndialog .feed-item-image {\n  display: block;\n  margin: auto;\n  max-width: 100vw;\n  max-height: 100vh;\n}\n`\n\nclass GhostActivityPubEmbed extends HTMLElement {\n    constructor() {\n      super();\n      this.attachShadow({ mode: 'open' });\n      \n      // Default styles\n      this.shadowRoot.innerHTML = `\n        <style>\n          ${styles}\n        </style>\n        <div class=\"feed-container\" part=\"container\">\n          <div class=\"loading\">Loading activity feed...</div>\n        </div>\n      `;\n    }\n  \n    static get observedAttributes() {\n      return ['url'];\n    }\n  \n    /**\n     * Format a date string in a more readable format\n     */\n    formatDate(dateStr) {\n      const date = new Date(dateStr);\n      return new Intl.DateTimeFormat('en-US', {\n        // year: 'numeric',\n        month: 'short',\n        day: 'numeric',\n      }).format(date);\n    }\n  \n    renderProfileHeader(profileData) {\n      return `\n        <div class=\"profile-header\" part=\"header\">\n          <img class=\"profile-image\" src=\"${profileData.image.url}\">\n          <div class=\"profile-info\">\n            <img class=\"profile-icon\" src=\"${profileData.icon.url}\">\n            <h2 class=\"profile-name\">${profileData.name}</h2>\n            <p class=\"profile-username\">@${profileData.preferredUsername}@${profileData.serverHost}</p>\n            <p class=\"profile-description\">${profileData.summary}</p>\n          </div>\n        </div>`;\n    }\n    /**\n     * Format the feed item content based on its type\n     */\n    renderItem(item, profileData) {\n      // Check if it's a Create activity with a Note\n      if (item.type === 'Create' && item.object && item.object.type === 'Note') {\n        const note = item.object;\n        const published = note.published;\n        let attachment = '';\n        \n        // Handle attachments (images)\n        if (note.attachment && note.attachment.type === 'Image') {\n          attachment = `<img class=\"feed-item-image\" src=\"${note.attachment.url}\" alt=\"Attached image\">`;\n        }\n        \n        return `\n          <div class=\"feed-item\" part=\"feed-item\">\n            <div class=\"feed-author\" part=\"feed-author\">\n              <div class=\"feed-author-avatar\" part=\"feed-author-avatar\">\n                <img src=\"${profileData.icon.url}\">\n              </div>\n              <div class=\"feed-author-meta\" part=\"feed-author-meta\">\n                <div class=\"feed-author-name\">${profileData.name}</div>\n                <div class=\"feed-author-username\">@${profileData.preferredUsername}@${profileData.serverHost} · <span class=\"feed-author-date\">${this.formatDate(published)}</span></div>\n              </div>\n            </div>\n            <div class=\"feed-item-content\" part=\"feed-item-content\">\n              ${ note.content }\n              ${attachment}\n            </div>\n          </div>\n        `;\n      } \n      else {\n        return ``;\n      }\n    }\n  \n    /**\n     * Fetch and display feed data\n     */\n    async fetchFeed() {\n\n      const url = new URL(this.getAttribute('url') || document.location.href);\n      \n      try {\n        // Fetch the main outbox\n        const response = await fetch(`${url.origin}/.ghost/activitypub/outbox/index`, {\n          headers: {\n            accept: 'application/activity+json'\n          }\n        });\n        if (!response.ok) {\n          throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n        const outboxData = await response.json();\n        \n        // Check if it has a \"first\" property to fetch the items\n        if (!outboxData.first) {\n          throw new Error('Invalid feed format: missing \"first\" property');\n        }\n        \n        // Fetch the actual items from the \"first\" URL\n        const itemsResponse = await fetch(outboxData.first, {\n          headers: {\n            accept: 'application/activity+json'\n          }\n        });\n        if (!itemsResponse.ok) {\n          throw new Error(`HTTP error! status: ${itemsResponse.status}`);\n        }\n        \n        const itemsData = await itemsResponse.json();\n        \n        // Check if we have items to display\n        if (!itemsData.orderedItems || !Array.isArray(itemsData.orderedItems)) {\n          throw new Error('Invalid feed format: missing \"orderedItems\" array');\n        }\n        \n        // Fetch profile info\n        const profile = await fetch(`${url.origin}/.ghost/activitypub/users/index`)\n        \n        if (!profile.ok) {\n          throw new Error(`HTTP error! status: ${profile.status}`);\n        }\n        \n        const profileData = await profile.json();\n        \n        profileData.serverHost = url.hostname.replace('www.', '');\n\n        const profileHeaderHTML = this.renderProfileHeader(profileData);\n            \n        // Get the first 10 items\n        const items = itemsData.orderedItems.slice(0, 10);\n        \n        // Render the feed items\n        let html = '';\n        if (items.length === 0) {\n          html = '<div class=\"feed-item\">No items in feed</div>';\n        } else {\n          items.forEach(item => {\n            html += this.renderItem(item, profileData);\n          });\n        }\n        \n        const attachmentModal = `<dialog><button><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M18 6 6 18\"></path><path d=\"m6 6 12 12\"></path></svg></button><div class=\"dialog-content\"></div></dialog>`\n        this.shadowRoot.querySelector('.feed-container').innerHTML = `${attachmentModal}${profileHeaderHTML}${html}`;\n        \n      } catch (error) {\n        console.error('Error fetching feed:', error);\n        this.shadowRoot.querySelector('.feed-container').innerHTML = `\n          <div class=\"error\">Error loading feed: ${error.message}</div>\n        `;\n      }\n    }\n    \n    initDialog() {\n      if (this.dialogInitiated) return;\n      \n      this.dialog = this.shadowRoot.querySelector('dialog');\n      this.dialogContent = this.dialog.querySelector('.dialog-content');\n      const dialogCloser = this.dialog.querySelector('button');\n      \n      dialogCloser.addEventListener('click', () => {\n        this.dialog.close();\n      });\n      \n      this.dialogInitiated = true;\n      console.log('dialogInitiated');\n    }\n  \n    showAttachment(content) {\n      console.log('showAttachment');\n      this.initDialog();\n      console.log('sed content')\n      this.dialogContent.innerHTML = content.outerHTML;\n      this.dialog.showModal();\n    }\n  \n    connectedCallback() {\n      console.log('connectedCallback');\n      this.fetchFeed();\n      \n      this.shadowRoot.addEventListener('click', (event) => {\n        if (event.target.matches('.feed-item .feed-item-image')) {\n          this.showAttachment(event.target);\n        }\n      }, false)\n    }\n  \n    attributeChangedCallback(name, oldValue, newValue) {\n      if (name === 'url' && oldValue !== newValue) {\n        this.fetchFeed();\n      }\n    }\n  }\n  \n  // Register the custom element\n  customElements.define('ghost-activitypub-embed', GhostActivityPubEmbed);\n  \n  console.log('ghost-activitypub-embed registered');\n"]}