Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@volcengine/imagex-hybrid-react

Package Overview
Dependencies
Maintainers
21
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volcengine/imagex-hybrid-react - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2-alpha.1

es/component/utils.d.ts

1

es/component/index.d.ts
export * from './react';
export * from './utils';

2

es/index.js

@@ -1,1 +0,1 @@

import React,{useRef,useEffect}from"react";var extendStatics=function(A,e){return(extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(A,e){A.__proto__=e}:function(A,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t])}))(A,e)};function __extends(A,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=A}extendStatics(A,e),A.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}var __assign=function(){return(__assign=Object.assign||function(A){for(var e,t=1,r=arguments.length;t<r;t++)for(var n in e=arguments[t])Object.prototype.hasOwnProperty.call(e,n)&&(A[n]=e[n]);return A}).apply(this,arguments)};function __rest(A,e){var t={};for(n in A)Object.prototype.hasOwnProperty.call(A,n)&&e.indexOf(n)<0&&(t[n]=A[n]);if(null!=A&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,n=Object.getOwnPropertySymbols(A);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(A,n[r])&&(t[n[r]]=A[n[r]]);return t}function __awaiter(A,o,a,s){return new(a=a||Promise)(function(t,e){function r(A){try{i(s.next(A))}catch(A){e(A)}}function n(A){try{i(s.throw(A))}catch(A){e(A)}}function i(A){var e;A.done?t(A.value):((e=A.value)instanceof a?e:new a(function(A){A(e)})).then(r,n)}i((s=s.apply(A,o||[])).next())})}function __generator(r,n){var i,o,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:A(0),throw:A(1),return:A(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function A(t){return function(A){var e=[t,A];if(i)throw new TypeError("Generator is already executing.");for(;s=c&&e[c=0]?0:s;)try{if(i=1,o&&(a=2&e[0]?o.return:e[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,e[1])).done)return a;switch(o=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,o=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3]))s.label=e[1];else if(6===e[0]&&s.label<a[1])s.label=a[1],a=e;else{if(!(a&&s.label<a[2])){a[2]&&s.ops.pop(),s.trys.pop();continue}s.label=a[2],s.ops.push(e)}}e=n.call(r,s)}catch(A){e=[6,A],o=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}var EMixRenderComponents,EMixRenderRuntime,EPlatform,ValidFormat$1=["webp","avif","heic","jpeg","png"];function getGlobal(){return new Function("return this")()}!function(A){A.LivePlayer="live_player",A.Lottie="lottie_view",A.Image="web_image"}(EMixRenderComponents=EMixRenderComponents||{}),function(A){A.DIG="dig",A.EMBED="embed"}(EMixRenderRuntime=EMixRenderRuntime||{}),function(A){A.ANDROID="Android",A.IOS="iOS",A.UNKNOWN="unknown"}(EPlatform=EPlatform||{});var _systemInfo_,_useragent_,REGEXP_DETECT_PLATFORM=/(Android|iPhone)/;function getUserAgent(){var A;return _useragent_=_useragent_||(null==(A=getGlobal().navigator)?void 0:A.userAgent)||""}function getSystemInfo(){var A,e;return _systemInfo_||(A=getUserAgent().match(REGEXP_DETECT_PLATFORM),e=EPlatform.UNKNOWN,A&&(e="Android"===A[1]?EPlatform.ANDROID:EPlatform.IOS),_systemInfo_={platform:e}),_systemInfo_}function isAndroid(){return getSystemInfo().platform===EPlatform.ANDROID}var MixRenderCallbackRegistry=function(){function A(){this._records={},this.id=0}return A.prototype.register=function(A){return this.id++,this._records[this.id]=A,this.id},A.prototype.unregister=function(A){this._records[A]=null},A.prototype.dispatch=function(A,e){var t=this._records[A],r=getMixRenderInstance();t&&(null!=(r=null==r?void 0:r.getLogger())&&r.log("callback, callbackId: ".concat(A,"; res: "),e),t(e))},A}(),MixRenderEventDelegate=function(){function A(){this._records={}}return A.prototype.addEventHandler=function(A,e,t){this._records[A]||(this._records[A]={}),this._records[A][e]||(this._records[A][e]=[]),this._records[A][e].push(t)},A.prototype.removeEventHandler=function(A,e,t){var r;this._records[A]&&(t?(r=this._records[A][e])&&-1<(t=r.indexOf(t))&&r.splice(t,1):this._records[A][e]=[])},A.prototype.dispatchEvent=function(A,e,t){this._records[A]&&(A=this._records[A][e])&&A.forEach(function(A){A(t)})},A}(),globalObject$3=getGlobal(),MixRenderLogger=function(){function A(A){this.prefix=A,this.isEnabled=!1,this.isEnabled=this.checkLoggerEnabled()}return A.prototype.log=function(A,e){this.isEnabled&&console.log(this.prefix,A,e)},A.prototype.warn=function(A){this.isEnabled&&console.warn(this.prefix,A)},A.prototype.error=function(A){this.isEnabled&&console.error(this.prefix,A)},A.prototype.checkLoggerEnabled=function(){var A=null==(A=globalObject$3.location)?void 0:A.href.split("?")[1];if(A)for(var e=0,t=A.split("&");e<t.length;e++)if(t[e]==="".concat("__pia_mixrender_logger__","=1"))return!0;return globalObject$3.__pia_mixrender_logger__},A}(),MixRenderCore=function(){function A(){this._id=0,this.CallbackRegistryImpl=MixRenderCallbackRegistry,this.EventDelegateImpl=MixRenderEventDelegate,this.LoggerImpl=MixRenderLogger}return A.prototype.registerImpl=function(A,e){switch(A){case"callbackRegistry":this.CallbackRegistryImpl=e;break;case"eventDelegate":this.EventDelegateImpl=e;break;case"logger":this.LoggerImpl=e}},A.prototype.init=function(){this._callback_registry_=new this.CallbackRegistryImpl,this._event_delegate_=new this.EventDelegateImpl,this._logger_=new this.LoggerImpl("[PIA MixRender]")},A.prototype.getCallbackRegistry=function(){return this._callback_registry_},A.prototype.getEventDelegate=function(){return this._event_delegate_},A.prototype.getLogger=function(){return this._logger_},A.prototype.getConfig=function(){return this._config_},A.prototype.setConfig=function(A){this._config_=A},A.prototype.allocateId=function(){return this._id++},A}();function getMixRenderInstance(){var A,e=getGlobal();return e._mix_render_core_||((A=new MixRenderCore).init(),e._mix_render_core_=A),e._mix_render_core_}function addMixRenderEventHandler(A,e,t){getMixRenderInstance().getEventDelegate().addEventHandler(A,e,t)}function removeMixRenderEventHandler(A,e,t){getMixRenderInstance().getEventDelegate().removeEventHandler(A,e,t)}var _a,globalObject$2=getGlobal();function call(A,e,t,r){var n,i=globalObject$2.byted_mixrender_native;i&&(n=getMixRenderInstance(),r=r?n.getCallbackRegistry().register(r):-1,i.invoke(A,e,JSON.stringify(t),r),n.getLogger().log("invoke, native component id ".concat(A,", command: ").concat(e,", callbackId: ").concat(r,", params: "),t))}function callSync(A,e){var t=globalObject$2.byted_mixrender_native;return null==t||!t.invokeSync||0!==(null==(t=JSON.parse(t.invokeSync(A,JSON.stringify(e))||""))?void 0:t.status)||null==t?void 0:t.data}function allocateId(){return getMixRenderInstance().allocateId()}var globalObject$1=getGlobal();function getMixRenderConfig(){var A,e=getMixRenderInstance();return e.getConfig()||(A=globalObject$1.byted_mixrender_config,e.getLogger().log("nativeConfig",A),A?e.setConfig(A):isAndroid()&&(A=callSync("getFeatures",null),e.setConfig(A),e.getLogger().log("GetFeatures",A))),e.getConfig()}function canIUse(A,e){void 0===e&&(e=!1);var t,r=getMixRenderConfig();return!(!(r&&r.mixrender_component_support_list&&r.mixrender_component_support_list[A])||(t="".concat(r.mixrender_component_support_list[A]),!e&&inBlockList(A,t))||isAndroid()&&1!==(null==(e=null==r?void 0:r.mixrender_runtime_support_list)?void 0:e.embed))}function isRuntimeModeSupport(A){var e;return!isAndroid()||(e=getMixRenderConfig())&&e.mixrender_runtime_support_list&&1===(null==(e=e.mixrender_runtime_support_list)?void 0:e[A])}var BLOCK_LIST={Android:{MixRender:{},PiaMixRender:((_a={})[EMixRenderComponents.LivePlayer]=["1"],_a)},iOS:{MixRender:{}}};function inBlockList(A,e){var t,r=!1,n=[];if(n=(isAndroid()?(t=getMixRenderConfig(),isAndroid()&&t.mixrender_runtime_support_list?BLOCK_LIST.Android.PiaMixRender:BLOCK_LIST.Android.MixRender):BLOCK_LIST.iOS.MixRender)[A])for(var i=0,o=n;i<o.length;i++)if(o[i]===e){r=!0;break}return r}function translateMixRenderCallbackResponse(A){switch(A){case 0:return[!0];case-1:return[!1,"unknown function error"];case-2:return[!1,"error occurs when initializing"];case-3:return[!1,"call method with wrong params"];default:return[!1,"unknown error occurs"]}}var AdapterImpl,LegacyAdapter=function(){function A(A,e,t){this.id=A,this.type=e,this.mode=t}return A.prototype.init=function(A){var t=this;return new Promise(function(e){call(t.id,"initialize",{type:t.type,properties:A},function(A){A=A.status;e(translateMixRenderCallbackResponse(A))})})},A.prototype.update=function(A){var t=this;return new Promise(function(e){call(t.id,"update",{type:t.type,properties:A},function(A){A=A.status;e(translateMixRenderCallbackResponse(A))}),isAndroid()||e([!0])})},A.prototype.destroy=function(A){var t=this;return void 0===A&&(A={}),new Promise(function(e){call(t.id,"destroy",{type:t.type,properties:A},function(A){A=A.status;e(translateMixRenderCallbackResponse(A))}),isAndroid()||e([!0])})},A.prototype.log=function(A){var t=this;return new Promise(function(e){call(t.id,"debugLog",{type:t.type,properties:A},function(A){A=A.status;e(translateMixRenderCallbackResponse(A))}),isAndroid()||e([!0])})},A.prototype.invoke=function(A){A.method,A.params;A=__rest(A,["method","params"]);return this.update(A)},A.prototype.addEventListener=function(A,e){addMixRenderEventHandler(this.id,A,e)},A.prototype.removeEventListener=function(A,e){removeMixRenderEventHandler(this.id,A,e)},A}(),PiaMixRenderAdapter=function(A){function e(){return null!==A&&A.apply(this,arguments)||this}return __extends(e,A),e.prototype.init=function(t){var r=this;return new Promise(function(e){var A={type:r.type,properties:t};"embed"===r.mode&&(A.mode="embed"),call(r.id,"initialize",A,function(A){A=A.status;e(translateMixRenderCallbackResponse(A))})})},e.prototype.invoke=function(r){var n=this;return new Promise(function(e){var A=r.method,t=r.params;call(n.id,"invokeMethod",{type:n.type,method:A,params:t},function(A){A=A.status;e(translateMixRenderCallbackResponse(A))})})},e}(LegacyAdapter);function getAdapterImpl(A){var e;return AdapterImpl||(e=getMixRenderConfig(),AdapterImpl=isAndroid()&&e&&e.mixrender_runtime_support_list?PiaMixRenderAdapter:LegacyAdapter),AdapterImpl}function setupAdapter(A,e,t){return void 0===t&&(t="dig"),new(getAdapterImpl())(A,e,t)}var TRANSFORM_BASE_BETWEEN_ID_AND_RGBA=255;function createPlaceholder4Android(A,e,t){var r;return"dig"===t?(A.setAttribute("tt-render-in-browser",String(e)),{destroy:function(){A.removeAttribute("tt-render-in-browser")}}):((r=document.createElement("embed")).setAttribute("tt-embed-id",String(e)),r.setAttribute("type","ttplugin/hybrid_component"),r.style.width="100%",r.style.height="100%",A.appendChild(r),{destroy:function(){A.removeChild(r)}})}function createPlaceholder4IOS(A,e){var t={overflow:A.style.overflow,"-webkit-overflow-scrolling":A.style["-webkit-overflow-scrolling"],backgroundColor:A.style.backgroundColor},r=Math.floor(e/TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),e=Math.floor(e%TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),n=(A.style.overflow="scroll",A.style["-webkit-overflow-scrolling"]="touch",A.style.backgroundColor="rgba(13, ".concat(r,", ").concat(e,", 0.13)"),document.createElement("div")),i=(n.style.width="100%",n.style.height="100%",A.appendChild(n),document.createElement("div"));return i.style.height="1px",A.appendChild(i),{destroy:function(){A.removeChild(n),A.removeChild(i),Object.assign(A.style,t)}}}function createPlaceholder(A,e,t){return isAndroid()?createPlaceholder4Android(A,e,t):createPlaceholder4IOS(A,e)}function callback(A,e){var t=getMixRenderInstance();t.getLogger().log("invoke native method callback, with: callbackId: ".concat(A,", res:"),e),t.getCallbackRegistry().dispatch(A,JSON.parse(e))}function invoke(A,e,t){var r=getMixRenderInstance();r.getLogger().log("trigger native event, with: id: ".concat(A,", command: ").concat(e,", params: "),t),r.getEventDelegate().dispatchEvent(A,e,JSON.parse(t))}var globalObject=getGlobal();function setupMixRenderWebHandle(){globalObject.byted_mixrender_web||(globalObject.byted_mixrender_web={invoke:invoke,callback:callback})}function getUsableRuntimeMode(A){return A||(isRuntimeModeSupport("embed")?"embed":"dig")}setupMixRenderWebHandle();var RegExp4Percentage=/(\d+)%/,RegExp4Pixel=/(\d+)px/,ImageWidget4Native=function(){function A(A){this.config=A,this.id=allocateId(),this.mode=getUsableRuntimeMode(this.config.mode),this.adapter=setupAdapter(this.id,EMixRenderComponents.Image,this.mode),this.cornerRadiusMatchRes4Percent=null==(A=this.config.cornerRadius)?void 0:A.match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=null==(A=this.config.cornerRadius)?void 0:A.match(RegExp4Pixel),this.updateCornerRadiusWhenResize=this.updateCornerRadiusWhenResize.bind(this)}return A.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){var e,t,r;return __generator(this,function(A){switch(A.label){case 0:return e=this.config.container,t=e.style.opacity||"1",e.style.opacity="0.1",this.placeholder=createPlaceholder(e,this.id,this.mode),(r=this.config).container,r.renderer,r.mode,r.cornerRadius,r=__rest(r,["container","renderer","mode","cornerRadius"]),this.log("widget init"),[4,this.adapter.init(__assign(__assign({},r),{cornerRadius:this.getCornerRadius()}))];case 1:return r=A.sent(),e.style.opacity=t,r[0]&&(this.cornerRadiusMatchRes4Percent&&window.addEventListener("resize",this.updateCornerRadiusWhenResize),e.style.background="rgba(0,0,0,0)"),[2,r]}})})},A.prototype.setSrc=function(A){return this.adapter.update({src:A})},A.prototype.setObjectFit=function(A){return this.adapter.update({objectFit:A})},A.prototype.setCornerRadius=function(A){return this.cornerRadiusMatchRes4Percent=(A=void 0===A?"":A).match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=A.match(RegExp4Pixel),this.adapter.update({cornerRadius:this.getCornerRadius()})},A.prototype.log=function(A){return this.adapter.log({webLog:A})},A.prototype.destroy=function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(A){switch(A.label){case 0:return[4,this.adapter.destroy()];case 1:return(e=A.sent())[0]&&(this.placeholder.destroy(),this.cornerRadiusMatchRes4Percent)&&window.removeEventListener("resize",this.updateCornerRadiusWhenResize),[2,e]}})})},A.prototype.updateCornerRadiusWhenResize=function(){var A=this.getCornerRadius();this.adapter.update({cornerRadius:A})},A.prototype.getCornerRadius=function(){var A=this.config.container;return this.cornerRadiusMatchRes4Percent?A.getBoundingClientRect().width*+this.cornerRadiusMatchRes4Percent[1]/100:this.cornerRadiusMatchRes4Pixel?+this.cornerRadiusMatchRes4Pixel[1]:void 0},A}(),ImageWidget4Web=function(){function A(A){this.config=A}return A.prototype.init=function(){var A=this.config,e=A.container,t=A.src,r=A.objectFit,A=A.cornerRadius;return this.image=new Image,this.image.style.width="100%",this.image.style.height="100%",this.image.src=t,this.image.style.objectFit=r,this.image.style.borderRadius="".concat(A,"px"),e.appendChild(this.image),Promise.resolve([!0])},A.prototype.setSrc=function(A){return this.image.src=A,Promise.resolve([!0])},A.prototype.setObjectFit=function(A){return this.image.style.objectFit=A,Promise.resolve([!0])},A.prototype.setCornerRadius=function(A){return this.image.style.borderRadius=A=void 0===A?"":A,Promise.resolve([!0])},A.prototype.log=function(A){return Promise.resolve([!0])},A.prototype.destroy=function(){return this.config.container.removeChild(this.image),Promise.resolve([!0])},A}(),ValidFormat=["webp","avif","heic","jpeg","png"],FormatsMap={webp:"awebp",heic:"heif",avif:"avis",jpeg:"jpeg",png:"png"},ErrorImageXUrl={protocol:"http://",domain:"",src:"",search:"",template:"",suffix:""},ErrorUrl={protocol:"http://",domain:"",src:"",search:""},imagexUrlPattern=/^(.+)~(tplv-[a-zA-Z0-9]{2,10}-.+)\.([a-zA-Z]+)\??(.*)$/,FORMAT_BASE64_MAP={webp:{base64:"data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvn8AnAAdQiUpUov+BiOh/AAA=",height:160},heic:{base64:"data:image/heic;base64,AAAAHGZ0eXBtaWYxAAAAAG1pZjFoZWljaGV2YwAAASVtZXRhAAAAAAAAACFoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAAAAAAA5waXRtAAAAAAABAAAAI2lpbmYAAAAAAAEAAAAVaW5mZQIAAAAAAQAAaHZjMQAAAACjaXBycAAAAIZpcGNvAAAAamh2Y0MBAWAAAAAAAAAAAAAe8AD8/fj4AAAPAyAAAQAYQAEMAf//AWAAAAMAAAMAAAMAAAMAHvAkIQABAB1CAQEBYAAAAwAAAwAAAwAAAwAeoDSBp3eX5JMrICIAAQAHRAHBLGDEgAAAABRpc3BlAAAAAAAAAGQAAABkAAAAFWlwbWEAAAAAAAAAAQABAoECAAAAJGlsb2MBAAAAREAAAQABAAAAAAAAAUkAAQAAAAAAAAAgAAAAKG1kYXQAAAAcJgGvJRNg+cJYeUBAgVGpfj2xh5SigAAENABAQA==",height:100},avif:{base64:"data:image/avif;base64,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",height:1}},check=function(r){return 0<=ValidFormat.indexOf(r)&&("jpeg"===r||"png"===r||!!FORMAT_BASE64_MAP[r]&&new Promise(function(e){if("undefined"==typeof window&&e(!1),void 0!==window["__support_".concat(r,"__")])e(!!window["__support_".concat(r,"__")]);else{if(FORMAT_BASE64_MAP[r].prerequisite)if(!FORMAT_BASE64_MAP[r].prerequisite())return window["__support_".concat(r,"__")]=!1,void e(!1);var t=new Image;t.onload=function(){var A=(null==t?void 0:t.height)===FORMAT_BASE64_MAP[r].height;window["__support_".concat(r,"__")]=A,e(A)},t.onerror=function(){window["__support_".concat(r,"__")]=!1,e(!1)},t.src=FORMAT_BASE64_MAP[r].base64}}))},getFormat=function(o){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(A){switch(A.label){case 0:return[4,new Promise(function(i){__awaiter(void 0,void 0,void 0,function(){var e,t,r,n;return __generator(this,function(A){switch(A.label){case 0:"undefined"==typeof window&&i("image"),e=0,t=o,A.label=1;case 1:if(!(e<t.length))return[3,7];r=t[e],n=!1,A.label=2;case 2:return A.trys.push([2,4,,5]),[4,check(r)];case 3:return n=A.sent(),[3,5];case 4:return A.sent(),console.error("格式探测失败"),[3,5];case 5:if(n)return i(r),[3,7];A.label=6;case 6:return e++,[3,1];case 7:return i("image"),[2]}})})})];case 1:return[2,A.sent()]}})})},parseImagexUrl=function(A){try{var e=A.startsWith("http")?A:(A.startsWith("//")?"https:":"http://").concat(A),t=new URL(e),r=imagexUrlPattern.exec(t.pathname.slice(1));return{protocol:t.protocol,domain:t.hostname,src:r[1],template:r[2],suffix:r[3],search:t.search}}catch(A){return console.error(A),ErrorImageXUrl}},parseOtherUrl=function(A){try{var e=A.startsWith("http")?A:(A.startsWith("//")?"https:":"http://").concat(A),t=new URL(e);return{protocol:t.protocol,domain:t.hostname,src:t.pathname.slice(1),search:t.search}}catch(A){return ErrorUrl}},isImagexUrl=function(A){return imagexUrlPattern.test(A)},isSupportNativeImage=canIUse(EMixRenderComponents.Image),ImageProxy=function(){function A(A){this.config=A,this.isInitialized=!1,this.renderFormat="image"}return A.prototype.init=function(){var i;return __awaiter(this,void 0,void 0,function(){var e,t,r,n;return __generator(this,function(A){switch(A.label){case 0:return e=this.config.renderer,t=this,"web"!==(e=e&&"auto"!==e?e:isSupportNativeImage?"native":"web")?[3,2]:[4,getFormat((this.config.formats||["avif","webp"]).filter(function(A){return"heic"!==A}))];case 1:return r=A.sent()||"image",[3,3];case 2:r=(null==(i=this.config.formats)?void 0:i[0])||"heic",A.label=3;case 3:return t.renderFormat=r,n=__assign(__assign({},this.config),{src:this.getSrc()}),this.widget=new("native"===e?ImageWidget4Native:ImageWidget4Web)(n),[4,this.widget.init()];case 4:return(n=A.sent())[0]&&(this.isInitialized=!0),[2,n]}})})},A.prototype.getSrc=function(A){var e,t,r,n,i,o,A=void 0===A?this.config.src:A;return e=isImagexUrl(A)?(r=(o=parseImagexUrl(A)).src,n=o.protocol,i=o.domain,t=o.suffix,e=o.template,o=o.search,{src:r,format:FormatsMap[this.renderFormat]||"image",extra:{suffix:t,template:e,search:o,protocol:n,domain:i,origin:A}}):(r=(t=parseOtherUrl(A)).src,n=t.protocol,i=t.domain,o=t.search,{src:r,format:FormatsMap[this.renderFormat]||"image",extra:{protocol:n,domain:i,search:o,origin:A}}),this.config.loader(e)},A.prototype.setSrc=function(A){return this.widget.setSrc(this.getSrc(A))},A.prototype.setObjectFit=function(A){return this.widget.setObjectFit(A)},A.prototype.setCornerRadius=function(A){return this.widget.setCornerRadius(A)},A.prototype.destroy=function(){return this.widget.destroy()},A}();function createImageProxy(A){return new ImageProxy(A)}var Viewer=function(e){var A,t=useRef(null),r=useRef(null),n=useRef(r.current&&r.current.isInitialized);return useEffect(function(){var A;n.current=null==(A=r.current)?void 0:A.isInitialized},[null==(A=r.current)?void 0:A.isInitialized]),useEffect(function(){if(t.current)return r.current=createImageProxy({container:t.current,renderer:e.renderer||"auto",src:e.src,loader:e.loader,objectFit:e.objectFit,cornerRadius:e.cornerRadius||"",mode:e.mode,formats:e.formats||["heic","avif","webp"]}),r.current.init().then(function(A){A[0]&&(n.current=!0)}),function(){r.current&&r.current.destroy&&r.current.destroy()}},[]),useEffect(function(){var A;n.current&&null!=(A=r.current)&&A.setSrc(e.src)},[e.src]),useEffect(function(){var A;n.current&&null!=(A=r.current)&&A.setObjectFit(e.objectFit)},[e.objectFit]),useEffect(function(){var A;n.current&&null!=(A=r.current)&&A.setCornerRadius(e.cornerRadius)},[e.cornerRadius]),React.createElement("div",{className:"pia-mixrender-image",style:{width:e.width,height:e.height}},React.createElement("div",{ref:t,style:{width:e.width,height:e.height,fontSize:0,lineHeight:0}}))};export{EMixRenderComponents,EMixRenderRuntime,ImageProxy,ValidFormat$1 as ValidFormat,Viewer,createImageProxy};
import React,{useRef,useEffect}from"react";var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var A in t)Object.prototype.hasOwnProperty.call(t,A)&&(e[A]=t[A])}))(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function A(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(A.prototype=t.prototype,new A)}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,A=1,r=arguments.length;A<r;A++)for(var n in t=arguments[A])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function __rest(e,t){var A={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(A[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(A[n[r]]=e[n[r]]);return A}function __awaiter(e,o,a,s){return new(a=a||Promise)(function(A,t){function r(e){try{i(s.next(e))}catch(e){t(e)}}function n(e){try{i(s.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?A(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(r,n)}i((s=s.apply(e,o||[])).next())})}function __generator(r,n){var i,o,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function e(A){return function(e){var t=[A,e];if(i)throw new TypeError("Generator is already executing.");for(;s=c&&t[c=0]?0:s;)try{if(i=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,o=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))s.label=t[1];else if(6===t[0]&&s.label<a[1])s.label=a[1],a=t;else{if(!(a&&s.label<a[2])){a[2]&&s.ops.pop(),s.trys.pop();continue}s.label=a[2],s.ops.push(t)}}t=n.call(r,s)}catch(e){t=[6,e],o=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}var EMixRenderComponents,EMixRenderRuntime,EPlatform,ValidFormat$1=["webp","avif","heic","jpeg","png"],ValidPlatform=["Android","iOS"];function getGlobal(){return new Function("return this")()}!function(e){e.LivePlayer="live_player",e.Lottie="lottie_view",e.Image="web_image"}(EMixRenderComponents=EMixRenderComponents||{}),function(e){e.DIG="dig",e.EMBED="embed"}(EMixRenderRuntime=EMixRenderRuntime||{}),function(e){e.ANDROID="Android",e.IOS="iOS",e.UNKNOWN="unknown"}(EPlatform=EPlatform||{});var _systemInfo_,_useragent_,REGEXP_DETECT_PLATFORM=/(Android|iPhone)/;function getUserAgent(){var e;return _useragent_=_useragent_||(null==(e=getGlobal().navigator)?void 0:e.userAgent)||""}function getSystemInfo(){var e,t;return _systemInfo_||(e=getUserAgent().match(REGEXP_DETECT_PLATFORM),t=EPlatform.UNKNOWN,e&&(t="Android"===e[1]?EPlatform.ANDROID:EPlatform.IOS),_systemInfo_={platform:t}),_systemInfo_}function isAndroid(){return getSystemInfo().platform===EPlatform.ANDROID}var MixRenderCallbackRegistry=function(){function e(){this._records={},this.id=0}return e.prototype.register=function(e){return this.id++,this._records[this.id]=e,this.id},e.prototype.unregister=function(e){this._records[e]=null},e.prototype.dispatch=function(e,t){var A=this._records[e],r=getMixRenderInstance();A&&(null!=(r=null==r?void 0:r.getLogger())&&r.log("callback, callbackId: ".concat(e,"; res: "),t),A(t))},e}(),MixRenderEventDelegate=function(){function e(){this._records={}}return e.prototype.addEventHandler=function(e,t,A){this._records[e]||(this._records[e]={}),this._records[e][t]||(this._records[e][t]=[]),this._records[e][t].push(A)},e.prototype.removeEventHandler=function(e,t,A){var r;this._records[e]&&(A?(r=this._records[e][t])&&-1<(A=r.indexOf(A))&&r.splice(A,1):this._records[e][t]=[])},e.prototype.dispatchEvent=function(e,t,A){this._records[e]&&(e=this._records[e][t])&&e.forEach(function(e){e(A)})},e}(),globalObject$3=getGlobal(),MixRenderLogger=function(){function e(e){this.prefix=e,this.isEnabled=!1,this.isEnabled=this.checkLoggerEnabled()}return e.prototype.log=function(e,t){this.isEnabled&&console.log(this.prefix,e,t)},e.prototype.warn=function(e){this.isEnabled&&console.warn(this.prefix,e)},e.prototype.error=function(e){this.isEnabled&&console.error(this.prefix,e)},e.prototype.checkLoggerEnabled=function(){var e=null==(e=globalObject$3.location)?void 0:e.href.split("?")[1];if(e)for(var t=0,A=e.split("&");t<A.length;t++)if(A[t]==="".concat("__pia_mixrender_logger__","=1"))return!0;return globalObject$3.__pia_mixrender_logger__},e}(),MixRenderCore=function(){function e(){this._id=0,this.CallbackRegistryImpl=MixRenderCallbackRegistry,this.EventDelegateImpl=MixRenderEventDelegate,this.LoggerImpl=MixRenderLogger}return e.prototype.registerImpl=function(e,t){switch(e){case"callbackRegistry":this.CallbackRegistryImpl=t;break;case"eventDelegate":this.EventDelegateImpl=t;break;case"logger":this.LoggerImpl=t}},e.prototype.init=function(){this._callback_registry_=new this.CallbackRegistryImpl,this._event_delegate_=new this.EventDelegateImpl,this._logger_=new this.LoggerImpl("[PIA MixRender]")},e.prototype.getCallbackRegistry=function(){return this._callback_registry_},e.prototype.getEventDelegate=function(){return this._event_delegate_},e.prototype.getLogger=function(){return this._logger_},e.prototype.getConfig=function(){return this._config_},e.prototype.setConfig=function(e){this._config_=e},e.prototype.allocateId=function(){return this._id++},e}();function getMixRenderInstance(){var e,t=getGlobal();return t._mix_render_core_||((e=new MixRenderCore).init(),t._mix_render_core_=e),t._mix_render_core_}function addMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().addEventHandler(e,t,A)}function removeMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().removeEventHandler(e,t,A)}var _a,globalObject$2=getGlobal();function call(e,t,A,r){var n,i=globalObject$2.byted_mixrender_native;i&&(n=getMixRenderInstance(),r=r?n.getCallbackRegistry().register(r):-1,i.invoke(e,t,JSON.stringify(A),r),n.getLogger().log("invoke, native component id ".concat(e,", command: ").concat(t,", callbackId: ").concat(r,", params: "),A))}function callSync(e,t){var A=globalObject$2.byted_mixrender_native;return null==A||!A.invokeSync||0!==(null==(A=JSON.parse(A.invokeSync(e,JSON.stringify(t))||""))?void 0:A.status)||null==A?void 0:A.data}function allocateId(){return getMixRenderInstance().allocateId()}var globalObject$1=getGlobal();function getMixRenderConfig(){var e,t=getMixRenderInstance();return t.getConfig()||(e=globalObject$1.byted_mixrender_config,t.getLogger().log("nativeConfig",e),e?t.setConfig(e):isAndroid()&&(e=callSync("getFeatures",null),t.setConfig(e),t.getLogger().log("GetFeatures",e))),t.getConfig()}function canIUse(e,t){void 0===t&&(t=!1);var A,r=getMixRenderConfig();return!(!(r&&r.mixrender_component_support_list&&r.mixrender_component_support_list[e])||(A="".concat(r.mixrender_component_support_list[e]),!t&&inBlockList(e,A))||isAndroid()&&1!==(null==(t=null==r?void 0:r.mixrender_runtime_support_list)?void 0:t.embed))}function isRuntimeModeSupport(e){var t;return!isAndroid()||(t=getMixRenderConfig())&&t.mixrender_runtime_support_list&&1===(null==(t=t.mixrender_runtime_support_list)?void 0:t[e])}var BLOCK_LIST={Android:{MixRender:{},PiaMixRender:((_a={})[EMixRenderComponents.LivePlayer]=["1"],_a)},iOS:{MixRender:{}}};function inBlockList(e,t){var A,r=!1,n=[];if(n=(isAndroid()?(A=getMixRenderConfig(),isAndroid()&&A.mixrender_runtime_support_list?BLOCK_LIST.Android.PiaMixRender:BLOCK_LIST.Android.MixRender):BLOCK_LIST.iOS.MixRender)[e])for(var i=0,o=n;i<o.length;i++)if(o[i]===t){r=!0;break}return r}function translateMixRenderCallbackResponse(e){switch(e){case 0:return[!0];case-1:return[!1,"unknown function error"];case-2:return[!1,"error occurs when initializing"];case-3:return[!1,"call method with wrong params"];default:return[!1,"unknown error occurs"]}}var LegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){var A=this;return new Promise(function(t){call(A.id,"initialize",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),SSRLegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){return new Promise(function(e){e([!0])})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),PiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.init=function(A){var r=this;return new Promise(function(t){var e={type:r.type,properties:A};"embed"===r.mode&&(e.mode="embed"),call(r.id,"initialize",e,function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(LegacyAdapter),SSRPiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(SSRLegacyAdapter);function getAdapterImpl(e,t){var A=getMixRenderConfig();return null!=t&&t.hybridRender?"Android"===(null==t?void 0:t.platform)?SSRPiaMixRenderAdapter:SSRLegacyAdapter:isAndroid()&&A&&A.mixrender_runtime_support_list?PiaMixRenderAdapter:LegacyAdapter}function setupAdapter(e,t,A,r){return new(getAdapterImpl(A=void 0===A?"embed":A,r))(e,t,A)}var TRANSFORM_BASE_BETWEEN_ID_AND_RGBA=255;function createPlaceholder4Android(e,t,A){var r;return"dig"===A?(e.setAttribute("tt-render-in-browser",String(t)),{destroy:function(){e.removeAttribute("tt-render-in-browser")}}):((r=document.createElement("embed")).setAttribute("tt-embed-id",String(t)),r.setAttribute("type","ttplugin/hybrid_component"),r.style.width="100%",r.style.height="100%",e.appendChild(r),{destroy:function(){e.removeChild(r)}})}function createPlaceholder4IOS(e,t){var A={overflow:e.style.overflow,"-webkit-overflow-scrolling":e.style["-webkit-overflow-scrolling"],backgroundColor:e.style.backgroundColor},r=Math.floor(t/TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),t=Math.floor(t%TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),n=(e.style.overflow="scroll",e.style["-webkit-overflow-scrolling"]="touch",e.style.backgroundColor="rgba(13, ".concat(r,", ").concat(t,", 0.13)"),document.createElement("div")),i=(n.style.width="100%",n.style.height="100%",e.appendChild(n),document.createElement("div"));return i.style.height="1px",e.appendChild(i),{destroy:function(){e.removeChild(n),e.removeChild(i),Object.assign(e.style,A)}}}function createPlaceholder(e,t,A){return isAndroid()?createPlaceholder4Android(e,t,A):createPlaceholder4IOS(e,t)}function callback(e,t){var A=getMixRenderInstance();A.getLogger().log("invoke native method callback, with: callbackId: ".concat(e,", res:"),t),A.getCallbackRegistry().dispatch(e,JSON.parse(t))}function invoke(e,t,A){var r=getMixRenderInstance();r.getLogger().log("trigger native event, with: id: ".concat(e,", command: ").concat(t,", params: "),A),r.getEventDelegate().dispatchEvent(e,t,JSON.parse(A))}var globalObject=getGlobal();function setupMixRenderWebHandle(){globalObject.byted_mixrender_web||(globalObject.byted_mixrender_web={invoke:invoke,callback:callback})}function getUsableRuntimeMode(e){return e||(isRuntimeModeSupport("embed")?"embed":"dig")}setupMixRenderWebHandle();var RegExp4Percentage=/(\d+)%/,RegExp4Pixel=/(\d+)px/,CSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode=getUsableRuntimeMode(this.config.mode),this.adapter=setupAdapter(this.id,EMixRenderComponents.Image,this.mode),this.cornerRadiusMatchRes4Percent=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Pixel),this.updateCornerRadiusWhenResize=this.updateCornerRadiusWhenResize.bind(this)}return e.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){var t,A,r;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.container,A=t.style.opacity||"1",t.style.opacity="0.1",this.placeholder=createPlaceholder(t,this.id,this.mode),(r=this.config).container,r.renderer,r.mode,r.cornerRadius,r=__rest(r,["container","renderer","mode","cornerRadius"]),this.log("widget init"),[4,this.adapter.init(__assign(__assign({},r),{cornerRadius:this.getCornerRadius()}))];case 1:return r=e.sent(),t.style.opacity=A,r[0]&&(this.cornerRadiusMatchRes4Percent&&window.addEventListener("resize",this.updateCornerRadiusWhenResize),t.style.background="rgba(0,0,0,0)"),[2,r]}})})},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return this.cornerRadiusMatchRes4Percent=(e=void 0===e?"":e).match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=e.match(RegExp4Pixel),this.adapter.update({cornerRadius:this.getCornerRadius()})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&(null!=(A=this.placeholder)&&A.destroy(),this.cornerRadiusMatchRes4Percent)&&window.removeEventListener("resize",this.updateCornerRadiusWhenResize),[2,t]}})})},e.prototype.updateCornerRadiusWhenResize=function(){var e=this.getCornerRadius();this.adapter.update({cornerRadius:e})},e.prototype.getCornerRadius=function(){var e=this.config.container;return this.cornerRadiusMatchRes4Percent?e.getBoundingClientRect().width*+this.cornerRadiusMatchRes4Percent[1]/100:this.cornerRadiusMatchRes4Pixel?+this.cornerRadiusMatchRes4Pixel[1]:void 0},e}(),SSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode="embed"}return e.prototype.init=function(){return this.adapter=setupAdapter(this.id,EMixRenderComponents.Image,this.mode,this.config.ssrConfig),this.id},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return void 0===e&&(e=""),this.adapter.update({cornerRadius:Number(e)})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&null!=(A=this.placeholder)&&A.destroy(),[2,t]}})})},e}(),ImageWidget4Web=function(){function e(e){this.config=e}return e.prototype.init=function(){var e=this.config,t=e.container,A=e.src,r=e.objectFit,e=e.cornerRadius;return this.image=new Image,this.image.style.width="100%",this.image.style.height="100%",this.image.src=A,this.image.style.objectFit=r,this.image.style.borderRadius="".concat(e,"px"),t.appendChild(this.image),Promise.resolve([!0])},e.prototype.setSrc=function(e){return this.image.src=e,Promise.resolve([!0])},e.prototype.setObjectFit=function(e){return this.image.style.objectFit=e,Promise.resolve([!0])},e.prototype.setCornerRadius=function(e){return this.image.style.borderRadius=e=void 0===e?"":e,Promise.resolve([!0])},e.prototype.log=function(e){return Promise.resolve([!0])},e.prototype.destroy=function(){return this.config.container.removeChild(this.image),Promise.resolve([!0])},e}(),ValidFormat=["webp","avif","heic","jpeg","png"],FormatsMap={webp:"awebp",heic:"heif",avif:"avis",jpeg:"jpeg",png:"png"},ErrorImageXUrl={protocol:"http://",domain:"",src:"",search:"",template:"",suffix:""},ErrorUrl={protocol:"http://",domain:"",src:"",search:""},imagexUrlPattern=/^(.+)~(tplv-[a-zA-Z0-9]{2,10}-.+)\.([a-zA-Z]+)\??(.*)$/,FORMAT_BASE64_MAP={webp:{base64:"data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvn8AnAAdQiUpUov+BiOh/AAA=",height:160},heic:{base64:"data:image/heic;base64,AAAAHGZ0eXBtaWYxAAAAAG1pZjFoZWljaGV2YwAAASVtZXRhAAAAAAAAACFoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAAAAAAA5waXRtAAAAAAABAAAAI2lpbmYAAAAAAAEAAAAVaW5mZQIAAAAAAQAAaHZjMQAAAACjaXBycAAAAIZpcGNvAAAAamh2Y0MBAWAAAAAAAAAAAAAe8AD8/fj4AAAPAyAAAQAYQAEMAf//AWAAAAMAAAMAAAMAAAMAHvAkIQABAB1CAQEBYAAAAwAAAwAAAwAAAwAeoDSBp3eX5JMrICIAAQAHRAHBLGDEgAAAABRpc3BlAAAAAAAAAGQAAABkAAAAFWlwbWEAAAAAAAAAAQABAoECAAAAJGlsb2MBAAAAREAAAQABAAAAAAAAAUkAAQAAAAAAAAAgAAAAKG1kYXQAAAAcJgGvJRNg+cJYeUBAgVGpfj2xh5SigAAENABAQA==",height:100},avif:{base64:"data:image/avif;base64,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",height:1}},check=function(r){return 0<=ValidFormat.indexOf(r)&&("jpeg"===r||"png"===r||!!FORMAT_BASE64_MAP[r]&&new Promise(function(t){if("undefined"==typeof window&&t(!1),void 0!==window["__support_".concat(r,"__")])t(!!window["__support_".concat(r,"__")]);else{if(FORMAT_BASE64_MAP[r].prerequisite)if(!FORMAT_BASE64_MAP[r].prerequisite())return window["__support_".concat(r,"__")]=!1,void t(!1);var A=new Image;A.onload=function(){var e=(null==A?void 0:A.height)===FORMAT_BASE64_MAP[r].height;window["__support_".concat(r,"__")]=e,t(e)},A.onerror=function(){window["__support_".concat(r,"__")]=!1,t(!1)},A.src=FORMAT_BASE64_MAP[r].base64}}))},getFormat=function(o){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,new Promise(function(i){__awaiter(void 0,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:"undefined"==typeof window&&i("image"),t=0,A=o,e.label=1;case 1:if(!(t<A.length))return[3,7];r=A[t],n=!1,e.label=2;case 2:return e.trys.push([2,4,,5]),[4,check(r)];case 3:return n=e.sent(),[3,5];case 4:return e.sent(),console.error("格式探测失败"),[3,5];case 5:if(n)return i(r),[3,7];e.label=6;case 6:return t++,[3,1];case 7:return i("image"),[2]}})})})];case 1:return[2,e.sent()]}})})},parseImagexUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t),r=imagexUrlPattern.exec(A.pathname.slice(1));return{protocol:A.protocol,domain:A.hostname,src:r[1],template:r[2],suffix:r[3],search:A.search}}catch(e){return console.error(e),ErrorImageXUrl}},parseOtherUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t);return{protocol:A.protocol,domain:A.hostname,src:A.pathname.slice(1),search:A.search}}catch(e){return ErrorUrl}},isImagexUrl=function(e){return imagexUrlPattern.test(e)},getSrc=function(e,t,A){var r,n,i,o,a,s;return t(isImagexUrl(e)?(i=(t=parseImagexUrl(e)).src,o=t.protocol,a=t.domain,r=t.suffix,n=t.template,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{suffix:r,template:n,search:s,protocol:o,domain:a,origin:e}}):(i=(t=parseOtherUrl(e)).src,o=t.protocol,a=t.domain,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{protocol:o,domain:a,search:s,origin:e}}))},isSupportNativeImage=canIUse(EMixRenderComponents.Image),CSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="image"}return e.prototype.init=function(){var i;return __awaiter(this,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.renderer,A=this,"web"!==(t=t&&"auto"!==t?t:isSupportNativeImage?"native":"web")?[3,2]:[4,getFormat((this.config.formats||["avif","webp"]).filter(function(e){return"heic"!==e}))];case 1:return r=e.sent()||"image",[3,3];case 2:r=(null==(i=this.config.formats)?void 0:i[0])||"heic",e.label=3;case 3:return A.renderFormat=r,n=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,FormatsMap[this.renderFormat]||"image")}),this.widget=new("native"===t?CSRImageWidget4Native:ImageWidget4Web)(n),[4,this.widget.init()];case 4:return(n=e.sent())[0]&&(this.isInitialized=!0),[2,n]}})})},e.prototype.setSrc=function(e){return this.widget.setSrc(getSrc(e,this.config.loader,FormatsMap[this.renderFormat]||"image"))},e.prototype.setObjectFit=function(e){return this.widget.setObjectFit(e)},e.prototype.setCornerRadius=function(e){return this.widget.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}(),SSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="image"}return e.prototype.init=function(){this.renderFormat="heic";var e=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,FormatsMap[this.renderFormat]||"image")}),t=(this.widget=new SSRImageWidget4Native(e),this.widget.init());return this.isInitialized=!0,{id:t,src:e.src}},e.prototype.setSrc=function(e){var t;return null==(t=this.widget)?void 0:t.setSrc(getSrc(e,this.config.loader,FormatsMap[this.renderFormat]||"image"))},e.prototype.setObjectFit=function(e){var t;return null==(t=this.widget)?void 0:t.setObjectFit(e)},e.prototype.setCornerRadius=function(e){var t;return null==(t=this.widget)?void 0:t.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}();function createImageProxy(e){return new(void 0!==e.ssrConfig?SSRImageProxy:CSRImageProxy)(e)}var Viewer=function(t){var e,A,r=useRef(null),n=useRef(null),i=useRef(n.current&&n.current.isInitialized),o=useRef(-1);return useEffect(function(){var e;i.current=null==(e=n.current)?void 0:e.isInitialized},[null==(e=n.current)?void 0:e.isInitialized]),useEffect(function(){if(r.current)return i.current||(n.current=createImageProxy({container:r.current,renderer:t.renderer||"auto",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",formats:t.formats||["heic","avif","webp"]}),n.current.init().then(function(e){e[0]&&(i.current=!0)})),function(){var e;n.current&&n.current.destroy&&null!=(e=n.current)&&e.destroy()}},[]),useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setSrc(t.src)},[t.src]),useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setObjectFit(t.objectFit)},[t.objectFit]),useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setCornerRadius(t.cornerRadius)},[t.cornerRadius]),null!=(e=t.ssrConfig)&&e.isSSR&&null!=(e=t.ssrConfig)&&e.hybridRender&&-1===o.current&&(n.current=createImageProxy({renderer:"native",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",ssrConfig:t.ssrConfig}),e=n.current.init(),o.current=e.id,"undefined"==typeof window&&((A=new Function("return this")()).imagexSsrData||(A.imagexSsrData=[]),A.imagexSsrData.push(__assign(__assign({},e||{}),{width:t.width,height:t.height,objectFit:t.objectFit,cornerRadius:t.cornerRadius||""}))),i.current=!0),React.createElement("div",{className:"pia-mixrender-image",style:{width:t.width,height:t.height}},null!=(A=t.ssrConfig)&&A.isSSR?null!=(e=t.ssrConfig)&&e.hybridRender?"iOS"===(null==(A=t.ssrConfig)?void 0:A.platform)?React.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0,overflow:"scroll",WebkitOverflowScrolling:"touch",backgroundColor:"rgba(13, ".concat(Math.floor(o.current/255),", ").concat(Math.floor(o.current%255),", 0.13)")}},React.createElement("div",{style:{width:"100%",height:"100%"}}),React.createElement("div",{style:{height:1}})):React.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0}},React.createElement("embed",{"tt-embed-id":o.current,type:"ttplugin/hybrid_component",style:{width:"100%",height:"100%"}})):React.createElement("img",{src:getSrc(t.src,t.loader,"image"),style:{width:"100%",height:"100%",objectFit:t.objectFit,borderRadius:"".concat(Number(t.cornerRadius||0),"px")}}):React.createElement("div",{ref:r,style:{width:t.width,height:t.height,fontSize:0,lineHeight:0}}))},exportInitScript=function(){var e,t=new Function("return this")();return t.imagexSsrData?(e='<script type="application/javascript">;(function(e){document.addEventListener("DOMContentLoaded",function(){console.log("ImageX SSR Init");const i=window.byted_mixrender_native;if(i)for(let t=0;t<(e||[]).length;t++)i.invoke(e[t].id,"initialize",JSON.stringify({type:"web_image",properties:{src:e[t].src,width:e[t].width,height:e[t].height,objectFit:e[t].objectFit,cornerRadius:e[t].cornerRadius}}),e[t].id)})})('.concat(JSON.stringify(t.imagexSsrData||[]),")<\/script>"),t._mix_render_core_=void 0,t.imagexSsrData=void 0,e):""};export{CSRImageProxy,EMixRenderComponents,EMixRenderRuntime,SSRImageProxy,ValidFormat$1 as ValidFormat,ValidPlatform,Viewer,createImageProxy,exportInitScript};

@@ -1,4 +0,2 @@

import type { IMixRenderRuntimeMode } from '../../mixrender';
import type { IImageObjectFitValues } from './widget';
import type { IRendererType } from '../../customize';
type ProtocolType = 'http:' | 'https:';

@@ -19,2 +17,8 @@ export type IImageLoaderProps = {

export declare const ValidFormat: readonly ["webp", "avif", "heic", "jpeg", "png"];
export declare const ValidPlatform: readonly ["Android", "iOS"];
export type ISSRConfig = {
isSSR?: boolean;
hybridRender?: boolean;
platform?: typeof ValidPlatform[number];
};
export interface IImageProps {

@@ -28,5 +32,5 @@ width: string | number;

cornerRadius?: string;
renderer?: IRendererType;
mode?: IMixRenderRuntimeMode;
ssrConfig?: ISSRConfig;
[props: string]: unknown;
}
export {};
import type { IMixRenderRuntimeMode } from '../../mixrender';
import type { IImageWidget, IImageObjectFitValues } from './widget';
import type { IRendererType } from '../../customize';
import type { ISSRConfig } from './component';
import { IImageLoader, ValidFormat } from '../image';

@@ -8,3 +9,3 @@ export type IImageProxy = IImageWidget & {

};
export interface IImageProxyConfig {
export interface ISSRImageProxyConfig {
src: string;

@@ -14,2 +15,11 @@ cornerRadius?: string;

loader: IImageLoader;
renderer: IRendererType;
mode?: IMixRenderRuntimeMode;
ssrConfig: ISSRConfig;
}
export interface ICSRImageProxyConfig {
src: string;
cornerRadius?: string;
objectFit?: IImageObjectFitValues;
loader: IImageLoader;
formats?: typeof ValidFormat[number][];

@@ -20,1 +30,2 @@ container: HTMLElement;

}
export type IImageProxyConfig = ISSRImageProxyConfig | ICSRImageProxyConfig;
import type { IImageObjectFitValues } from './native';
export interface IImageWidget {
init(): Promise<[boolean, string?]>;
init: Promise<[boolean, unknown?]> | (() => unknown);
destroy(): Promise<[boolean, string?]>;

@@ -5,0 +5,0 @@ setSrc(src: string): Promise<[boolean, string?]>;

@@ -1,4 +0,4 @@

import { LegacyAdapter } from './legacy';
import type { IMixRenderRuntimeMode } from '../../interface';
export declare function getAdapterImpl(_mode: IMixRenderRuntimeMode): typeof LegacyAdapter;
export declare function setupAdapter<T extends Record<string, any>>(id: number, type: string, mode?: IMixRenderRuntimeMode): LegacyAdapter<T>;
import { LegacyAdapter, SSRLegacyAdapter } from './legacy';
import type { IMixRenderRuntimeMode, ISSRConfig } from '../../interface';
export declare function getAdapterImpl(_mode: IMixRenderRuntimeMode, ssrConfig?: ISSRConfig): typeof LegacyAdapter | typeof SSRLegacyAdapter;
export declare function setupAdapter<T extends Record<string, any>>(id: number, type: string, mode?: IMixRenderRuntimeMode, ssrConfig?: ISSRConfig): LegacyAdapter<T> | SSRLegacyAdapter<T>;

@@ -18,1 +18,17 @@ import type { IMixRenderRuntimeMode } from '../../interface';

}
export declare class SSRLegacyAdapter<P extends Record<string, any> = Record<string, any>> {
protected id: number;
protected type: string;
protected mode: IMixRenderRuntimeMode;
constructor(id: number, type: string, mode: IMixRenderRuntimeMode);
init(_properties: Partial<P>): Promise<[boolean, string?]>;
update(properties: Partial<P>): Promise<[boolean, string?]>;
destroy(properties?: Partial<P>): Promise<[boolean, string?]>;
log(properties: Partial<P>): Promise<[boolean, string?]>;
invoke(properties: Partial<P> & {
method: string;
params?: unknown;
}): Promise<[boolean, string?]>;
addEventListener(eventName: string, callback: (params: any) => any): void;
removeEventListener(eventName: string, handler?: (params: any) => any): void;
}

@@ -1,2 +0,2 @@

import { LegacyAdapter } from './legacy';
import { LegacyAdapter, SSRLegacyAdapter } from './legacy';
export declare class PiaMixRenderAdapter<P extends Record<string, any> = Record<string, any>> extends LegacyAdapter<P> {

@@ -9,1 +9,7 @@ init(properties: Partial<P>): Promise<[boolean, string?]>;

}
export declare class SSRPiaMixRenderAdapter<P extends Record<string, any> = Record<string, any>> extends SSRLegacyAdapter<P> {
invoke(properties: Partial<P> & {
method: string;
params?: unknown;
}): Promise<[boolean, string?]>;
}

@@ -1,3 +0,3 @@

import type { IImageProxy, IImageProxyConfig, IImageObjectFitValues } from '../interface';
export declare class ImageProxy implements IImageProxy {
import type { IImageProxy, IImageProxyConfig, ICSRImageProxyConfig, IImageObjectFitValues, ISSRImageProxyConfig } from '../interface';
export declare class CSRImageProxy implements IImageProxy {
private config;

@@ -7,5 +7,4 @@ private widget;

private renderFormat;
constructor(config: IImageProxyConfig);
constructor(config: ICSRImageProxyConfig);
init(): Promise<[boolean, (string | undefined)?]>;
private getSrc;
setSrc(src: string): Promise<[boolean, (string | undefined)?]>;

@@ -16,2 +15,17 @@ setObjectFit(value: IImageObjectFitValues): Promise<[boolean, (string | undefined)?]>;

}
export declare function createImageProxy(config: IImageProxyConfig): ImageProxy;
export declare class SSRImageProxy implements IImageProxy {
private config;
private widget;
isInitialized: boolean;
private renderFormat;
constructor(config: ISSRImageProxyConfig);
init(): {
id: number;
src: string;
};
setSrc(src: string): any;
setObjectFit(value: IImageObjectFitValues): any;
setCornerRadius(value: string): any;
destroy(): Promise<any>;
}
export declare function createImageProxy(config: IImageProxyConfig): CSRImageProxy | SSRImageProxy;

@@ -0,1 +1,2 @@

import type { IImageLoader } from '../interface';
declare global {

@@ -30,2 +31,3 @@ interface Window {

export declare const isImagexUrl: (url: string) => boolean;
export declare const getSrc: (src: string, loader: IImageLoader, format: string) => string;
export {};

@@ -1,3 +0,3 @@

import type { IImageWidget, IImageProxyConfig, IImageObjectFitValues } from '../interface';
export declare class ImageWidget4Native implements IImageWidget {
import type { IImageWidget, IImageObjectFitValues, ICSRImageProxyConfig, ISSRImageProxyConfig } from '../interface';
export declare class CSRImageWidget4Native implements IImageWidget {
private config;

@@ -10,3 +10,3 @@ private id;

private cornerRadiusMatchRes4Pixel;
constructor(config: IImageProxyConfig);
constructor(config: ICSRImageProxyConfig);
init(): Promise<[boolean, (string | undefined)?]>;

@@ -21,1 +21,15 @@ setSrc(src: string): Promise<[boolean, (string | undefined)?]>;

}
export declare class SSRImageWidget4Native implements IImageWidget {
private config;
private id;
private mode;
private adapter;
private placeholder;
constructor(config: ISSRImageProxyConfig);
init(): number;
setSrc(src: string): any;
setObjectFit(value: IImageObjectFitValues): any;
setCornerRadius(value?: string): any;
log(webLog: string): any;
destroy(): Promise<any>;
}

@@ -1,5 +0,5 @@

import type { IImageWidget, IImageProxyConfig, IImageObjectFitValues } from '../interface';
import type { IImageWidget, IImageObjectFitValues, ICSRImageProxyConfig } from '../interface';
export declare class ImageWidget4Web implements IImageWidget {
private config;
constructor(config: IImageProxyConfig);
constructor(config: ICSRImageProxyConfig);
private image;

@@ -6,0 +6,0 @@ init(): Promise<[boolean]>;

export * from './react';
export * from './utils';

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),extendStatics=function(e,A){return(extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,A){e.__proto__=A}:function(e,A){for(var t in A)Object.prototype.hasOwnProperty.call(A,t)&&(e[t]=A[t])}))(e,A)};function __extends(e,A){if("function"!=typeof A&&null!==A)throw new TypeError("Class extends value "+String(A)+" is not a constructor or null");function t(){this.constructor=e}extendStatics(e,A),e.prototype=null===A?Object.create(A):(t.prototype=A.prototype,new t)}var __assign=function(){return(__assign=Object.assign||function(e){for(var A,t=1,r=arguments.length;t<r;t++)for(var n in A=arguments[t])Object.prototype.hasOwnProperty.call(A,n)&&(e[n]=A[n]);return e}).apply(this,arguments)};function __rest(e,A){var t={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&A.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)A.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]]);return t}function __awaiter(e,o,a,s){return new(a=a||Promise)(function(t,A){function r(e){try{i(s.next(e))}catch(e){A(e)}}function n(e){try{i(s.throw(e))}catch(e){A(e)}}function i(e){var A;e.done?t(e.value):((A=e.value)instanceof a?A:new a(function(e){e(A)})).then(r,n)}i((s=s.apply(e,o||[])).next())})}function __generator(r,n){var i,o,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function e(t){return function(e){var A=[t,e];if(i)throw new TypeError("Generator is already executing.");for(;s=c&&A[c=0]?0:s;)try{if(i=1,o&&(a=2&A[0]?o.return:A[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,A[1])).done)return a;switch(o=0,(A=a?[2&A[0],a.value]:A)[0]){case 0:case 1:a=A;break;case 4:return s.label++,{value:A[1],done:!1};case 5:s.label++,o=A[1],A=[0];continue;case 7:A=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===A[0]||2===A[0])){s=0;continue}if(3===A[0]&&(!a||A[1]>a[0]&&A[1]<a[3]))s.label=A[1];else if(6===A[0]&&s.label<a[1])s.label=a[1],a=A;else{if(!(a&&s.label<a[2])){a[2]&&s.ops.pop(),s.trys.pop();continue}s.label=a[2],s.ops.push(A)}}A=n.call(r,s)}catch(e){A=[6,e],o=0}finally{i=a=0}if(5&A[0])throw A[1];return{value:A[0]?A[1]:void 0,done:!0}}}}var EPlatform,ValidFormat$1=["webp","avif","heic","jpeg","png"];function getGlobal(){return new Function("return this")()}exports.EMixRenderComponents=void 0,function(e){e.LivePlayer="live_player",e.Lottie="lottie_view",e.Image="web_image"}(exports.EMixRenderComponents||(exports.EMixRenderComponents={})),exports.EMixRenderRuntime=void 0,function(e){e.DIG="dig",e.EMBED="embed"}(exports.EMixRenderRuntime||(exports.EMixRenderRuntime={})),function(e){e.ANDROID="Android",e.IOS="iOS",e.UNKNOWN="unknown"}(EPlatform=EPlatform||{});var _systemInfo_,_useragent_,REGEXP_DETECT_PLATFORM=/(Android|iPhone)/;function getUserAgent(){var e;return _useragent_=_useragent_||(null==(e=getGlobal().navigator)?void 0:e.userAgent)||""}function getSystemInfo(){var e,A;return _systemInfo_||(e=getUserAgent().match(REGEXP_DETECT_PLATFORM),A=EPlatform.UNKNOWN,e&&(A="Android"===e[1]?EPlatform.ANDROID:EPlatform.IOS),_systemInfo_={platform:A}),_systemInfo_}function isAndroid(){return getSystemInfo().platform===EPlatform.ANDROID}var MixRenderCallbackRegistry=function(){function e(){this._records={},this.id=0}return e.prototype.register=function(e){return this.id++,this._records[this.id]=e,this.id},e.prototype.unregister=function(e){this._records[e]=null},e.prototype.dispatch=function(e,A){var t=this._records[e],r=getMixRenderInstance();t&&(null!=(r=null==r?void 0:r.getLogger())&&r.log("callback, callbackId: ".concat(e,"; res: "),A),t(A))},e}(),MixRenderEventDelegate=function(){function e(){this._records={}}return e.prototype.addEventHandler=function(e,A,t){this._records[e]||(this._records[e]={}),this._records[e][A]||(this._records[e][A]=[]),this._records[e][A].push(t)},e.prototype.removeEventHandler=function(e,A,t){var r;this._records[e]&&(t?(r=this._records[e][A])&&-1<(t=r.indexOf(t))&&r.splice(t,1):this._records[e][A]=[])},e.prototype.dispatchEvent=function(e,A,t){this._records[e]&&(e=this._records[e][A])&&e.forEach(function(e){e(t)})},e}(),globalObject$3=getGlobal(),MixRenderLogger=function(){function e(e){this.prefix=e,this.isEnabled=!1,this.isEnabled=this.checkLoggerEnabled()}return e.prototype.log=function(e,A){this.isEnabled&&console.log(this.prefix,e,A)},e.prototype.warn=function(e){this.isEnabled&&console.warn(this.prefix,e)},e.prototype.error=function(e){this.isEnabled&&console.error(this.prefix,e)},e.prototype.checkLoggerEnabled=function(){var e=null==(e=globalObject$3.location)?void 0:e.href.split("?")[1];if(e)for(var A=0,t=e.split("&");A<t.length;A++)if(t[A]==="".concat("__pia_mixrender_logger__","=1"))return!0;return globalObject$3.__pia_mixrender_logger__},e}(),MixRenderCore=function(){function e(){this._id=0,this.CallbackRegistryImpl=MixRenderCallbackRegistry,this.EventDelegateImpl=MixRenderEventDelegate,this.LoggerImpl=MixRenderLogger}return e.prototype.registerImpl=function(e,A){switch(e){case"callbackRegistry":this.CallbackRegistryImpl=A;break;case"eventDelegate":this.EventDelegateImpl=A;break;case"logger":this.LoggerImpl=A}},e.prototype.init=function(){this._callback_registry_=new this.CallbackRegistryImpl,this._event_delegate_=new this.EventDelegateImpl,this._logger_=new this.LoggerImpl("[PIA MixRender]")},e.prototype.getCallbackRegistry=function(){return this._callback_registry_},e.prototype.getEventDelegate=function(){return this._event_delegate_},e.prototype.getLogger=function(){return this._logger_},e.prototype.getConfig=function(){return this._config_},e.prototype.setConfig=function(e){this._config_=e},e.prototype.allocateId=function(){return this._id++},e}();function getMixRenderInstance(){var e,A=getGlobal();return A._mix_render_core_||((e=new MixRenderCore).init(),A._mix_render_core_=e),A._mix_render_core_}function addMixRenderEventHandler(e,A,t){getMixRenderInstance().getEventDelegate().addEventHandler(e,A,t)}function removeMixRenderEventHandler(e,A,t){getMixRenderInstance().getEventDelegate().removeEventHandler(e,A,t)}var _a,globalObject$2=getGlobal();function call(e,A,t,r){var n,i=globalObject$2.byted_mixrender_native;i&&(n=getMixRenderInstance(),r=r?n.getCallbackRegistry().register(r):-1,i.invoke(e,A,JSON.stringify(t),r),n.getLogger().log("invoke, native component id ".concat(e,", command: ").concat(A,", callbackId: ").concat(r,", params: "),t))}function callSync(e,A){var t=globalObject$2.byted_mixrender_native;return null==t||!t.invokeSync||0!==(null==(t=JSON.parse(t.invokeSync(e,JSON.stringify(A))||""))?void 0:t.status)||null==t?void 0:t.data}function allocateId(){return getMixRenderInstance().allocateId()}var globalObject$1=getGlobal();function getMixRenderConfig(){var e,A=getMixRenderInstance();return A.getConfig()||(e=globalObject$1.byted_mixrender_config,A.getLogger().log("nativeConfig",e),e?A.setConfig(e):isAndroid()&&(e=callSync("getFeatures",null),A.setConfig(e),A.getLogger().log("GetFeatures",e))),A.getConfig()}function canIUse(e,A){void 0===A&&(A=!1);var t,r=getMixRenderConfig();return!(!(r&&r.mixrender_component_support_list&&r.mixrender_component_support_list[e])||(t="".concat(r.mixrender_component_support_list[e]),!A&&inBlockList(e,t))||isAndroid()&&1!==(null==(A=null==r?void 0:r.mixrender_runtime_support_list)?void 0:A.embed))}function isRuntimeModeSupport(e){var A;return!isAndroid()||(A=getMixRenderConfig())&&A.mixrender_runtime_support_list&&1===(null==(A=A.mixrender_runtime_support_list)?void 0:A[e])}var BLOCK_LIST={Android:{MixRender:{},PiaMixRender:((_a={})[exports.EMixRenderComponents.LivePlayer]=["1"],_a)},iOS:{MixRender:{}}};function inBlockList(e,A){var t,r=!1,n=[];if(n=(isAndroid()?(t=getMixRenderConfig(),isAndroid()&&t.mixrender_runtime_support_list?BLOCK_LIST.Android.PiaMixRender:BLOCK_LIST.Android.MixRender):BLOCK_LIST.iOS.MixRender)[e])for(var i=0,o=n;i<o.length;i++)if(o[i]===A){r=!0;break}return r}function translateMixRenderCallbackResponse(e){switch(e){case 0:return[!0];case-1:return[!1,"unknown function error"];case-2:return[!1,"error occurs when initializing"];case-3:return[!1,"call method with wrong params"];default:return[!1,"unknown error occurs"]}}var AdapterImpl,LegacyAdapter=function(){function e(e,A,t){this.id=e,this.type=A,this.mode=t}return e.prototype.init=function(e){var t=this;return new Promise(function(A){call(t.id,"initialize",{type:t.type,properties:e},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))})})},e.prototype.update=function(e){var t=this;return new Promise(function(A){call(t.id,"update",{type:t.type,properties:e},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))}),isAndroid()||A([!0])})},e.prototype.destroy=function(e){var t=this;return void 0===e&&(e={}),new Promise(function(A){call(t.id,"destroy",{type:t.type,properties:e},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))}),isAndroid()||A([!0])})},e.prototype.log=function(e){var t=this;return new Promise(function(A){call(t.id,"debugLog",{type:t.type,properties:e},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))}),isAndroid()||A([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,A){addMixRenderEventHandler(this.id,e,A)},e.prototype.removeEventListener=function(e,A){removeMixRenderEventHandler(this.id,e,A)},e}(),PiaMixRenderAdapter=function(e){function A(){return null!==e&&e.apply(this,arguments)||this}return __extends(A,e),A.prototype.init=function(t){var r=this;return new Promise(function(A){var e={type:r.type,properties:t};"embed"===r.mode&&(e.mode="embed"),call(r.id,"initialize",e,function(e){e=e.status;A(translateMixRenderCallbackResponse(e))})})},A.prototype.invoke=function(r){var n=this;return new Promise(function(A){var e=r.method,t=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:t},function(e){e=e.status;A(translateMixRenderCallbackResponse(e))})})},A}(LegacyAdapter);function getAdapterImpl(e){var A;return AdapterImpl||(A=getMixRenderConfig(),AdapterImpl=isAndroid()&&A&&A.mixrender_runtime_support_list?PiaMixRenderAdapter:LegacyAdapter),AdapterImpl}function setupAdapter(e,A,t){return void 0===t&&(t="dig"),new(getAdapterImpl())(e,A,t)}var TRANSFORM_BASE_BETWEEN_ID_AND_RGBA=255;function createPlaceholder4Android(e,A,t){var r;return"dig"===t?(e.setAttribute("tt-render-in-browser",String(A)),{destroy:function(){e.removeAttribute("tt-render-in-browser")}}):((r=document.createElement("embed")).setAttribute("tt-embed-id",String(A)),r.setAttribute("type","ttplugin/hybrid_component"),r.style.width="100%",r.style.height="100%",e.appendChild(r),{destroy:function(){e.removeChild(r)}})}function createPlaceholder4IOS(e,A){var t={overflow:e.style.overflow,"-webkit-overflow-scrolling":e.style["-webkit-overflow-scrolling"],backgroundColor:e.style.backgroundColor},r=Math.floor(A/TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),A=Math.floor(A%TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),n=(e.style.overflow="scroll",e.style["-webkit-overflow-scrolling"]="touch",e.style.backgroundColor="rgba(13, ".concat(r,", ").concat(A,", 0.13)"),document.createElement("div")),i=(n.style.width="100%",n.style.height="100%",e.appendChild(n),document.createElement("div"));return i.style.height="1px",e.appendChild(i),{destroy:function(){e.removeChild(n),e.removeChild(i),Object.assign(e.style,t)}}}function createPlaceholder(e,A,t){return isAndroid()?createPlaceholder4Android(e,A,t):createPlaceholder4IOS(e,A)}function callback(e,A){var t=getMixRenderInstance();t.getLogger().log("invoke native method callback, with: callbackId: ".concat(e,", res:"),A),t.getCallbackRegistry().dispatch(e,JSON.parse(A))}function invoke(e,A,t){var r=getMixRenderInstance();r.getLogger().log("trigger native event, with: id: ".concat(e,", command: ").concat(A,", params: "),t),r.getEventDelegate().dispatchEvent(e,A,JSON.parse(t))}var globalObject=getGlobal();function setupMixRenderWebHandle(){globalObject.byted_mixrender_web||(globalObject.byted_mixrender_web={invoke:invoke,callback:callback})}function getUsableRuntimeMode(e){return e||(isRuntimeModeSupport("embed")?"embed":"dig")}setupMixRenderWebHandle();var RegExp4Percentage=/(\d+)%/,RegExp4Pixel=/(\d+)px/,ImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode=getUsableRuntimeMode(this.config.mode),this.adapter=setupAdapter(this.id,exports.EMixRenderComponents.Image,this.mode),this.cornerRadiusMatchRes4Percent=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Pixel),this.updateCornerRadiusWhenResize=this.updateCornerRadiusWhenResize.bind(this)}return e.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){var A,t,r;return __generator(this,function(e){switch(e.label){case 0:return A=this.config.container,t=A.style.opacity||"1",A.style.opacity="0.1",this.placeholder=createPlaceholder(A,this.id,this.mode),(r=this.config).container,r.renderer,r.mode,r.cornerRadius,r=__rest(r,["container","renderer","mode","cornerRadius"]),this.log("widget init"),[4,this.adapter.init(__assign(__assign({},r),{cornerRadius:this.getCornerRadius()}))];case 1:return r=e.sent(),A.style.opacity=t,r[0]&&(this.cornerRadiusMatchRes4Percent&&window.addEventListener("resize",this.updateCornerRadiusWhenResize),A.style.background="rgba(0,0,0,0)"),[2,r]}})})},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return this.cornerRadiusMatchRes4Percent=(e=void 0===e?"":e).match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=e.match(RegExp4Pixel),this.adapter.update({cornerRadius:this.getCornerRadius()})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){return __awaiter(this,void 0,void 0,function(){var A;return __generator(this,function(e){switch(e.label){case 0:return[4,this.adapter.destroy()];case 1:return(A=e.sent())[0]&&(this.placeholder.destroy(),this.cornerRadiusMatchRes4Percent)&&window.removeEventListener("resize",this.updateCornerRadiusWhenResize),[2,A]}})})},e.prototype.updateCornerRadiusWhenResize=function(){var e=this.getCornerRadius();this.adapter.update({cornerRadius:e})},e.prototype.getCornerRadius=function(){var e=this.config.container;return this.cornerRadiusMatchRes4Percent?e.getBoundingClientRect().width*+this.cornerRadiusMatchRes4Percent[1]/100:this.cornerRadiusMatchRes4Pixel?+this.cornerRadiusMatchRes4Pixel[1]:void 0},e}(),ImageWidget4Web=function(){function e(e){this.config=e}return e.prototype.init=function(){var e=this.config,A=e.container,t=e.src,r=e.objectFit,e=e.cornerRadius;return this.image=new Image,this.image.style.width="100%",this.image.style.height="100%",this.image.src=t,this.image.style.objectFit=r,this.image.style.borderRadius="".concat(e,"px"),A.appendChild(this.image),Promise.resolve([!0])},e.prototype.setSrc=function(e){return this.image.src=e,Promise.resolve([!0])},e.prototype.setObjectFit=function(e){return this.image.style.objectFit=e,Promise.resolve([!0])},e.prototype.setCornerRadius=function(e){return this.image.style.borderRadius=e=void 0===e?"":e,Promise.resolve([!0])},e.prototype.log=function(e){return Promise.resolve([!0])},e.prototype.destroy=function(){return this.config.container.removeChild(this.image),Promise.resolve([!0])},e}(),ValidFormat=["webp","avif","heic","jpeg","png"],FormatsMap={webp:"awebp",heic:"heif",avif:"avis",jpeg:"jpeg",png:"png"},ErrorImageXUrl={protocol:"http://",domain:"",src:"",search:"",template:"",suffix:""},ErrorUrl={protocol:"http://",domain:"",src:"",search:""},imagexUrlPattern=/^(.+)~(tplv-[a-zA-Z0-9]{2,10}-.+)\.([a-zA-Z]+)\??(.*)$/,FORMAT_BASE64_MAP={webp:{base64:"data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvn8AnAAdQiUpUov+BiOh/AAA=",height:160},heic:{base64:"data:image/heic;base64,AAAAHGZ0eXBtaWYxAAAAAG1pZjFoZWljaGV2YwAAASVtZXRhAAAAAAAAACFoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAAAAAAA5waXRtAAAAAAABAAAAI2lpbmYAAAAAAAEAAAAVaW5mZQIAAAAAAQAAaHZjMQAAAACjaXBycAAAAIZpcGNvAAAAamh2Y0MBAWAAAAAAAAAAAAAe8AD8/fj4AAAPAyAAAQAYQAEMAf//AWAAAAMAAAMAAAMAAAMAHvAkIQABAB1CAQEBYAAAAwAAAwAAAwAAAwAeoDSBp3eX5JMrICIAAQAHRAHBLGDEgAAAABRpc3BlAAAAAAAAAGQAAABkAAAAFWlwbWEAAAAAAAAAAQABAoECAAAAJGlsb2MBAAAAREAAAQABAAAAAAAAAUkAAQAAAAAAAAAgAAAAKG1kYXQAAAAcJgGvJRNg+cJYeUBAgVGpfj2xh5SigAAENABAQA==",height:100},avif:{base64:"data:image/avif;base64,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",height:1}},check=function(r){return 0<=ValidFormat.indexOf(r)&&("jpeg"===r||"png"===r||!!FORMAT_BASE64_MAP[r]&&new Promise(function(A){if("undefined"==typeof window&&A(!1),void 0!==window["__support_".concat(r,"__")])A(!!window["__support_".concat(r,"__")]);else{if(FORMAT_BASE64_MAP[r].prerequisite)if(!FORMAT_BASE64_MAP[r].prerequisite())return window["__support_".concat(r,"__")]=!1,void A(!1);var t=new Image;t.onload=function(){var e=(null==t?void 0:t.height)===FORMAT_BASE64_MAP[r].height;window["__support_".concat(r,"__")]=e,A(e)},t.onerror=function(){window["__support_".concat(r,"__")]=!1,A(!1)},t.src=FORMAT_BASE64_MAP[r].base64}}))},getFormat=function(o){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,new Promise(function(i){__awaiter(void 0,void 0,void 0,function(){var A,t,r,n;return __generator(this,function(e){switch(e.label){case 0:"undefined"==typeof window&&i("image"),A=0,t=o,e.label=1;case 1:if(!(A<t.length))return[3,7];r=t[A],n=!1,e.label=2;case 2:return e.trys.push([2,4,,5]),[4,check(r)];case 3:return n=e.sent(),[3,5];case 4:return e.sent(),console.error("格式探测失败"),[3,5];case 5:if(n)return i(r),[3,7];e.label=6;case 6:return A++,[3,1];case 7:return i("image"),[2]}})})})];case 1:return[2,e.sent()]}})})},parseImagexUrl=function(e){try{var A=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),t=new URL(A),r=imagexUrlPattern.exec(t.pathname.slice(1));return{protocol:t.protocol,domain:t.hostname,src:r[1],template:r[2],suffix:r[3],search:t.search}}catch(e){return console.error(e),ErrorImageXUrl}},parseOtherUrl=function(e){try{var A=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),t=new URL(A);return{protocol:t.protocol,domain:t.hostname,src:t.pathname.slice(1),search:t.search}}catch(e){return ErrorUrl}},isImagexUrl=function(e){return imagexUrlPattern.test(e)},isSupportNativeImage=canIUse(exports.EMixRenderComponents.Image),ImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="image"}return e.prototype.init=function(){var i;return __awaiter(this,void 0,void 0,function(){var A,t,r,n;return __generator(this,function(e){switch(e.label){case 0:return A=this.config.renderer,t=this,"web"!==(A=A&&"auto"!==A?A:isSupportNativeImage?"native":"web")?[3,2]:[4,getFormat((this.config.formats||["avif","webp"]).filter(function(e){return"heic"!==e}))];case 1:return r=e.sent()||"image",[3,3];case 2:r=(null==(i=this.config.formats)?void 0:i[0])||"heic",e.label=3;case 3:return t.renderFormat=r,n=__assign(__assign({},this.config),{src:this.getSrc()}),this.widget=new("native"===A?ImageWidget4Native:ImageWidget4Web)(n),[4,this.widget.init()];case 4:return(n=e.sent())[0]&&(this.isInitialized=!0),[2,n]}})})},e.prototype.getSrc=function(e){var A,t,r,n,i,o,e=void 0===e?this.config.src:e;return A=isImagexUrl(e)?(r=(o=parseImagexUrl(e)).src,n=o.protocol,i=o.domain,t=o.suffix,A=o.template,o=o.search,{src:r,format:FormatsMap[this.renderFormat]||"image",extra:{suffix:t,template:A,search:o,protocol:n,domain:i,origin:e}}):(r=(t=parseOtherUrl(e)).src,n=t.protocol,i=t.domain,o=t.search,{src:r,format:FormatsMap[this.renderFormat]||"image",extra:{protocol:n,domain:i,search:o,origin:e}}),this.config.loader(A)},e.prototype.setSrc=function(e){return this.widget.setSrc(this.getSrc(e))},e.prototype.setObjectFit=function(e){return this.widget.setObjectFit(e)},e.prototype.setCornerRadius=function(e){return this.widget.setCornerRadius(e)},e.prototype.destroy=function(){return this.widget.destroy()},e}();function createImageProxy(e){return new ImageProxy(e)}var Viewer=function(A){var e,t=React.useRef(null),r=React.useRef(null),n=React.useRef(r.current&&r.current.isInitialized);return React.useEffect(function(){var e;n.current=null==(e=r.current)?void 0:e.isInitialized},[null==(e=r.current)?void 0:e.isInitialized]),React.useEffect(function(){if(t.current)return r.current=createImageProxy({container:t.current,renderer:A.renderer||"auto",src:A.src,loader:A.loader,objectFit:A.objectFit,cornerRadius:A.cornerRadius||"",mode:A.mode,formats:A.formats||["heic","avif","webp"]}),r.current.init().then(function(e){e[0]&&(n.current=!0)}),function(){r.current&&r.current.destroy&&r.current.destroy()}},[]),React.useEffect(function(){var e;n.current&&null!=(e=r.current)&&e.setSrc(A.src)},[A.src]),React.useEffect(function(){var e;n.current&&null!=(e=r.current)&&e.setObjectFit(A.objectFit)},[A.objectFit]),React.useEffect(function(){var e;n.current&&null!=(e=r.current)&&e.setCornerRadius(A.cornerRadius)},[A.cornerRadius]),React__default.default.createElement("div",{className:"pia-mixrender-image",style:{width:A.width,height:A.height}},React__default.default.createElement("div",{ref:t,style:{width:A.width,height:A.height,fontSize:0,lineHeight:0}}))};exports.ImageProxy=ImageProxy,exports.ValidFormat=ValidFormat$1,exports.Viewer=Viewer,exports.createImageProxy=createImageProxy;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var A in t)Object.prototype.hasOwnProperty.call(t,A)&&(e[A]=t[A])}))(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function A(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(A.prototype=t.prototype,new A)}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,A=1,r=arguments.length;A<r;A++)for(var n in t=arguments[A])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function __rest(e,t){var A={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(A[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(A[n[r]]=e[n[r]]);return A}function __awaiter(e,o,a,s){return new(a=a||Promise)(function(A,t){function r(e){try{i(s.next(e))}catch(e){t(e)}}function n(e){try{i(s.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?A(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(r,n)}i((s=s.apply(e,o||[])).next())})}function __generator(r,n){var i,o,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function e(A){return function(e){var t=[A,e];if(i)throw new TypeError("Generator is already executing.");for(;s=c&&t[c=0]?0:s;)try{if(i=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,o=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))s.label=t[1];else if(6===t[0]&&s.label<a[1])s.label=a[1],a=t;else{if(!(a&&s.label<a[2])){a[2]&&s.ops.pop(),s.trys.pop();continue}s.label=a[2],s.ops.push(t)}}t=n.call(r,s)}catch(e){t=[6,e],o=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}var EPlatform,ValidFormat$1=["webp","avif","heic","jpeg","png"],ValidPlatform=["Android","iOS"];function getGlobal(){return new Function("return this")()}exports.EMixRenderComponents=void 0,function(e){e.LivePlayer="live_player",e.Lottie="lottie_view",e.Image="web_image"}(exports.EMixRenderComponents||(exports.EMixRenderComponents={})),exports.EMixRenderRuntime=void 0,function(e){e.DIG="dig",e.EMBED="embed"}(exports.EMixRenderRuntime||(exports.EMixRenderRuntime={})),function(e){e.ANDROID="Android",e.IOS="iOS",e.UNKNOWN="unknown"}(EPlatform=EPlatform||{});var _systemInfo_,_useragent_,REGEXP_DETECT_PLATFORM=/(Android|iPhone)/;function getUserAgent(){var e;return _useragent_=_useragent_||(null==(e=getGlobal().navigator)?void 0:e.userAgent)||""}function getSystemInfo(){var e,t;return _systemInfo_||(e=getUserAgent().match(REGEXP_DETECT_PLATFORM),t=EPlatform.UNKNOWN,e&&(t="Android"===e[1]?EPlatform.ANDROID:EPlatform.IOS),_systemInfo_={platform:t}),_systemInfo_}function isAndroid(){return getSystemInfo().platform===EPlatform.ANDROID}var MixRenderCallbackRegistry=function(){function e(){this._records={},this.id=0}return e.prototype.register=function(e){return this.id++,this._records[this.id]=e,this.id},e.prototype.unregister=function(e){this._records[e]=null},e.prototype.dispatch=function(e,t){var A=this._records[e],r=getMixRenderInstance();A&&(null!=(r=null==r?void 0:r.getLogger())&&r.log("callback, callbackId: ".concat(e,"; res: "),t),A(t))},e}(),MixRenderEventDelegate=function(){function e(){this._records={}}return e.prototype.addEventHandler=function(e,t,A){this._records[e]||(this._records[e]={}),this._records[e][t]||(this._records[e][t]=[]),this._records[e][t].push(A)},e.prototype.removeEventHandler=function(e,t,A){var r;this._records[e]&&(A?(r=this._records[e][t])&&-1<(A=r.indexOf(A))&&r.splice(A,1):this._records[e][t]=[])},e.prototype.dispatchEvent=function(e,t,A){this._records[e]&&(e=this._records[e][t])&&e.forEach(function(e){e(A)})},e}(),globalObject$3=getGlobal(),MixRenderLogger=function(){function e(e){this.prefix=e,this.isEnabled=!1,this.isEnabled=this.checkLoggerEnabled()}return e.prototype.log=function(e,t){this.isEnabled&&console.log(this.prefix,e,t)},e.prototype.warn=function(e){this.isEnabled&&console.warn(this.prefix,e)},e.prototype.error=function(e){this.isEnabled&&console.error(this.prefix,e)},e.prototype.checkLoggerEnabled=function(){var e=null==(e=globalObject$3.location)?void 0:e.href.split("?")[1];if(e)for(var t=0,A=e.split("&");t<A.length;t++)if(A[t]==="".concat("__pia_mixrender_logger__","=1"))return!0;return globalObject$3.__pia_mixrender_logger__},e}(),MixRenderCore=function(){function e(){this._id=0,this.CallbackRegistryImpl=MixRenderCallbackRegistry,this.EventDelegateImpl=MixRenderEventDelegate,this.LoggerImpl=MixRenderLogger}return e.prototype.registerImpl=function(e,t){switch(e){case"callbackRegistry":this.CallbackRegistryImpl=t;break;case"eventDelegate":this.EventDelegateImpl=t;break;case"logger":this.LoggerImpl=t}},e.prototype.init=function(){this._callback_registry_=new this.CallbackRegistryImpl,this._event_delegate_=new this.EventDelegateImpl,this._logger_=new this.LoggerImpl("[PIA MixRender]")},e.prototype.getCallbackRegistry=function(){return this._callback_registry_},e.prototype.getEventDelegate=function(){return this._event_delegate_},e.prototype.getLogger=function(){return this._logger_},e.prototype.getConfig=function(){return this._config_},e.prototype.setConfig=function(e){this._config_=e},e.prototype.allocateId=function(){return this._id++},e}();function getMixRenderInstance(){var e,t=getGlobal();return t._mix_render_core_||((e=new MixRenderCore).init(),t._mix_render_core_=e),t._mix_render_core_}function addMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().addEventHandler(e,t,A)}function removeMixRenderEventHandler(e,t,A){getMixRenderInstance().getEventDelegate().removeEventHandler(e,t,A)}var _a,globalObject$2=getGlobal();function call(e,t,A,r){var n,i=globalObject$2.byted_mixrender_native;i&&(n=getMixRenderInstance(),r=r?n.getCallbackRegistry().register(r):-1,i.invoke(e,t,JSON.stringify(A),r),n.getLogger().log("invoke, native component id ".concat(e,", command: ").concat(t,", callbackId: ").concat(r,", params: "),A))}function callSync(e,t){var A=globalObject$2.byted_mixrender_native;return null==A||!A.invokeSync||0!==(null==(A=JSON.parse(A.invokeSync(e,JSON.stringify(t))||""))?void 0:A.status)||null==A?void 0:A.data}function allocateId(){return getMixRenderInstance().allocateId()}var globalObject$1=getGlobal();function getMixRenderConfig(){var e,t=getMixRenderInstance();return t.getConfig()||(e=globalObject$1.byted_mixrender_config,t.getLogger().log("nativeConfig",e),e?t.setConfig(e):isAndroid()&&(e=callSync("getFeatures",null),t.setConfig(e),t.getLogger().log("GetFeatures",e))),t.getConfig()}function canIUse(e,t){void 0===t&&(t=!1);var A,r=getMixRenderConfig();return!(!(r&&r.mixrender_component_support_list&&r.mixrender_component_support_list[e])||(A="".concat(r.mixrender_component_support_list[e]),!t&&inBlockList(e,A))||isAndroid()&&1!==(null==(t=null==r?void 0:r.mixrender_runtime_support_list)?void 0:t.embed))}function isRuntimeModeSupport(e){var t;return!isAndroid()||(t=getMixRenderConfig())&&t.mixrender_runtime_support_list&&1===(null==(t=t.mixrender_runtime_support_list)?void 0:t[e])}var BLOCK_LIST={Android:{MixRender:{},PiaMixRender:((_a={})[exports.EMixRenderComponents.LivePlayer]=["1"],_a)},iOS:{MixRender:{}}};function inBlockList(e,t){var A,r=!1,n=[];if(n=(isAndroid()?(A=getMixRenderConfig(),isAndroid()&&A.mixrender_runtime_support_list?BLOCK_LIST.Android.PiaMixRender:BLOCK_LIST.Android.MixRender):BLOCK_LIST.iOS.MixRender)[e])for(var i=0,o=n;i<o.length;i++)if(o[i]===t){r=!0;break}return r}function translateMixRenderCallbackResponse(e){switch(e){case 0:return[!0];case-1:return[!1,"unknown function error"];case-2:return[!1,"error occurs when initializing"];case-3:return[!1,"call method with wrong params"];default:return[!1,"unknown error occurs"]}}var LegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){var A=this;return new Promise(function(t){call(A.id,"initialize",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),SSRLegacyAdapter=function(){function e(e,t,A){this.id=e,this.type=t,this.mode=A}return e.prototype.init=function(e){return new Promise(function(e){e([!0])})},e.prototype.update=function(e){var A=this;return new Promise(function(t){call(A.id,"update",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.destroy=function(e){var A=this;return void 0===e&&(e={}),new Promise(function(t){call(A.id,"destroy",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.log=function(e){var A=this;return new Promise(function(t){call(A.id,"debugLog",{type:A.type,properties:e},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))}),isAndroid()||t([!0])})},e.prototype.invoke=function(e){e.method,e.params;e=__rest(e,["method","params"]);return this.update(e)},e.prototype.addEventListener=function(e,t){addMixRenderEventHandler(this.id,e,t)},e.prototype.removeEventListener=function(e,t){removeMixRenderEventHandler(this.id,e,t)},e}(),PiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.init=function(A){var r=this;return new Promise(function(t){var e={type:r.type,properties:A};"embed"===r.mode&&(e.mode="embed"),call(r.id,"initialize",e,function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(LegacyAdapter),SSRPiaMixRenderAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.invoke=function(r){var n=this;return new Promise(function(t){var e=r.method,A=r.params;call(n.id,"invokeMethod",{type:n.type,method:e,params:A},function(e){e=e.status;t(translateMixRenderCallbackResponse(e))})})},t}(SSRLegacyAdapter);function getAdapterImpl(e,t){var A=getMixRenderConfig();return null!=t&&t.hybridRender?"Android"===(null==t?void 0:t.platform)?SSRPiaMixRenderAdapter:SSRLegacyAdapter:isAndroid()&&A&&A.mixrender_runtime_support_list?PiaMixRenderAdapter:LegacyAdapter}function setupAdapter(e,t,A,r){return new(getAdapterImpl(A=void 0===A?"embed":A,r))(e,t,A)}var TRANSFORM_BASE_BETWEEN_ID_AND_RGBA=255;function createPlaceholder4Android(e,t,A){var r;return"dig"===A?(e.setAttribute("tt-render-in-browser",String(t)),{destroy:function(){e.removeAttribute("tt-render-in-browser")}}):((r=document.createElement("embed")).setAttribute("tt-embed-id",String(t)),r.setAttribute("type","ttplugin/hybrid_component"),r.style.width="100%",r.style.height="100%",e.appendChild(r),{destroy:function(){e.removeChild(r)}})}function createPlaceholder4IOS(e,t){var A={overflow:e.style.overflow,"-webkit-overflow-scrolling":e.style["-webkit-overflow-scrolling"],backgroundColor:e.style.backgroundColor},r=Math.floor(t/TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),t=Math.floor(t%TRANSFORM_BASE_BETWEEN_ID_AND_RGBA),n=(e.style.overflow="scroll",e.style["-webkit-overflow-scrolling"]="touch",e.style.backgroundColor="rgba(13, ".concat(r,", ").concat(t,", 0.13)"),document.createElement("div")),i=(n.style.width="100%",n.style.height="100%",e.appendChild(n),document.createElement("div"));return i.style.height="1px",e.appendChild(i),{destroy:function(){e.removeChild(n),e.removeChild(i),Object.assign(e.style,A)}}}function createPlaceholder(e,t,A){return isAndroid()?createPlaceholder4Android(e,t,A):createPlaceholder4IOS(e,t)}function callback(e,t){var A=getMixRenderInstance();A.getLogger().log("invoke native method callback, with: callbackId: ".concat(e,", res:"),t),A.getCallbackRegistry().dispatch(e,JSON.parse(t))}function invoke(e,t,A){var r=getMixRenderInstance();r.getLogger().log("trigger native event, with: id: ".concat(e,", command: ").concat(t,", params: "),A),r.getEventDelegate().dispatchEvent(e,t,JSON.parse(A))}var globalObject=getGlobal();function setupMixRenderWebHandle(){globalObject.byted_mixrender_web||(globalObject.byted_mixrender_web={invoke:invoke,callback:callback})}function getUsableRuntimeMode(e){return e||(isRuntimeModeSupport("embed")?"embed":"dig")}setupMixRenderWebHandle();var RegExp4Percentage=/(\d+)%/,RegExp4Pixel=/(\d+)px/,CSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode=getUsableRuntimeMode(this.config.mode),this.adapter=setupAdapter(this.id,exports.EMixRenderComponents.Image,this.mode),this.cornerRadiusMatchRes4Percent=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=null==(e=this.config.cornerRadius)?void 0:e.match(RegExp4Pixel),this.updateCornerRadiusWhenResize=this.updateCornerRadiusWhenResize.bind(this)}return e.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){var t,A,r;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.container,A=t.style.opacity||"1",t.style.opacity="0.1",this.placeholder=createPlaceholder(t,this.id,this.mode),(r=this.config).container,r.renderer,r.mode,r.cornerRadius,r=__rest(r,["container","renderer","mode","cornerRadius"]),this.log("widget init"),[4,this.adapter.init(__assign(__assign({},r),{cornerRadius:this.getCornerRadius()}))];case 1:return r=e.sent(),t.style.opacity=A,r[0]&&(this.cornerRadiusMatchRes4Percent&&window.addEventListener("resize",this.updateCornerRadiusWhenResize),t.style.background="rgba(0,0,0,0)"),[2,r]}})})},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return this.cornerRadiusMatchRes4Percent=(e=void 0===e?"":e).match(RegExp4Percentage),this.cornerRadiusMatchRes4Pixel=e.match(RegExp4Pixel),this.adapter.update({cornerRadius:this.getCornerRadius()})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&(null!=(A=this.placeholder)&&A.destroy(),this.cornerRadiusMatchRes4Percent)&&window.removeEventListener("resize",this.updateCornerRadiusWhenResize),[2,t]}})})},e.prototype.updateCornerRadiusWhenResize=function(){var e=this.getCornerRadius();this.adapter.update({cornerRadius:e})},e.prototype.getCornerRadius=function(){var e=this.config.container;return this.cornerRadiusMatchRes4Percent?e.getBoundingClientRect().width*+this.cornerRadiusMatchRes4Percent[1]/100:this.cornerRadiusMatchRes4Pixel?+this.cornerRadiusMatchRes4Pixel[1]:void 0},e}(),SSRImageWidget4Native=function(){function e(e){this.config=e,this.id=allocateId(),this.mode="embed"}return e.prototype.init=function(){return this.adapter=setupAdapter(this.id,exports.EMixRenderComponents.Image,this.mode,this.config.ssrConfig),this.id},e.prototype.setSrc=function(e){return this.adapter.update({src:e})},e.prototype.setObjectFit=function(e){return this.adapter.update({objectFit:e})},e.prototype.setCornerRadius=function(e){return void 0===e&&(e=""),this.adapter.update({cornerRadius:Number(e)})},e.prototype.log=function(e){return this.adapter.log({webLog:e})},e.prototype.destroy=function(){var A;return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,null==(A=this.adapter)?void 0:A.destroy()];case 1:return(t=e.sent())[0]&&null!=(A=this.placeholder)&&A.destroy(),[2,t]}})})},e}(),ImageWidget4Web=function(){function e(e){this.config=e}return e.prototype.init=function(){var e=this.config,t=e.container,A=e.src,r=e.objectFit,e=e.cornerRadius;return this.image=new Image,this.image.style.width="100%",this.image.style.height="100%",this.image.src=A,this.image.style.objectFit=r,this.image.style.borderRadius="".concat(e,"px"),t.appendChild(this.image),Promise.resolve([!0])},e.prototype.setSrc=function(e){return this.image.src=e,Promise.resolve([!0])},e.prototype.setObjectFit=function(e){return this.image.style.objectFit=e,Promise.resolve([!0])},e.prototype.setCornerRadius=function(e){return this.image.style.borderRadius=e=void 0===e?"":e,Promise.resolve([!0])},e.prototype.log=function(e){return Promise.resolve([!0])},e.prototype.destroy=function(){return this.config.container.removeChild(this.image),Promise.resolve([!0])},e}(),ValidFormat=["webp","avif","heic","jpeg","png"],FormatsMap={webp:"awebp",heic:"heif",avif:"avis",jpeg:"jpeg",png:"png"},ErrorImageXUrl={protocol:"http://",domain:"",src:"",search:"",template:"",suffix:""},ErrorUrl={protocol:"http://",domain:"",src:"",search:""},imagexUrlPattern=/^(.+)~(tplv-[a-zA-Z0-9]{2,10}-.+)\.([a-zA-Z]+)\??(.*)$/,FORMAT_BASE64_MAP={webp:{base64:"data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvn8AnAAdQiUpUov+BiOh/AAA=",height:160},heic:{base64:"data:image/heic;base64,AAAAHGZ0eXBtaWYxAAAAAG1pZjFoZWljaGV2YwAAASVtZXRhAAAAAAAAACFoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAAAAAAA5waXRtAAAAAAABAAAAI2lpbmYAAAAAAAEAAAAVaW5mZQIAAAAAAQAAaHZjMQAAAACjaXBycAAAAIZpcGNvAAAAamh2Y0MBAWAAAAAAAAAAAAAe8AD8/fj4AAAPAyAAAQAYQAEMAf//AWAAAAMAAAMAAAMAAAMAHvAkIQABAB1CAQEBYAAAAwAAAwAAAwAAAwAeoDSBp3eX5JMrICIAAQAHRAHBLGDEgAAAABRpc3BlAAAAAAAAAGQAAABkAAAAFWlwbWEAAAAAAAAAAQABAoECAAAAJGlsb2MBAAAAREAAAQABAAAAAAAAAUkAAQAAAAAAAAAgAAAAKG1kYXQAAAAcJgGvJRNg+cJYeUBAgVGpfj2xh5SigAAENABAQA==",height:100},avif:{base64:"data:image/avif;base64,AAAALGZ0eXBhdmlzAAAAAGF2aWZhdmlzbXNmMWlzbzhtaWYxbWlhZk1BMUEAAAElbWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAiaWxvYwAAAABEQAABAAIAAAAABgAAAQAAACUAAAAYAAAAKGlpbmYAAAAAAAEAAAAaaW5mZQIAAAAAAgAAYXYwMUFscGhhAAAAAAxpcmVmAAAAAAAAAI1pcHJwAAAAbmlwY28AAAAUaXNwZQAAAAAAAAABAAAAAQAAAA5waXhpAAAAAAEIAAAADGF2MUOBABwAAAAAOGF1eEMAAAAAdXJuOm1wZWc6bXBlZ0I6Y2ljcDpzeXN0ZW1zOmF1eGlsaWFyeTphbHBoYQAAAAAXaXBtYQAAAAAAAAABAAIEAQKDBAAABKdtb292AAAAbG12aGQAAAAA4GrKgOBqyoAAAABkAAAAZAABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAACGXRyYWsAAABcdGtoZAAAAAHgasqA4GrL+AAAAAEAAAAAAAAAZAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAQAAAAEAAAAAAbVtZGlhAAAAIG1kaGQAAAAA4GrKgOBqyoAAAABkAAAAZFXEAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAABZW1pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAASVzdGJsAAAAlXN0c2QAAAAAAAAAAQAAAIVhdjAxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAEAAQBIAAAASAAAAAAAAAABCkFPTSBDb2RpbmcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGP//AAAADGF2MUOBIAAAAAAAE2NvbHJuY2x4AAEADQAGgAAAABBjY3N0AAAAAHwAAAAAAAAYc3R0cwAAAAAAAAABAAAAAgAAADIAAAAUc3RzcwAAAAAAAAABAAAAAQAAAChzdHNjAAAAAAAAAAIAAAABAAAAAQAAAAEAAAACAAAAAQAAAAEAAAAcc3RzegAAAAAAAAAAAAAAAgAAACUAAAAaAAAAGHN0Y28AAAAAAAAAAgAABgAAAAY9AAACGnRyYWsAAABcdGtoZAAAAAHgasqA4GrL+AAAAAIAAAAAAAAAZAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAQAAAAEAAAAAABR0cmVmAAAADGF1eGwAAAABAAABom1kaWEAAAAgbWRoZAAAAADgasqA4GrKgAAAAGQAAABkVcQAAAAAAChoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAbGliYXZpZgAAAAFSbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAABEnN0YmwAAACCc3RzZAAAAAAAAAABAAAAcmF2MDEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAQABAEgAAABIAAAAAAAAAAEKQU9NIENvZGluZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY//8AAAAMYXYxQ4EAHAAAAAAQY2NzdAAAAAB8AAAAAAAAGHN0dHMAAAAAAAAAAQAAAAIAAAAyAAAAFHN0c3MAAAAAAAAAAQAAAAEAAAAoc3RzYwAAAAAAAAACAAAAAQAAAAEAAAABAAAAAgAAAAEAAAABAAAAHHN0c3oAAAAAAAAAAAAAAAIAAAAYAAAAEAAAABhzdGNvAAAAAAAAAAIAAAYlAAAGVwAAAG9tZGF0EgAKCyAAAAAAffyQENBpMhQQALAAAAJAAAAAeUzeCGsZI8iw4BIACggAAAAAAH38lTIKEACAAAAY3qKVUBIAMhYwA8CAAABGsAAAAkAAIAAeeln6XS7gEgAyDDADwIAAAEaABACRkAAAAENmcmVlSXNvTWVkaWEgRmlsZSBQcm9kdWNlZCB3aXRoIEdQQUMgMi4yLXJldjAtZ2FiMDEyYmJmLW1hc3RlcgA=",height:1}},check=function(r){return 0<=ValidFormat.indexOf(r)&&("jpeg"===r||"png"===r||!!FORMAT_BASE64_MAP[r]&&new Promise(function(t){if("undefined"==typeof window&&t(!1),void 0!==window["__support_".concat(r,"__")])t(!!window["__support_".concat(r,"__")]);else{if(FORMAT_BASE64_MAP[r].prerequisite)if(!FORMAT_BASE64_MAP[r].prerequisite())return window["__support_".concat(r,"__")]=!1,void t(!1);var A=new Image;A.onload=function(){var e=(null==A?void 0:A.height)===FORMAT_BASE64_MAP[r].height;window["__support_".concat(r,"__")]=e,t(e)},A.onerror=function(){window["__support_".concat(r,"__")]=!1,t(!1)},A.src=FORMAT_BASE64_MAP[r].base64}}))},getFormat=function(o){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,new Promise(function(i){__awaiter(void 0,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:"undefined"==typeof window&&i("image"),t=0,A=o,e.label=1;case 1:if(!(t<A.length))return[3,7];r=A[t],n=!1,e.label=2;case 2:return e.trys.push([2,4,,5]),[4,check(r)];case 3:return n=e.sent(),[3,5];case 4:return e.sent(),console.error("格式探测失败"),[3,5];case 5:if(n)return i(r),[3,7];e.label=6;case 6:return t++,[3,1];case 7:return i("image"),[2]}})})})];case 1:return[2,e.sent()]}})})},parseImagexUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t),r=imagexUrlPattern.exec(A.pathname.slice(1));return{protocol:A.protocol,domain:A.hostname,src:r[1],template:r[2],suffix:r[3],search:A.search}}catch(e){return console.error(e),ErrorImageXUrl}},parseOtherUrl=function(e){try{var t=e.startsWith("http")?e:(e.startsWith("//")?"https:":"http://").concat(e),A=new URL(t);return{protocol:A.protocol,domain:A.hostname,src:A.pathname.slice(1),search:A.search}}catch(e){return ErrorUrl}},isImagexUrl=function(e){return imagexUrlPattern.test(e)},getSrc=function(e,t,A){var r,n,i,o,a,s;return t(isImagexUrl(e)?(i=(t=parseImagexUrl(e)).src,o=t.protocol,a=t.domain,r=t.suffix,n=t.template,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{suffix:r,template:n,search:s,protocol:o,domain:a,origin:e}}):(i=(t=parseOtherUrl(e)).src,o=t.protocol,a=t.domain,s=t.search,{src:i,format:FormatsMap[A]||"image",extra:{protocol:o,domain:a,search:s,origin:e}}))},isSupportNativeImage=canIUse(exports.EMixRenderComponents.Image),CSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="image"}return e.prototype.init=function(){var i;return __awaiter(this,void 0,void 0,function(){var t,A,r,n;return __generator(this,function(e){switch(e.label){case 0:return t=this.config.renderer,A=this,"web"!==(t=t&&"auto"!==t?t:isSupportNativeImage?"native":"web")?[3,2]:[4,getFormat((this.config.formats||["avif","webp"]).filter(function(e){return"heic"!==e}))];case 1:return r=e.sent()||"image",[3,3];case 2:r=(null==(i=this.config.formats)?void 0:i[0])||"heic",e.label=3;case 3:return A.renderFormat=r,n=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,FormatsMap[this.renderFormat]||"image")}),this.widget=new("native"===t?CSRImageWidget4Native:ImageWidget4Web)(n),[4,this.widget.init()];case 4:return(n=e.sent())[0]&&(this.isInitialized=!0),[2,n]}})})},e.prototype.setSrc=function(e){return this.widget.setSrc(getSrc(e,this.config.loader,FormatsMap[this.renderFormat]||"image"))},e.prototype.setObjectFit=function(e){return this.widget.setObjectFit(e)},e.prototype.setCornerRadius=function(e){return this.widget.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}(),SSRImageProxy=function(){function e(e){this.config=e,this.isInitialized=!1,this.renderFormat="image"}return e.prototype.init=function(){this.renderFormat="heic";var e=__assign(__assign({},this.config),{src:getSrc(this.config.src,this.config.loader,FormatsMap[this.renderFormat]||"image")}),t=(this.widget=new SSRImageWidget4Native(e),this.widget.init());return this.isInitialized=!0,{id:t,src:e.src}},e.prototype.setSrc=function(e){var t;return null==(t=this.widget)?void 0:t.setSrc(getSrc(e,this.config.loader,FormatsMap[this.renderFormat]||"image"))},e.prototype.setObjectFit=function(e){var t;return null==(t=this.widget)?void 0:t.setObjectFit(e)},e.prototype.setCornerRadius=function(e){var t;return null==(t=this.widget)?void 0:t.setCornerRadius(e)},e.prototype.destroy=function(){var e;return null==(e=this.widget)?void 0:e.destroy()},e}();function createImageProxy(e){return new(void 0!==e.ssrConfig?SSRImageProxy:CSRImageProxy)(e)}var Viewer=function(t){var e,A,r=React.useRef(null),n=React.useRef(null),i=React.useRef(n.current&&n.current.isInitialized),o=React.useRef(-1);return React.useEffect(function(){var e;i.current=null==(e=n.current)?void 0:e.isInitialized},[null==(e=n.current)?void 0:e.isInitialized]),React.useEffect(function(){if(r.current)return i.current||(n.current=createImageProxy({container:r.current,renderer:t.renderer||"auto",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",formats:t.formats||["heic","avif","webp"]}),n.current.init().then(function(e){e[0]&&(i.current=!0)})),function(){var e;n.current&&n.current.destroy&&null!=(e=n.current)&&e.destroy()}},[]),React.useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setSrc(t.src)},[t.src]),React.useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setObjectFit(t.objectFit)},[t.objectFit]),React.useEffect(function(){var e;i.current&&null!=(e=n.current)&&e.setCornerRadius(t.cornerRadius)},[t.cornerRadius]),null!=(e=t.ssrConfig)&&e.isSSR&&null!=(e=t.ssrConfig)&&e.hybridRender&&-1===o.current&&(n.current=createImageProxy({renderer:"native",src:t.src,loader:t.loader,objectFit:t.objectFit,cornerRadius:t.cornerRadius||"",ssrConfig:t.ssrConfig}),e=n.current.init(),o.current=e.id,"undefined"==typeof window&&((A=new Function("return this")()).imagexSsrData||(A.imagexSsrData=[]),A.imagexSsrData.push(__assign(__assign({},e||{}),{width:t.width,height:t.height,objectFit:t.objectFit,cornerRadius:t.cornerRadius||""}))),i.current=!0),React__default.default.createElement("div",{className:"pia-mixrender-image",style:{width:t.width,height:t.height}},null!=(A=t.ssrConfig)&&A.isSSR?null!=(e=t.ssrConfig)&&e.hybridRender?"iOS"===(null==(A=t.ssrConfig)?void 0:A.platform)?React__default.default.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0,overflow:"scroll",WebkitOverflowScrolling:"touch",backgroundColor:"rgba(13, ".concat(Math.floor(o.current/255),", ").concat(Math.floor(o.current%255),", 0.13)")}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"}}),React__default.default.createElement("div",{style:{height:1}})):React__default.default.createElement("div",{ref:r,style:{opacity:1,width:t.width,height:t.height,fontSize:0,lineHeight:0}},React__default.default.createElement("embed",{"tt-embed-id":o.current,type:"ttplugin/hybrid_component",style:{width:"100%",height:"100%"}})):React__default.default.createElement("img",{src:getSrc(t.src,t.loader,"image"),style:{width:"100%",height:"100%",objectFit:t.objectFit,borderRadius:"".concat(Number(t.cornerRadius||0),"px")}}):React__default.default.createElement("div",{ref:r,style:{width:t.width,height:t.height,fontSize:0,lineHeight:0}}))},exportInitScript=function(){var e,t=new Function("return this")();return t.imagexSsrData?(e='<script type="application/javascript">;(function(e){document.addEventListener("DOMContentLoaded",function(){console.log("ImageX SSR Init");const i=window.byted_mixrender_native;if(i)for(let t=0;t<(e||[]).length;t++)i.invoke(e[t].id,"initialize",JSON.stringify({type:"web_image",properties:{src:e[t].src,width:e[t].width,height:e[t].height,objectFit:e[t].objectFit,cornerRadius:e[t].cornerRadius}}),e[t].id)})})('.concat(JSON.stringify(t.imagexSsrData||[]),")<\/script>"),t._mix_render_core_=void 0,t.imagexSsrData=void 0,e):""};exports.CSRImageProxy=CSRImageProxy,exports.SSRImageProxy=SSRImageProxy,exports.ValidFormat=ValidFormat$1,exports.ValidPlatform=ValidPlatform,exports.Viewer=Viewer,exports.createImageProxy=createImageProxy,exports.exportInitScript=exportInitScript;

@@ -1,4 +0,2 @@

import type { IMixRenderRuntimeMode } from '../../mixrender';
import type { IImageObjectFitValues } from './widget';
import type { IRendererType } from '../../customize';
type ProtocolType = 'http:' | 'https:';

@@ -19,2 +17,8 @@ export type IImageLoaderProps = {

export declare const ValidFormat: readonly ["webp", "avif", "heic", "jpeg", "png"];
export declare const ValidPlatform: readonly ["Android", "iOS"];
export type ISSRConfig = {
isSSR?: boolean;
hybridRender?: boolean;
platform?: typeof ValidPlatform[number];
};
export interface IImageProps {

@@ -28,5 +32,5 @@ width: string | number;

cornerRadius?: string;
renderer?: IRendererType;
mode?: IMixRenderRuntimeMode;
ssrConfig?: ISSRConfig;
[props: string]: unknown;
}
export {};
import type { IMixRenderRuntimeMode } from '../../mixrender';
import type { IImageWidget, IImageObjectFitValues } from './widget';
import type { IRendererType } from '../../customize';
import type { ISSRConfig } from './component';
import { IImageLoader, ValidFormat } from '../image';

@@ -8,3 +9,3 @@ export type IImageProxy = IImageWidget & {

};
export interface IImageProxyConfig {
export interface ISSRImageProxyConfig {
src: string;

@@ -14,2 +15,11 @@ cornerRadius?: string;

loader: IImageLoader;
renderer: IRendererType;
mode?: IMixRenderRuntimeMode;
ssrConfig: ISSRConfig;
}
export interface ICSRImageProxyConfig {
src: string;
cornerRadius?: string;
objectFit?: IImageObjectFitValues;
loader: IImageLoader;
formats?: typeof ValidFormat[number][];

@@ -20,1 +30,2 @@ container: HTMLElement;

}
export type IImageProxyConfig = ISSRImageProxyConfig | ICSRImageProxyConfig;
import type { IImageObjectFitValues } from './native';
export interface IImageWidget {
init(): Promise<[boolean, string?]>;
init: Promise<[boolean, unknown?]> | (() => unknown);
destroy(): Promise<[boolean, string?]>;

@@ -5,0 +5,0 @@ setSrc(src: string): Promise<[boolean, string?]>;

@@ -1,4 +0,4 @@

import { LegacyAdapter } from './legacy';
import type { IMixRenderRuntimeMode } from '../../interface';
export declare function getAdapterImpl(_mode: IMixRenderRuntimeMode): typeof LegacyAdapter;
export declare function setupAdapter<T extends Record<string, any>>(id: number, type: string, mode?: IMixRenderRuntimeMode): LegacyAdapter<T>;
import { LegacyAdapter, SSRLegacyAdapter } from './legacy';
import type { IMixRenderRuntimeMode, ISSRConfig } from '../../interface';
export declare function getAdapterImpl(_mode: IMixRenderRuntimeMode, ssrConfig?: ISSRConfig): typeof LegacyAdapter | typeof SSRLegacyAdapter;
export declare function setupAdapter<T extends Record<string, any>>(id: number, type: string, mode?: IMixRenderRuntimeMode, ssrConfig?: ISSRConfig): LegacyAdapter<T> | SSRLegacyAdapter<T>;

@@ -18,1 +18,17 @@ import type { IMixRenderRuntimeMode } from '../../interface';

}
export declare class SSRLegacyAdapter<P extends Record<string, any> = Record<string, any>> {
protected id: number;
protected type: string;
protected mode: IMixRenderRuntimeMode;
constructor(id: number, type: string, mode: IMixRenderRuntimeMode);
init(_properties: Partial<P>): Promise<[boolean, string?]>;
update(properties: Partial<P>): Promise<[boolean, string?]>;
destroy(properties?: Partial<P>): Promise<[boolean, string?]>;
log(properties: Partial<P>): Promise<[boolean, string?]>;
invoke(properties: Partial<P> & {
method: string;
params?: unknown;
}): Promise<[boolean, string?]>;
addEventListener(eventName: string, callback: (params: any) => any): void;
removeEventListener(eventName: string, handler?: (params: any) => any): void;
}

@@ -1,2 +0,2 @@

import { LegacyAdapter } from './legacy';
import { LegacyAdapter, SSRLegacyAdapter } from './legacy';
export declare class PiaMixRenderAdapter<P extends Record<string, any> = Record<string, any>> extends LegacyAdapter<P> {

@@ -9,1 +9,7 @@ init(properties: Partial<P>): Promise<[boolean, string?]>;

}
export declare class SSRPiaMixRenderAdapter<P extends Record<string, any> = Record<string, any>> extends SSRLegacyAdapter<P> {
invoke(properties: Partial<P> & {
method: string;
params?: unknown;
}): Promise<[boolean, string?]>;
}

@@ -1,3 +0,3 @@

import type { IImageProxy, IImageProxyConfig, IImageObjectFitValues } from '../interface';
export declare class ImageProxy implements IImageProxy {
import type { IImageProxy, IImageProxyConfig, ICSRImageProxyConfig, IImageObjectFitValues, ISSRImageProxyConfig } from '../interface';
export declare class CSRImageProxy implements IImageProxy {
private config;

@@ -7,5 +7,4 @@ private widget;

private renderFormat;
constructor(config: IImageProxyConfig);
constructor(config: ICSRImageProxyConfig);
init(): Promise<[boolean, (string | undefined)?]>;
private getSrc;
setSrc(src: string): Promise<[boolean, (string | undefined)?]>;

@@ -16,2 +15,17 @@ setObjectFit(value: IImageObjectFitValues): Promise<[boolean, (string | undefined)?]>;

}
export declare function createImageProxy(config: IImageProxyConfig): ImageProxy;
export declare class SSRImageProxy implements IImageProxy {
private config;
private widget;
isInitialized: boolean;
private renderFormat;
constructor(config: ISSRImageProxyConfig);
init(): {
id: number;
src: string;
};
setSrc(src: string): any;
setObjectFit(value: IImageObjectFitValues): any;
setCornerRadius(value: string): any;
destroy(): Promise<any>;
}
export declare function createImageProxy(config: IImageProxyConfig): CSRImageProxy | SSRImageProxy;

@@ -0,1 +1,2 @@

import type { IImageLoader } from '../interface';
declare global {

@@ -30,2 +31,3 @@ interface Window {

export declare const isImagexUrl: (url: string) => boolean;
export declare const getSrc: (src: string, loader: IImageLoader, format: string) => string;
export {};

@@ -1,3 +0,3 @@

import type { IImageWidget, IImageProxyConfig, IImageObjectFitValues } from '../interface';
export declare class ImageWidget4Native implements IImageWidget {
import type { IImageWidget, IImageObjectFitValues, ICSRImageProxyConfig, ISSRImageProxyConfig } from '../interface';
export declare class CSRImageWidget4Native implements IImageWidget {
private config;

@@ -10,3 +10,3 @@ private id;

private cornerRadiusMatchRes4Pixel;
constructor(config: IImageProxyConfig);
constructor(config: ICSRImageProxyConfig);
init(): Promise<[boolean, (string | undefined)?]>;

@@ -21,1 +21,15 @@ setSrc(src: string): Promise<[boolean, (string | undefined)?]>;

}
export declare class SSRImageWidget4Native implements IImageWidget {
private config;
private id;
private mode;
private adapter;
private placeholder;
constructor(config: ISSRImageProxyConfig);
init(): number;
setSrc(src: string): any;
setObjectFit(value: IImageObjectFitValues): any;
setCornerRadius(value?: string): any;
log(webLog: string): any;
destroy(): Promise<any>;
}

@@ -1,5 +0,5 @@

import type { IImageWidget, IImageProxyConfig, IImageObjectFitValues } from '../interface';
import type { IImageWidget, IImageObjectFitValues, ICSRImageProxyConfig } from '../interface';
export declare class ImageWidget4Web implements IImageWidget {
private config;
constructor(config: IImageProxyConfig);
constructor(config: ICSRImageProxyConfig);
private image;

@@ -6,0 +6,0 @@ init(): Promise<[boolean]>;

{
"name": "@volcengine/imagex-hybrid-react",
"version": "0.1.1",
"version": "0.1.2-alpha.1",
"description": "hybrid image viewer",
"private": false,
"main": "lib/index.js",
"types": "es/src/index.d.ts",
"types": "es/index.d.ts",
"module": "es/index.js",

@@ -9,0 +9,0 @@ "source": "src/index.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc