 import UIKit
 import WebKit
 
-/// follow slot javascript lyfecycle
-/// - Note:
-/// method will be triggered on mainThread or thead from original call
+/// Follow slot javascript lyfecycle
+///
+/// Methods will be triggered on mainThread or thead from original call
+///
 @objc public protocol TeadsWebViewHelperDelegate {
     /// This is called when the teads slot is shown.
     @objc optional func webViewHelperSlotStartToShow()

            }
            self.slotOpener = nil
        }
        if isSlotFound {
            slotOpener?()
        }
    }

    private func createContainerView(topOffset: CGFloat, bottomOffset: CGFloat) -> UIView {


    // MARK: JS Interface

    /// the bootstrap calls this when the slot is updated: slot found or moved to another position due to runtime evolution of the HTML content
    ///
    /// - Parameter position: json describing the position with top/bottom/right/left
    private func onSlotUpdated(position: String?) {
        guard let data = position?.data(using: .utf8),
              let slotPosition = try? JSONDecoder().decode(SlotPosition.self, from: data) else {
            delegate?.webViewHelperOnError?(error: "The json is malformed")
            return
        }
        noSlotTimer?.invalidate()

        if isSlotNotFound {
            // triggered once: only when slot is found
            delegate?.webViewHelperSlotFoundSuccessfully?()
        }

        self.slotPosition = slotPosition
        guard let webView = webView else {
            return
        }
        slotOpportunity?(webView, slotPosition)
        slotOpener?()
        updateAdViewPosition(position: slotPosition)
    }

    // MARK: WKScriptMessageHandler
