@lingxia/bridge 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- const __LX_RUNTIME_PLATFORM__="all";var __LingXiaBridgeBundle=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t="BRIDGE_TIMEOUT",n="BRIDGE_CANCELED",o="BRIDGE_HANDSHAKE_FAILED",r="BRIDGE_MALFORMED_MESSAGE",i="BRIDGE_METHOD_NOT_FOUND",s="BRIDGE_CAPABILITY_DENIED",a="BRIDGE_INTERNAL_ERROR",l="BRIDGE_OUTBOX_FULL",c="BRIDGE_STREAM_CLOSED";var d=class extends Error{constructor(e,t,n){super(t),this.name="BridgeInvocationError",this.code=e,this.data=n}};function u(e){if(e instanceof d)return e;if(e&&"object"==typeof e){const t=e;let n=a;("string"==typeof t.code&&""!==t.code.trim()||"number"==typeof t.code&&Number.isFinite(t.code))&&(n=t.code);const o="string"==typeof t.message&&""!==t.message.trim()?t.message:"Unknown error";return new d(n,o,"data"in t?t.data:void 0)}const t=e instanceof Error?e.message:"string"==typeof e?e:"Unknown error";return new d(a,t)}function m(e){const t=u(e);return{code:String(t.code||a),message:"string"==typeof t.message&&""!==t.message.trim()?t.message:"Unknown error",...void 0===t.data?{}:{data:t.data}}}function f({os:e,send:t}){if("undefined"==typeof window)return;if("undefined"==typeof document)return;const n="iOS"===e;if(!n&&"Android"!==e)return;const o=Symbol.for("LingXia.NativeComponentCoverageMonitor");if(window[o]?.installed)return;const r={installed:!0,coveredById:new Map,coveredCount:0,anyCovered:!1,scheduled:!1,hasAnyVideo:!1,scrollLocked:!1,scrollY:0,htmlOverflow:"",bodyOverflow:"",bodyPosition:"",bodyTop:"",bodyWidth:""};function i(e){const t=e.getBoundingClientRect?.();if(!t)return!1;if(t.width<2||t.height<2)return!1;const n=t.left+t.width/2,o=t.top+t.height/2;if(n<0||o<0||n>=window.innerWidth||o>=window.innerHeight)return!1;const r=document.elementFromPoint?.(n,o);return!!r&&(r!==document.documentElement&&r!==document.body&&!(r===e||e.contains(r)))}function s(){r.scheduled=!1;const e=document.querySelectorAll("lx-video[id]");if(r.hasAnyVideo=e.length>0,!r.hasAnyVideo&&0===r.coveredById.size&&!r.anyCovered)return;const o=new Set;for(const n of Array.from(e)){const e=n.id;if(!e)continue;o.add(e);const s=i(n),a=r.coveredById.get(e);a!==s&&(!0===a&&(r.coveredCount-=1),!0===s&&(r.coveredCount+=1),r.coveredById.set(e,s),t({id:e,action:"component.coverage",covered:s}))}const s=[];for(const[e,t]of r.coveredById.entries())o.has(e)||(s.push(e),!0===t&&(r.coveredCount-=1));for(const e of s)r.coveredById.delete(e),t({id:e,action:"component.coverage",covered:!1});const a=r.coveredCount>0;a!==r.anyCovered&&(r.anyCovered=a,n&&(a?function(){if(!n)return;if(r.scrollLocked)return;const e=document.documentElement,t=document.body;e&&t&&(r.scrollLocked=!0,r.scrollY=window.scrollY||e.scrollTop||0,r.htmlOverflow=e.style.overflow||"",r.bodyOverflow=t.style.overflow||"",r.bodyPosition=t.style.position||"",r.bodyTop=t.style.top||"",r.bodyWidth=t.style.width||"",e.style.overflow="hidden",t.style.overflow="hidden",t.style.position="fixed",t.style.top=-r.scrollY+"px",t.style.width="100%")}():function(){if(!n)return;if(!r.scrollLocked)return;const e=document.documentElement,t=document.body;e&&t&&(r.scrollLocked=!1,e.style.overflow=r.htmlOverflow,t.style.overflow=r.bodyOverflow,t.style.position=r.bodyPosition,t.style.top=r.bodyTop,t.style.width=r.bodyWidth,window.scrollTo(0,r.scrollY))}()))}function a(){r.scheduled||(r.scheduled=!0,requestAnimationFrame(s))}window[o]=r,new MutationObserver(a).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0});const l={handleEvent:()=>{(r.hasAnyVideo||0!==r.coveredById.size)&&a()}},c={handleEvent:()=>a()};window.addEventListener("scroll",l,{capture:!0,passive:!0}),window.addEventListener("resize",c),a()}const p="undefined"!=typeof window&&window.__LX_BRIDGE_CFG||{};function h(){return p.os||"unknown"}function g(){return"iOS"===p.os}function v(){return"macOS"===p.os}const y="__LingXiaRecvMessage",x=5e3,w="[LX.Bridge]",b="messageport",k="jsinterface",E={data:!1,proto:!1,all:!1},I=[];function C(e){return E.all||E[e]}function _(...e){console.log(w,...e)}function T(...e){console.warn(w,...e)}function L(...e){console.error(w,...e)}function S(e){try{return JSON.stringify(e)}catch{return function(e,t){const n=new WeakSet;return JSON.stringify(e,(e,t)=>{if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular]";n.add(t)}return t},t)}(e)}}function M(e){try{return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch{return{}}}const N="iOS"===p.os||"macOS"===p.os?"webkit":"Harmony"===p.os?"messageport":"Android"===p.os?window.LingXiaProxy?.supportsMessagePort?.()?"messageport":"jsinterface":"unknown";"undefined"!=typeof window&&"function"!=typeof window[y]&&(window[y]=e=>{I.push(e)});let B=null,A=!1,O=null,P=null,j=null,R=200;const F={listenerInstalled:!1,promise:null,resolve:null,reject:null,timer:null},D={handleEvent:e=>{const t=e;if("LingXia-port-init"!==t.data)return;const n=t.ports?.[0];n&&(He._connectWebMessagePort(n),F.resolve?.(n))}};function X(){F.listenerInstalled||(F.listenerInstalled=!0,window.addEventListener("message",D))}function $(){null!==F.timer&&(window.clearTimeout(F.timer),F.timer=null),F.resolve=null,F.reject=null,F.promise=null}function H(){return"webkit"===N&&(g()||v())}function q(){null!==j&&(clearTimeout(j),j=null)}function z(e){for(const t of Array.from(oe.keys()))ve(t,{code:c,message:e});for(const t of Array.from(re.keys()))ye(t,{code:c,message:e});!function(e){for(const[t,n]of Array.from(ie.entries()))ie.delete(t),n._emitClose(c,e)}(e)}function G(e){let t=e;for(;;){const e=t.indexOf("\n");if(e<0)break;const n=t.slice(0,e).trim();if(t=t.slice(e+1),n)try{Ne(JSON.parse(n))}catch(e){T("Apple downstream parse error:",e,n)}}return t}function U(){H()&&(O||(q(),O=async function(){const e=new AbortController;let t;P=e;try{t=await fetch("lx-apple://bridge/downstream",{method:"GET",cache:"no-store",headers:{Accept:"application/x-ndjson"},signal:e.signal})}catch(t){if(e.signal.aborted)return;throw t}if(!t.ok)throw new Error(`Apple downstream HTTP ${t.status}`);if(!t.body)throw new Error("Apple downstream response body unavailable");A=!0,R=200,C("proto")&&_("Apple downstream connected"),Ce();const n=t.body.getReader(),o=new TextDecoder;let r="";try{for(;;){const{value:e,done:t}=await n.read();if(t)break;r+=o.decode(e,{stream:!0}),r=G(r)}r+=o.decode();const e=r.trim();if(e)try{Ne(JSON.parse(e))}catch(t){T("Apple downstream trailing parse error:",t,e)}}finally{try{n.releaseLock()}catch{}}}().catch(e=>{P?.signal.aborted||T("Apple downstream failed:",e)}).finally(()=>{const e=P?.signal.aborted??!1;O=null,P=null;const t=A;var n,o;A=!1,n="Apple downstream closed",o=t,Ie(),J=null,Y=!1,V=!1,K=0,o&&z(n),e||function(e){if(!H())return;q();const t=R;R=Math.min(2*R,2e3);const n=`Apple downstream disconnected, retrying in ${t}ms: ${e}`;t<=200?_(n):T(n),j=setTimeout(()=>{j=null,U()},t)}("stream closed")})))}function W(e){const t=e.kind;"req"!==t&&"notify"!==t||_(`postToNative: ${t} ${e.method}`),C("proto")&&console.log("→",JSON.stringify(e,null,2));try{if("webkit"===N)return void window.webkit?.messageHandlers.LingXia?.postMessage(e);const t=S(e);if(N===b&&B)return void B.postMessage(t);if(N===k&&window.LingXiaProxy?.postMessage)return void window.LingXiaProxy.postMessage(t);T("Transport not ready")}catch(e){L("Send error:",e)}}let J=null,Y=!1,V=!1,K=0,Q=null;const Z={};let ee=0;function te(){return{data:new Set,end:new Set,error:new Set,close:new Set}}function ne(e,t){const n=te();let o=!1,r=()=>{},i=()=>{};const s=[],a=[],l=new Promise((e,t)=>{r=e,i=t});return{id:e,result:l,on(e,t){return"data"===e&&n.data.add(t),"end"===e&&n.end.add(t),"error"===e&&n.error.add(t),this},[Symbol.asyncIterator]:()=>({next:()=>s.length>0?Promise.resolve({done:!1,value:s.shift()}):o?l.then(e=>({done:!0,value:e}),e=>Promise.reject(e)):new Promise((e,t)=>{a.push({resolve:e,reject:t})})}),cancel(){o||t()},_emitData(e){if(!o){a.length>0?a.shift().resolve({done:!1,value:e}):s.push(e);for(const t of n.data)try{t(e)}catch(e){T("Stream data listener failed:",e)}}},_resolve(e){if(!o){for(o=!0,r(e);a.length>0;)a.shift().resolve({done:!0,value:e});for(const t of n.end)try{t(e)}catch(e){T("Stream end listener failed:",e)}}},_reject(e){if(!o){for(o=!0,i(e);a.length>0;)a.shift().reject(e);for(const t of n.error)try{t(e)}catch(e){T("Stream error listener failed:",e)}}}}}const oe=new Map,re=new Map,ie=new Map,se=[];let ae=-1,le={};const ce=new Set,de=new WeakMap,ue=new Map;function me(e,t){ue.set(e,t)}function fe(e){if(e.startsWith("host."))return"host";const t=e.indexOf(".");return t>0?e.slice(0,t):"page"}function pe(e){if(null!=e)return e}function he(){return N===b?!!B:H()?A:"webkit"===N||N===k}function ge(){return he()&&Y}function ve(e,t){const n=oe.get(e);if(n){oe.delete(e),null!==n.timerId&&clearTimeout(n.timerId);const o=u(t);if("stream"===n.mode&&n.stream)return void n.stream._reject(o);n.reject?.(o)}}function ye(e,t){const n=re.get(e);if(!n)return;re.delete(e),null!==n.timerId&&clearTimeout(n.timerId);const o=u(t);n.channel._reject(o),n.reject(o)}function xe(e,t){oe.has(e)?ve(e,t):re.has(e)&&ye(e,t)}function we(e){const n=oe.get(e);n&&(!Number.isFinite(n.timeoutMs)||n.timeoutMs<=0?null!==n.timerId&&(clearTimeout(n.timerId),n.timerId=null):(null!==n.timerId&&clearTimeout(n.timerId),n.timerId=setTimeout(()=>{oe.has(e)&&ve(e,{code:t,message:`'${n.method}' timed out`})},n.timeoutMs)))}function be(e){oe.has(e)?we(e):re.has(e)&&function(e){const n=re.get(e);n&&(null!==n.timerId&&clearTimeout(n.timerId),n.timerId=setTimeout(()=>{ye(e,{code:t,message:`Channel '${n.topic}' timed out`})},x))}(e)}function ke(e){for(let t=se.length-1;t>=0;t--)if(se[t]?.reqId===e)return se.splice(t,1),!0;return!1}function Ee(e,t){const n=e.kind,o="hello"===n||"helloAck"===n||"ready"===n;if(!ge()&&!o)return se.length>=256?(L("Outbox full"),void(t&&xe(t,{code:l,message:"Bridge outbox is full"}))):void se.push({msg:e,reqId:t});t&&be(t),W(e)}function Ie(){null!==Q&&(clearTimeout(Q),Q=null)}function Ce(){if(Y)return;if(!he())return;Ie();const e={v:2,kind:"hello",nonce:p.nonce||"",role:"view",protocolsSupported:[2]};V=!0,W(e),Q=setTimeout(()=>{if(!Y)if(K++,K<3)T(`Handshake timeout (${K}/3), retrying...`),V=!1,Ce();else{for(L("Handshake failed"),Ie(),V=!1,K=0;se.length;){const e=se.shift();e?.reqId&&xe(e.reqId,{code:o,message:"Bridge handshake failed"})}for(const e of Array.from(re.keys()))ye(e,{code:o,message:"Bridge handshake failed"})}},1e4)}function _e(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Te(e,t,n=!1){const o=function(e){if(""===e)return[];if(!e.startsWith("/"))throw new Error(`Invalid JSON pointer: ${e}`);return e.split("/").slice(1).map(_e)}(t);if(0===o.length)return{container:{$root:e},key:"$root"};let r=e;for(let e=0;e<o.length-1;e++){const t=o[e];if(Array.isArray(r))r=r[Number(t)];else{if(!r||"object"!=typeof r)throw new Error(`Invalid container at ${t}`);{const i=r;if(n&&void 0===i[t]){const n=o[e+1];i[t]=n&&/^\d+$/.test(n)?[]:{}}r=i[t]}}}return{container:r,key:o[o.length-1]}}function Le(e){ce.forEach(t=>{try{if(!de.has(t))return de.set(t,!0),void t(M(le),{rev:ae,initial:!0});t(M(le),{rev:ae,initial:e})}catch(e){T("Subscriber error:",e)}})}function Se(e){if("function"!=typeof e)return()=>{};if(ce.add(e),ae>=0){de.set(e,!0);try{e(M(le),{rev:ae,initial:!0})}catch(e){L("Callback error:",e)}}return()=>{ce.delete(e),de.delete(e)}}function Me(e){$e.call("state.getSnapshot",{scope:e}).catch(()=>{})}function Ne(e){if(e&&"object"==typeof e){const t=e;if("event"===t.type&&"nativecomponent"===t.name&&t.payload){const e=t.payload,n=e.id||e.componentId;if("string"==typeof n){const t=Be.get(n);if(t)try{t(e)}catch(e){L("NC handler error:",e)}}return}}const t=function(e){if(!e||"object"!=typeof e)return null;const t=e.v,n=e.kind;return 2!==t||"string"!=typeof n?null:e}(e);if(t)switch(t.kind){case"helloAck":return void(J=t.sessionId);case"ready":if(J&&t.sessionId!==J)return void T("sessionId mismatch");if(Ie(),Y=!0,K=0,t.hostMethods)for(const[e,n]of Object.entries(t.hostMethods))Z[e]=n;return C("proto")&&_("Handshake complete, hostMethods:",Object.keys(Z).length),void function(){if(ge())for(;se.length;){const e=se.shift();e&&(e.reqId&&be(e.reqId),W(e.msg))}}();case"res":{const e=oe.get(t.id);if(!e)return;if(oe.delete(t.id),null!==e.timerId&&clearTimeout(e.timerId),t.ok){if("state.getSnapshot"===e.method&&(function(e){if(!e||"object"!=typeof e)return!1;const t=e;return!("number"!=typeof t.rev||!Number.isFinite(t.rev)||!t.state||"object"!=typeof t.state||(le=t.state,ae=t.rev,C("data")&&(console.group("[LX] snapshot(res)"),console.log("rev:",ae,"state:",M(le)),console.groupEnd()),Le(!0),0))}(t.result)||T("Invalid state.getSnapshot result")),"stream"===e.mode&&e.stream)return void e.stream._resolve(t.result);e.resolve?.(t.result)}else{const n=u(t.error);if("stream"===e.mode&&e.stream)return void e.stream._reject(n);e.reject?.(n)}return}case"event":if(oe.has(t.id)){const e=oe.get(t.id);return void("stream"===e?.mode&&e.stream?(we(t.id),e.stream._emitData(t.payload)):T(`Received event for non-stream request '${t.id}'`))}return;case"state.snapshot":return le=t.state||{},ae=t.rev,C("data")&&(console.group("[LX] snapshot"),console.log("rev:",ae,"state:",M(le)),console.groupEnd()),void Le(!0);case"state.patch":if(t.baseRev!==ae)return T("baseRev mismatch",{have:ae,want:t.baseRev}),void Me(t.scope);try{!function(e,t){for(const n of t){const t="add"===n.op||"replace"===n.op,{container:o,key:r}=Te(e,n.path,t);if("$root"===r){for(const t of Object.keys(e))delete e[t];if("remove"!==n.op){const t=n.value;t&&"object"==typeof t&&Object.assign(e,t)}continue}if(Array.isArray(o)){const e="-"===r?o.length:Number(r);if(!Number.isFinite(e)||e<0)throw new Error("Invalid index");"remove"===n.op?o.splice(e,1):"add"===n.op?o.splice(e,0,n.value):"replace"===n.op&&(o[e]=n.value);continue}if(!o||"object"!=typeof o)throw new Error("Invalid container");const i=o;"remove"===n.op?delete i[r]:i[r]=n.value}}(le,t.ops||[]),ae=t.rev}catch(e){return L("Patch failed:",e),void Me(t.scope)}return C("data")&&(console.group("[LX] patch"),console.log("rev:",ae,"ops:",t.ops),console.groupEnd()),Le(!1),void(t.ack&&Ee({v:2,kind:"state.ack",scope:t.scope,rev:t.rev}));case"ch.ack":{const e=re.get(t.id);if(!e)return;if(re.delete(t.id),null!==e.timerId&&clearTimeout(e.timerId),t.ok)e.channel._markOpen(),ie.set(t.id,e.channel),e.resolve(e.channel);else{const n=u(t.error);e.channel._reject(n),e.reject(n)}return}case"ch.data":{const e=ie.get(t.id);if(!e)return;return void e._emitData(t.payload)}case"ch.close":{const e=re.get(t.id);if(e)return re.delete(t.id),void e.channel._emitClose(t.code,t.reason);const n=ie.get(t.id);if(!n)return;return ie.delete(t.id),void n._emitClose(t.code,t.reason)}case"req":{const e=t,n=fe(e.method);if(!e.cap||e.cap!==n)return void Ee({v:2,kind:"res",id:e.id,ok:!1,error:{code:s,message:`Invalid cap for ${e.method}`}});const o=ue.get(e.method);return o?void Promise.resolve().then(()=>o(e.params)).then(t=>{Ee({v:2,kind:"res",id:e.id,ok:!0,result:t})}).catch(t=>{Ee({v:2,kind:"res",id:e.id,ok:!1,error:u(t)})}):void Ee({v:2,kind:"res",id:e.id,ok:!1,error:{code:i,message:`View handler not found: ${e.method}`}})}}else T("Invalid V2 message:",e)}const Be=new Map,Ae=[];let Oe=!1;function Pe(){return"undefined"!=typeof window&&!(!window.webkit?.messageHandlers?.NativeComponent&&!window.NativeComponentBridge?.postMessage)}function je(e){try{if(window.webkit?.messageHandlers?.NativeComponent)return void window.webkit.messageHandlers.NativeComponent.postMessage(e);if(window.NativeComponentBridge?.postMessage)return void window.NativeComponentBridge.postMessage(S(e))}catch(e){L("NativeComponent send error:",e)}}function Re(){if(Pe()&&0!==Ae.length)for(Oe=!0;Ae.length;){const e=Ae.shift();try{je(e)}catch{break}}}function Fe(e){try{if(!Pe())return void Ae.push(e);Oe||Re(),je(e)}catch(e){L("NC send failed:",e)}}function De(e){return`${e}_${Date.now()}_${ee++}`}function Xe(e,t,n){if(!t)return;if(t.aborted)return void n();let o={handleEvent:()=>{t.removeEventListener("abort",o),n()}};t.addEventListener("abort",o)}const $e={call:(e,t,o)=>new Promise((i,s)=>{if(!e||"string"!=typeof e)return void s({code:r,message:"Method name must be a non-empty string"});V||Ce();const a=De("c"),l=o?.cap||fe(e),c=o?.timeoutMs??x;oe.set(a,{method:e,mode:"call",resolve:i,reject:e=>s(e),timeoutMs:c,timerId:null}),Ee({v:2,kind:"req",id:a,method:e,params:pe(t),cap:l},a),Xe(0,o?.signal,()=>{const e=ke(a);ve(a,{code:n,message:"Bridge request aborted"}),!e&&Y&&Ee({v:2,kind:"cancel",id:a})})}),stream(e,t,o){if(!e||"string"!=typeof e){const e=ne("invalid",()=>{});return e._reject({code:r,message:"Method name must be a non-empty string"}),e}V||Ce();const i=De("c"),s=ne(i,()=>{ke(i)?ve(i,{code:n,message:"Bridge request aborted"}):Y&&Ee({v:2,kind:"cancel",id:i})}),a=o?.cap||fe(e),l=o?.timeoutMs??x;return oe.set(i,{method:e,mode:"stream",stream:s,timeoutMs:l,timerId:null}),Ee({v:2,kind:"req",id:i,method:e,params:pe(t),cap:a},i),Xe(0,o?.signal,()=>s.cancel()),s},notify(e,t,n){e&&"string"==typeof e&&(V||Ce(),Ee({v:2,kind:"notify",method:e,params:pe(t),cap:n?.cap||fe(e)}))},state:{subscribe:Se},channel:{open:(e,t,n)=>e&&"string"==typeof e?(V||Ce(),new Promise((o,r)=>{const i=De("ch"),s=function(e,t,n){const o=te();let r=!1,i=0,s=!1;const a=[],l=[],d={id:e,send(n){r?t(n,i++):d._reject({code:c,message:`Channel '${e}' is closed`})},on(e,t){return"data"===e&&o.data.add(t),"close"===e&&o.close.add(t),"error"===e&&o.error.add(t),this},[Symbol.asyncIterator]:()=>({next:()=>a.length>0?Promise.resolve({done:!1,value:a.shift()}):s?Promise.resolve({done:!0,value:void 0}):new Promise((e,t)=>{l.push({resolve:e,reject:t})})}),close(e,t){r&&(r=!1,s=!0,n(e,t),d._emitClose(e,t))},_emitData(e){if(r){l.length>0?l.shift().resolve({done:!1,value:e}):a.push(e);for(const t of o.data)try{t(e)}catch(e){T("Channel listener failed:",e)}}},_emitClose(e,t){for(s=!0;l.length>0;)l.shift().resolve({done:!0,value:void 0});for(const n of o.close)try{n(e,t)}catch(e){T("Channel close listener failed:",e)}},_reject(e){for(s=!0;l.length>0;)l.shift().reject(e);for(const t of o.error)try{t(e)}catch(e){T("Channel error listener failed:",e)}},_markOpen(){r=!0,s=!1},_isOpen:()=>r,_nextSeq:()=>i++};return d}(i,(e,t)=>{Ee({v:2,kind:"ch.data",id:i,seq:t,payload:e})},(e,t)=>{const n=re.get(i);n&&null!==n.timerId&&clearTimeout(n.timerId),re.delete(i),ie.delete(i),Ee({v:2,kind:"ch.close",id:i,code:e,reason:t})});re.set(i,{topic:e,channel:s,resolve:o,reject:r,timerId:null}),Ee({v:2,kind:"ch.open",id:i,topic:e,params:pe(t),cap:n?.cap||fe(e)},i)})):Promise.reject({code:r,message:"Topic name must be a non-empty string"})}},He={invoke:(e,t,n)=>$e.call(qe(e),t,ze(n)).then(e=>e).catch(e=>Promise.reject(m(e))),notify(e,t,n){$e.notify(qe(e),t,ze(n))},stream:(e,t,n)=>Ge($e.stream(qe(e),t,ze(n))),channel:(e,t,n)=>$e.channel.open(qe(e),t,ze(n)).then(e=>function(e){const t=new Set,n=new Set;return e.on("data",e=>{for(const n of t)n(e)}),e.on("close",(e,t)=>{const o={code:e,reason:t};for(const e of n)e(o)}),{send(t){e.send(t)},onMessage:e=>(t.add(e),()=>{t.delete(e)}),onClose:e=>(n.add(e),()=>{n.delete(e)}),close(t,n){e.close(t,n)}}}(e)).catch(e=>Promise.reject(m(e))),raw:$e,state:{subscribe:Se},_connectWebMessagePort(e){if(N===b){if(B&&B!==e)try{B.onmessage=null,B.close()}catch{}B=e,e.onmessage=e=>{let t=e.data;if("string"==typeof t)try{t=JSON.parse(t)}catch{return}Ne(t)};try{e.start()}catch{}_("Port connected"),Ce()}},_receiveEvaluateMessage(e){try{e&&Ne(JSON.parse(e))}catch(e){L("Parse error:",e)}},debug:new Proxy(E,{get:(e,t)=>e[t],set:(e,t,n)=>t in e&&(e[t]=!!n,console.log(`[LX] ${t}: ${n}`),!0)}),platform:{isHarmony:function(){return"Harmony"===p.os},isIOS:g,isAndroid:function(){return"Android"===p.os},isMacOS:v,isDesktop:function(){return v()},getOS:h},dom:{measureById(e){try{if(!e)return null;const t=document.getElementById(e);if(!t)return null;const n=t.getBoundingClientRect();let o=0;try{o=parseFloat(getComputedStyle(t).borderRadius)||0}catch{}return[n.left+window.scrollX,n.top+window.scrollY,n.width,n.height,o]}catch{return null}}},nativeComponents:{send:Fe,hasHandler:Pe,flush:Re,register:(e,t)=>e&&"function"==typeof t?(Be.set(e,t),()=>Be.delete(e)):()=>{},unregister(e){Be.delete(e)}},isReady:()=>Y};function qe(e){return e.startsWith("host.")?e:`host.${e}`}function ze(e){return{...e||{},cap:e?.cap||"host"}}function Ge(e){const t=new Set,n=new Set;return e.on("data",e=>{for(const n of t)n(e)}),e.on("error",e=>{const t=m(e);for(const e of n)e(t)}),{onEvent:e=>(t.add(e),()=>{t.delete(e)}),onError:e=>(n.add(e),()=>{n.delete(e)}),result:e.result.catch(e=>Promise.reject(m(e))),cancel(){e.cancel()}}}function Ue(){if(window.__LX_BRIDGE_INIT_STATE)_(`Bridge already ${window.__LX_BRIDGE_INIT_STATE}, skipping duplicate init`);else{window.__LX_BRIDGE_INIT_STATE="initializing";try{_(`Method: ${N}`),function(e){if("undefined"==typeof window)return;if(window[y]=e,0===I.length)return;const t=I.splice(0,I.length);for(const n of t)try{e(n)}catch(e){T("Failed to replay queued native message:",e)}}(He._receiveEvaluateMessage),H()?U():N===b?(X(),function(){if(B)return Promise.resolve(B);if(F.promise)return F.promise;X(),F.promise=new Promise((e,t)=>{F.resolve=t=>{$(),e(t)},F.reject=e=>{$(),t(e)},F.timer=window.setTimeout(()=>{F.reject?.(new Error("MessagePort init timed out after 5000ms"))},5e3)});try{window.LingXiaProxy?.getPort("LingXiaPort")}catch(e){F.reject?.(e)}return F.promise}().catch(e=>T("Port init failed:",e))):"webkit"===N||N===k?Ce():T("Unknown method"),window.LingXiaBridge=He,f({os:h(),send:Fe}),window.__LX_BRIDGE_INIT_STATE="initialized",_("Init complete")}catch(e){throw delete window.__LX_BRIDGE_INIT_STATE,e}}}function We(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function Je(e){const{failedPath:t,reason:n}=e,o=document.createElement("style");o.textContent="\n* { margin: 0; padding: 0; box-sizing: border-box; }\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: #f5f5f7;\n color: #1d1d1f;\n padding: 20px;\n -webkit-font-smoothing: antialiased;\n}\n.lx-error {\n text-align: center;\n max-width: 400px;\n}\n.lx-error-code {\n font-size: 120px;\n font-weight: 700;\n color: #d1d1d6;\n line-height: 1;\n letter-spacing: -4px;\n}\n.lx-error-title {\n font-size: 21px;\n font-weight: 600;\n margin: 16px 0 8px;\n color: #1d1d1f;\n}\n.lx-error-desc {\n font-size: 15px;\n color: #86868b;\n line-height: 1.5;\n}\n.lx-error-path {\n display: inline-block;\n margin-top: 20px;\n padding: 10px 16px;\n background: rgba(0,0,0,0.04);\n border-radius: 8px;\n font-family: 'SF Mono', ui-monospace, Menlo, Monaco, monospace;\n font-size: 13px;\n color: #1d1d1f;\n word-break: break-all;\n max-width: 100%;\n}\n@media (prefers-color-scheme: dark) {\n body { background: #000; color: #f5f5f7; }\n .lx-error-code { color: #3a3a3c; }\n .lx-error-title { color: #f5f5f7; }\n .lx-error-desc { color: #86868b; }\n .lx-error-path { background: rgba(255,255,255,0.08); color: #f5f5f7; }\n}\n",document.head.appendChild(o),document.body.innerHTML="",document.body.style.cssText="";const r=document.createElement("div");r.className="lx-error";let i='<div class="lx-error-code">404</div>';i+='<h1 class="lx-error-title">Page Not Found</h1>',i+="<p class=\"lx-error-desc\">The page you're looking for doesn't exist.</p>",t&&(i+=`<div class="lx-error-path">${We(t)}</div>`),n&&(i+=`<p class="lx-error-desc" style="margin-top:12px">${We(n)}</p>`),r.innerHTML=i,document.body.appendChild(r)}function Ye(){const e=window.__LX_RUNTIME_CONFIG;return!(!e||!e.error)}function Ve(){return window.__LX_RUNTIME_CONFIG?.error||null}const Ke={handleEvent:()=>Qe()};function Qe(){if(Ye()){const e=Ve();e&&Je(e)}}function Ze(){Ue(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Ke):Qe()}const et="lx-action-sheet-style";let tt=null;function nt(e){const t=e,n=t?.itemList??[],o=t?.cancelText??"Cancel",r=t?.itemColor??"#007AFF",i=(tt??Promise.resolve()).then(()=>ot(n,o,r),()=>ot(n,o,r));return tt=i,i}function ot(e,t,n){return new Promise(o=>{let r=!1;const i="macOS"===h();!function(){if(document.getElementById(et))return;const e=document.createElement("style");e.id=et,e.textContent="\n.lx-as-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity 300ms ease;\n}\n.lx-as-backdrop.lx-as-visible { opacity: 1; }\n\n.lx-as-sheet {\n position: fixed; left: 0; right: 0; bottom: 0; z-index: 100000;\n transform: translateY(100%);\n transition: transform 300ms ease;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n}\n.lx-as-sheet.lx-as-visible { transform: translateY(0); }\n.lx-as-sheet.lx-as-desktop {\n left: 50%;\n right: auto;\n bottom: auto;\n top: 50%;\n width: min(92vw, 460px);\n transform: translate(-50%, calc(-50% + 16px));\n}\n.lx-as-sheet.lx-as-desktop.lx-as-visible { transform: translate(-50%, -50%); }\n\n.lx-as-container {\n background: #fff;\n border-radius: 16px 16px 0 0;\n overflow: hidden;\n}\n.lx-as-container.lx-as-desktop {\n border-radius: 16px;\n}\n\n.lx-as-item {\n display: block; width: 100%;\n height: 56px;\n line-height: 56px;\n padding: 0;\n border: none; background: none;\n font-size: 18px; font-weight: 400;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n position: relative;\n}\n.lx-as-item:active { background: rgba(0,0,0,0.08); }\n.lx-as-item + .lx-as-item::before {\n content: ''; position: absolute; top: 0; left: 0; right: 0;\n height: 1px; background: #E0E0E0;\n}\n.lx-as-separator {\n height: 8px;\n background: #F2F2F2;\n}\n.lx-as-cancel-btn { font-weight: 500; color: #000; }\n",document.head.appendChild(e)}();const s=document.createElement("div");s.className="lx-as-backdrop";const a=document.createElement("div");a.className="lx-as-sheet",i&&a.classList.add("lx-as-desktop");const l=document.createElement("div");l.className="lx-as-container",i&&l.classList.add("lx-as-desktop"),e.forEach((e,t)=>{const o=document.createElement("button");o.className="lx-as-item",o.textContent=e,o.style.color=n,o.addEventListener("click",()=>u(t)),l.appendChild(o)});const c=document.createElement("div");c.className="lx-as-separator",l.appendChild(c);const d=document.createElement("button");function u(e){r||(r=!0,s.classList.remove("lx-as-visible"),a.classList.remove("lx-as-visible"),setTimeout(()=>{s.remove(),a.remove(),o({tapIndex:e})},300))}d.className="lx-as-item lx-as-cancel-btn",d.textContent=t,d.addEventListener("click",()=>u(-1)),l.appendChild(d),a.appendChild(l),document.body.appendChild(s),document.body.appendChild(a),requestAnimationFrame(()=>{s.classList.add("lx-as-visible"),a.classList.add("lx-as-visible")}),s.addEventListener("click",()=>u(-1))})}const rt=200,it="lx-modal-style";let st=null;function at(e){const t=e,n=t?.title??"",o=t?.content??"",r=t?.showCancel??!0,i=t?.cancelText??"Cancel",s=t?.cancelColor,a=t?.confirmText??"OK",l=t?.confirmColor??"#007AFF",c=(st??Promise.resolve()).then(()=>lt(n,o,r,i,s,a,l),()=>lt(n,o,r,i,s,a,l));return st=c,c}function lt(e,t,n,o,r,i,s){return new Promise(a=>{let l=!1;!function(){if(document.getElementById(it))return;const e=document.createElement("style");e.id=it,e.textContent="\n.lx-modal-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity 200ms ease;\n display: flex; align-items: center; justify-content: center;\n}\n.lx-modal-backdrop.lx-modal-visible { opacity: 1; }\n\n.lx-modal-dialog {\n width: min(92vw, 320px);\n background: #fff;\n border-radius: 14px;\n overflow: hidden;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n transform: scale(0.95); opacity: 0;\n transition: transform 200ms ease, opacity 200ms ease;\n}\n.lx-modal-backdrop.lx-modal-visible .lx-modal-dialog {\n transform: scale(1); opacity: 1;\n}\n\n.lx-modal-body {\n padding: 24px 20px 16px;\n text-align: center;\n}\n.lx-modal-title {\n margin: 0 0 8px;\n font-size: 17px;\n font-weight: 600;\n color: #000;\n line-height: 1.35;\n}\n.lx-modal-content {\n margin: 0;\n font-size: 14px;\n color: #666;\n line-height: 1.5;\n word-break: break-word;\n}\n.lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n font-size: 17px;\n font-weight: 600;\n color: #000;\n}\n\n.lx-modal-footer {\n display: flex;\n border-top: 1px solid #E0E0E0;\n}\n.lx-modal-btn {\n flex: 1;\n height: 44px;\n line-height: 44px;\n padding: 0;\n border: none;\n background: none;\n font-size: 17px;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n.lx-modal-btn:active { background: rgba(0,0,0,0.06); }\n.lx-modal-btn + .lx-modal-btn {\n border-left: 1px solid #E0E0E0;\n}\n.lx-modal-btn-cancel {\n color: #666;\n font-weight: 400;\n}\n.lx-modal-btn-confirm {\n font-weight: 600;\n}\n\n@media (prefers-color-scheme: dark) {\n .lx-modal-dialog { background: #2c2c2e; }\n .lx-modal-title { color: #f5f5f7; }\n .lx-modal-content { color: #ababab; }\n .lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n color: #f5f5f7;\n }\n .lx-modal-footer { border-top-color: #3a3a3c; }\n .lx-modal-btn:active { background: rgba(255,255,255,0.08); }\n .lx-modal-btn + .lx-modal-btn { border-left-color: #3a3a3c; }\n .lx-modal-btn-cancel { color: #ababab; }\n}\n",document.head.appendChild(e)}();const c=document.createElement("div");c.className="lx-modal-backdrop";const d=document.createElement("div");d.className="lx-modal-dialog";const u=document.createElement("div");u.className="lx-modal-body";const m=document.createElement("div");if(m.className="lx-modal-title",m.textContent=e,u.appendChild(m),t){const e=document.createElement("p");e.className="lx-modal-content",e.textContent=t,u.appendChild(e)}d.appendChild(u);const f=document.createElement("div");if(f.className="lx-modal-footer",n){const e=document.createElement("button");e.className="lx-modal-btn lx-modal-btn-cancel",e.textContent=o,r&&(e.style.color=r),e.addEventListener("click",()=>h(!1)),f.appendChild(e)}const p=document.createElement("button");function h(e){l||(l=!0,c.classList.remove("lx-modal-visible"),setTimeout(()=>{c.remove(),a({confirm:e,cancel:!e})},rt))}p.className="lx-modal-btn lx-modal-btn-confirm",p.textContent=i,p.style.color=s,p.addEventListener("click",()=>h(!0)),f.appendChild(p),d.appendChild(f),c.appendChild(d),document.body.appendChild(c),requestAnimationFrame(()=>{c.classList.add("lx-modal-visible")})})}const ct="lx-toast-style";let dt=null;function ut(e){const t=e,n=t?.title??"",o=t?.icon??"none",r=t?.duration??1500,i=t?.mask??!1,s=t?.position??"center";dt&&(dt.dismiss(),dt=null),function(){if(document.getElementById(ct))return;const e=document.createElement("style");e.id=ct,e.textContent="\n.lx-toast-mask {\n position: fixed; inset: 0; z-index: 99998;\n}\n.lx-toast-container {\n position: fixed; left: 0; right: 0; z-index: 99999;\n display: flex; justify-content: center;\n pointer-events: none;\n}\n.lx-toast-container.lx-toast-top { top: 0; padding-top: 80px; }\n.lx-toast-container.lx-toast-center { top: 0; bottom: 0; align-items: center; }\n.lx-toast-container.lx-toast-bottom { bottom: 0; padding-bottom: 80px; }\n\n.lx-toast-box {\n display: flex; flex-direction: column; align-items: center; gap: 10px;\n min-width: 120px; max-width: 280px;\n padding: 20px;\n background: rgba(0,0,0,0.8);\n border-radius: 12px;\n color: #fff;\n pointer-events: auto;\n transform: scale(0.8); opacity: 0;\n transition: transform 200ms ease, opacity 200ms ease;\n}\n.lx-toast-box.lx-toast-no-icon {\n min-width: auto; min-height: auto;\n padding: 12px 20px;\n}\n.lx-toast-box.lx-toast-visible {\n transform: scale(1); opacity: 1;\n}\n.lx-toast-icon {\n width: 36px; height: 36px;\n color: #fff;\n line-height: 0;\n}\n.lx-toast-title {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n font-size: 16px; font-weight: 500;\n text-align: center;\n line-height: 1.4;\n word-break: break-word;\n -webkit-font-smoothing: antialiased;\n}\n",document.head.appendChild(e)}();let a=null;i&&(a=document.createElement("div"),a.className="lx-toast-mask",document.body.appendChild(a));const l=document.createElement("div");l.className="lx-toast-container","top"===s?l.classList.add("lx-toast-top"):"bottom"===s?l.classList.add("lx-toast-bottom"):l.classList.add("lx-toast-center");const c=document.createElement("div");c.className="lx-toast-box";const d="none"!==o;if(d||c.classList.add("lx-toast-no-icon"),d){const e=document.createElement("div");e.className="lx-toast-icon","success"===o?e.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M11 18l5 5 9-9" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>':"error"===o?e.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M13 13l10 10M23 13l-10 10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>':"loading"===o&&(e.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 4a14 14 0 0 1 14 14" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.8s" repeatCount="indefinite"/></path></svg>'),c.appendChild(e)}const u=document.createElement("div");u.className="lx-toast-title",u.textContent=n,c.appendChild(u),l.appendChild(c),document.body.appendChild(l),requestAnimationFrame(()=>{c.classList.add("lx-toast-visible")});let m=!1;function f(){m||(m=!0,dt?.dismiss===f&&(dt=null),c.classList.remove("lx-toast-visible"),p&&clearTimeout(p),setTimeout(()=>{l.remove(),a?.remove()},200))}let p=null;return r>0&&(p=setTimeout(f,r)),dt={dismiss:f,timer:p},Promise.resolve()}function mt(){return dt&&(dt.dismiss(),dt=null),Promise.resolve()}return me("ui.showActionSheet",nt),me("ui.showModal",at),me("ui.showToast",ut),me("ui.hideToast",mt),Ze(),e.LingXiaBridge=He,e.boot=function(){Ue(),Qe()},e.bootWhenReady=Ze,e.channel=function(e,t,n){return He.channel(e,t,n)},e.getErrorInfo=Ve,e.hasError=Ye,e.initBridge=Ue,e.invoke=function(e,t,n){return He.invoke(e,t,n)},e.isNativeError=function(e,t){if(!e||"object"!=typeof e)return!1;const n=e;return"string"==typeof n.code&&""!==n.code.trim()&&("string"==typeof n.message&&(void 0===t||n.code===t))},e.notify=function(e,t,n){$e.notify(qe(e),t,ze(n))},e.renderErrorUI=Je,e.stream=function(e,t,n){return Ge($e.stream(qe(e),t,ze(n)))},e}({});
1
+ const __LX_RUNTIME_PLATFORM__="all";var __LingXiaBridgeBundle=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t="BRIDGE_TIMEOUT",n="BRIDGE_CANCELED",o="BRIDGE_HANDSHAKE_FAILED",r="BRIDGE_MALFORMED_MESSAGE",i="BRIDGE_METHOD_NOT_FOUND",s="BRIDGE_CAPABILITY_DENIED",a="BRIDGE_INTERNAL_ERROR",l="BRIDGE_OUTBOX_FULL",c="BRIDGE_STREAM_CLOSED";var d=class extends Error{constructor(e,t,n){super(t),this.name="BridgeInvocationError",this.code=e,this.data=n}};function u(e){if(e instanceof d)return e;if(e&&"object"==typeof e){const t=e;let n=a;("string"==typeof t.code&&""!==t.code.trim()||"number"==typeof t.code&&Number.isFinite(t.code))&&(n=t.code);const o="string"==typeof t.message&&""!==t.message.trim()?t.message:"Unknown error";return new d(n,o,"data"in t?t.data:void 0)}const t=e instanceof Error?e.message:"string"==typeof e?e:"Unknown error";return new d(a,t)}function m(e){const t=u(e);return{code:String(t.code||a),message:"string"==typeof t.message&&""!==t.message.trim()?t.message:"Unknown error",...void 0===t.data?{}:{data:t.data}}}function f({os:e,send:t}){if("undefined"==typeof window)return;if("undefined"==typeof document)return;const n="iOS"===e;if(!n&&"Android"!==e)return;const o=Symbol.for("LingXia.NativeComponentCoverageMonitor");if(window[o]?.installed)return;const r={installed:!0,coveredById:new Map,coveredCount:0,anyCovered:!1,scheduled:!1,hasAnyVideo:!1,scrollLocked:!1,scrollY:0,htmlOverflow:"",bodyOverflow:"",bodyPosition:"",bodyTop:"",bodyWidth:""};function i(e){const t=e.getBoundingClientRect?.();if(!t)return!1;if(t.width<2||t.height<2)return!1;const n=t.left+t.width/2,o=t.top+t.height/2;if(n<0||o<0||n>=window.innerWidth||o>=window.innerHeight)return!1;const r=document.elementFromPoint?.(n,o);return!!r&&(r!==document.documentElement&&r!==document.body&&!(r===e||e.contains(r)))}function s(){r.scheduled=!1;const e=document.querySelectorAll("lx-video[id]");if(r.hasAnyVideo=e.length>0,!r.hasAnyVideo&&0===r.coveredById.size&&!r.anyCovered)return;const o=new Set;for(const n of Array.from(e)){const e=n.id;if(!e)continue;o.add(e);const s=i(n),a=r.coveredById.get(e);a!==s&&(!0===a&&(r.coveredCount-=1),!0===s&&(r.coveredCount+=1),r.coveredById.set(e,s),t({id:e,action:"component.coverage",covered:s}))}const s=[];for(const[e,t]of r.coveredById.entries())o.has(e)||(s.push(e),!0===t&&(r.coveredCount-=1));for(const e of s)r.coveredById.delete(e),t({id:e,action:"component.coverage",covered:!1});const a=r.coveredCount>0;a!==r.anyCovered&&(r.anyCovered=a,n&&(a?function(){if(!n)return;if(r.scrollLocked)return;const e=document.documentElement,t=document.body;e&&t&&(r.scrollLocked=!0,r.scrollY=window.scrollY||e.scrollTop||0,r.htmlOverflow=e.style.overflow||"",r.bodyOverflow=t.style.overflow||"",r.bodyPosition=t.style.position||"",r.bodyTop=t.style.top||"",r.bodyWidth=t.style.width||"",e.style.overflow="hidden",t.style.overflow="hidden",t.style.position="fixed",t.style.top=-r.scrollY+"px",t.style.width="100%")}():function(){if(!n)return;if(!r.scrollLocked)return;const e=document.documentElement,t=document.body;e&&t&&(r.scrollLocked=!1,e.style.overflow=r.htmlOverflow,t.style.overflow=r.bodyOverflow,t.style.position=r.bodyPosition,t.style.top=r.bodyTop,t.style.width=r.bodyWidth,window.scrollTo(0,r.scrollY))}()))}function a(){r.scheduled||(r.scheduled=!0,requestAnimationFrame(s))}window[o]=r,new MutationObserver(a).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0});const l={handleEvent:()=>{(r.hasAnyVideo||0!==r.coveredById.size)&&a()}},c={handleEvent:()=>a()};window.addEventListener("scroll",l,{capture:!0,passive:!0}),window.addEventListener("resize",c),a()}const p="undefined"!=typeof window&&window.__LX_BRIDGE_CFG||{};function h(){return p.os||"unknown"}function g(){return"iOS"===p.os}function v(){return"macOS"===p.os}const y="__LingXiaRecvMessage",x=5e3,w="[LX.Bridge]",b="messageport",k="jsinterface",E=p.appleDownstreamURL,I={data:!1,proto:!1,all:!1},C=[];function _(e){return I.all||I[e]}function T(...e){console.log(w,...e)}function L(...e){console.warn(w,...e)}function S(...e){console.error(w,...e)}function M(e){try{return JSON.stringify(e)}catch{return function(e,t){const n=new WeakSet;return JSON.stringify(e,(e,t)=>{if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular]";n.add(t)}return t},t)}(e)}}function N(e){try{return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch{return{}}}const A="iOS"===p.os||"macOS"===p.os?"webkit":"Harmony"===p.os?"messageport":"Android"===p.os?window.LingXiaProxy?.supportsMessagePort?.()?"messageport":"jsinterface":"unknown";"undefined"!=typeof window&&"function"!=typeof window[y]&&(window[y]=e=>{C.push(e)});let B=null,O=!1,j=null,P=null,R=null,F=200;const D={listenerInstalled:!1,promise:null,resolve:null,reject:null,timer:null},X={handleEvent:e=>{const t=e;if("LingXia-port-init"!==t.data)return;const n=t.ports?.[0];n&&(qe._connectWebMessagePort(n),D.resolve?.(n))}};function $(){D.listenerInstalled||(D.listenerInstalled=!0,window.addEventListener("message",X))}function H(){null!==D.timer&&(window.clearTimeout(D.timer),D.timer=null),D.resolve=null,D.reject=null,D.promise=null}function q(){return"webkit"===A&&(g()||v())}function z(){null!==R&&(clearTimeout(R),R=null)}function G(e){for(const t of Array.from(re.keys()))ye(t,{code:c,message:e});for(const t of Array.from(ie.keys()))xe(t,{code:c,message:e});!function(e){for(const[t,n]of Array.from(se.entries()))se.delete(t),n._emitClose(c,e)}(e)}function U(e){let t=e;for(;;){const e=t.indexOf("\n");if(e<0)break;const n=t.slice(0,e).trim();if(t=t.slice(e+1),n)try{Ae(JSON.parse(n))}catch(e){L("Apple downstream parse error:",e,n)}}return t}function W(){q()&&(j||(z(),j=async function(){if(!E)throw new Error("Apple downstream URL is not configured");const e=new AbortController;P=e;const t=await fetch(E,{method:"GET",cache:"no-store",headers:{Accept:"application/x-ndjson"},signal:e.signal});if(!t.ok)throw new Error(`Apple downstream HTTP ${t.status}`);if(!t.body)throw new Error("Apple downstream response body unavailable");O=!0,F=200,_("proto")&&T("Apple downstream connected"),_e();const n=t.body.getReader(),o=new TextDecoder;let r="";try{for(;;){const{value:e,done:t}=await n.read();if(t)break;r+=o.decode(e,{stream:!0}),r=U(r)}r+=o.decode();const e=r.trim();if(e)try{Ae(JSON.parse(e))}catch(t){L("Apple downstream trailing parse error:",t,e)}}catch(t){if(e.signal.aborted)return;throw t}finally{try{n.releaseLock()}catch{}}}().catch(e=>{P?.signal.aborted||L("Apple downstream failed:",e)}).finally(()=>{const e=P?.signal.aborted??!1;j=null,P=null;const t=O;var n,o;O=!1,n="Apple downstream closed",o=t,Ce(),Y=null,V=!1,K=!1,Q=0,o&&G(n),e||function(e){if(!q())return;z();const t=F;F=Math.min(2*F,2e3);const n=`Apple downstream disconnected, retrying in ${t}ms: ${e}`;t<=200?T(n):L(n),R=setTimeout(()=>{R=null,W()},t)}("stream closed")})))}function J(e){const t=e.kind;"req"!==t&&"notify"!==t||T(`postToNative: ${t} ${e.method}`),_("proto")&&console.log("→",JSON.stringify(e,null,2));try{if("webkit"===A)return void window.webkit?.messageHandlers.LingXia?.postMessage(e);const t=M(e);if(A===b&&B)return void B.postMessage(t);if(A===k&&window.LingXiaProxy?.postMessage)return void window.LingXiaProxy.postMessage(t);L("Transport not ready")}catch(e){S("Send error:",e)}}let Y=null,V=!1,K=!1,Q=0,Z=null;const ee={};let te=0;function ne(){return{data:new Set,end:new Set,error:new Set,close:new Set}}function oe(e,t){const n=ne();let o=!1,r=()=>{},i=()=>{};const s=[],a=[],l=new Promise((e,t)=>{r=e,i=t});return{id:e,result:l,on(e,t){return"data"===e&&n.data.add(t),"end"===e&&n.end.add(t),"error"===e&&n.error.add(t),this},[Symbol.asyncIterator]:()=>({next:()=>s.length>0?Promise.resolve({done:!1,value:s.shift()}):o?l.then(e=>({done:!0,value:e}),e=>Promise.reject(e)):new Promise((e,t)=>{a.push({resolve:e,reject:t})})}),cancel(){o||t()},_emitData(e){if(!o){a.length>0?a.shift().resolve({done:!1,value:e}):s.push(e);for(const t of n.data)try{t(e)}catch(e){L("Stream data listener failed:",e)}}},_resolve(e){if(!o){for(o=!0,r(e);a.length>0;)a.shift().resolve({done:!0,value:e});for(const t of n.end)try{t(e)}catch(e){L("Stream end listener failed:",e)}}},_reject(e){if(!o){for(o=!0,i(e);a.length>0;)a.shift().reject(e);for(const t of n.error)try{t(e)}catch(e){L("Stream error listener failed:",e)}}}}}const re=new Map,ie=new Map,se=new Map,ae=[];let le=-1,ce={};const de=new Set,ue=new WeakMap,me=new Map;function fe(e,t){me.set(e,t)}function pe(e){if(e.startsWith("host."))return"host";const t=e.indexOf(".");return t>0?e.slice(0,t):"page"}function he(e){if(null!=e)return e}function ge(){return A===b?!!B:q()?O:"webkit"===A||A===k}function ve(){return ge()&&V}function ye(e,t){const n=re.get(e);if(n){re.delete(e),null!==n.timerId&&clearTimeout(n.timerId);const o=u(t);if("stream"===n.mode&&n.stream)return void n.stream._reject(o);n.reject?.(o)}}function xe(e,t){const n=ie.get(e);if(!n)return;ie.delete(e),null!==n.timerId&&clearTimeout(n.timerId);const o=u(t);n.channel._reject(o),n.reject(o)}function we(e,t){re.has(e)?ye(e,t):ie.has(e)&&xe(e,t)}function be(e){const n=re.get(e);n&&(!Number.isFinite(n.timeoutMs)||n.timeoutMs<=0?null!==n.timerId&&(clearTimeout(n.timerId),n.timerId=null):(null!==n.timerId&&clearTimeout(n.timerId),n.timerId=setTimeout(()=>{re.has(e)&&ye(e,{code:t,message:`'${n.method}' timed out`})},n.timeoutMs)))}function ke(e){re.has(e)?be(e):ie.has(e)&&function(e){const n=ie.get(e);n&&(null!==n.timerId&&clearTimeout(n.timerId),n.timerId=setTimeout(()=>{xe(e,{code:t,message:`Channel '${n.topic}' timed out`})},x))}(e)}function Ee(e){for(let t=ae.length-1;t>=0;t--)if(ae[t]?.reqId===e)return ae.splice(t,1),!0;return!1}function Ie(e,t){const n=e.kind,o="hello"===n||"helloAck"===n||"ready"===n;if(!ve()&&!o)return ae.length>=256?(S("Outbox full"),void(t&&we(t,{code:l,message:"Bridge outbox is full"}))):void ae.push({msg:e,reqId:t});t&&ke(t),J(e)}function Ce(){null!==Z&&(clearTimeout(Z),Z=null)}function _e(){if(V)return;if(!ge())return;Ce();const e={v:2,kind:"hello",nonce:p.nonce||"",role:"view",protocolsSupported:[2]};K=!0,J(e),Z=setTimeout(()=>{if(!V)if(Q++,Q<3)L(`Handshake timeout (${Q}/3), retrying...`),K=!1,_e();else{for(S("Handshake failed"),Ce(),K=!1,Q=0;ae.length;){const e=ae.shift();e?.reqId&&we(e.reqId,{code:o,message:"Bridge handshake failed"})}for(const e of Array.from(ie.keys()))xe(e,{code:o,message:"Bridge handshake failed"})}},1e4)}function Te(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Le(e,t,n=!1){const o=function(e){if(""===e)return[];if(!e.startsWith("/"))throw new Error(`Invalid JSON pointer: ${e}`);return e.split("/").slice(1).map(Te)}(t);if(0===o.length)return{container:{$root:e},key:"$root"};let r=e;for(let e=0;e<o.length-1;e++){const t=o[e];if(Array.isArray(r))r=r[Number(t)];else{if(!r||"object"!=typeof r)throw new Error(`Invalid container at ${t}`);{const i=r;if(n&&void 0===i[t]){const n=o[e+1];i[t]=n&&/^\d+$/.test(n)?[]:{}}r=i[t]}}}return{container:r,key:o[o.length-1]}}function Se(e){de.forEach(t=>{try{if(!ue.has(t))return ue.set(t,!0),void t(N(ce),{rev:le,initial:!0});t(N(ce),{rev:le,initial:e})}catch(e){L("Subscriber error:",e)}})}function Me(e){if("function"!=typeof e)return()=>{};if(de.add(e),le>=0){ue.set(e,!0);try{e(N(ce),{rev:le,initial:!0})}catch(e){S("Callback error:",e)}}return()=>{de.delete(e),ue.delete(e)}}function Ne(e){He.call("state.getSnapshot",{scope:e}).catch(()=>{})}function Ae(e){if(e&&"object"==typeof e){const t=e;if("event"===t.type&&"nativecomponent"===t.name&&t.payload){const e=t.payload,n=e.id||e.componentId;if("string"==typeof n){const t=Be.get(n);if(t)try{t(e)}catch(e){S("NC handler error:",e)}}return}}const t=function(e){if(!e||"object"!=typeof e)return null;const t=e.v,n=e.kind;return 2!==t||"string"!=typeof n?null:e}(e);if(t)switch(t.kind){case"helloAck":return void(Y=t.sessionId);case"ready":if(Y&&t.sessionId!==Y)return void L("sessionId mismatch");if(Ce(),V=!0,Q=0,t.hostMethods)for(const[e,n]of Object.entries(t.hostMethods))ee[e]=n;return _("proto")&&T("Handshake complete, hostMethods:",Object.keys(ee).length),void function(){if(ve())for(;ae.length;){const e=ae.shift();e&&(e.reqId&&ke(e.reqId),J(e.msg))}}();case"res":{const e=re.get(t.id);if(!e)return;if(re.delete(t.id),null!==e.timerId&&clearTimeout(e.timerId),t.ok){if("state.getSnapshot"===e.method&&(function(e){if(!e||"object"!=typeof e)return!1;const t=e;return!("number"!=typeof t.rev||!Number.isFinite(t.rev)||!t.state||"object"!=typeof t.state||(ce=t.state,le=t.rev,_("data")&&(console.group("[LX] snapshot(res)"),console.log("rev:",le,"state:",N(ce)),console.groupEnd()),Se(!0),0))}(t.result)||L("Invalid state.getSnapshot result")),"stream"===e.mode&&e.stream)return void e.stream._resolve(t.result);e.resolve?.(t.result)}else{const n=u(t.error);if("stream"===e.mode&&e.stream)return void e.stream._reject(n);e.reject?.(n)}return}case"event":if(re.has(t.id)){const e=re.get(t.id);return void("stream"===e?.mode&&e.stream?(be(t.id),e.stream._emitData(t.payload)):L(`Received event for non-stream request '${t.id}'`))}return;case"state.snapshot":return ce=t.state||{},le=t.rev,_("data")&&(console.group("[LX] snapshot"),console.log("rev:",le,"state:",N(ce)),console.groupEnd()),void Se(!0);case"state.patch":if(t.baseRev!==le)return L("baseRev mismatch",{have:le,want:t.baseRev}),void Ne(t.scope);try{!function(e,t){for(const n of t){const t="add"===n.op||"replace"===n.op,{container:o,key:r}=Le(e,n.path,t);if("$root"===r){for(const t of Object.keys(e))delete e[t];if("remove"!==n.op){const t=n.value;t&&"object"==typeof t&&Object.assign(e,t)}continue}if(Array.isArray(o)){const e="-"===r?o.length:Number(r);if(!Number.isFinite(e)||e<0)throw new Error("Invalid index");"remove"===n.op?o.splice(e,1):"add"===n.op?o.splice(e,0,n.value):"replace"===n.op&&(o[e]=n.value);continue}if(!o||"object"!=typeof o)throw new Error("Invalid container");const i=o;"remove"===n.op?delete i[r]:i[r]=n.value}}(ce,t.ops||[]),le=t.rev}catch(e){return S("Patch failed:",e),void Ne(t.scope)}return _("data")&&(console.group("[LX] patch"),console.log("rev:",le,"ops:",t.ops),console.groupEnd()),Se(!1),void(t.ack&&Ie({v:2,kind:"state.ack",scope:t.scope,rev:t.rev}));case"ch.ack":{const e=ie.get(t.id);if(!e)return;if(ie.delete(t.id),null!==e.timerId&&clearTimeout(e.timerId),t.ok)e.channel._markOpen(),se.set(t.id,e.channel),e.resolve(e.channel);else{const n=u(t.error);e.channel._reject(n),e.reject(n)}return}case"ch.data":{const e=se.get(t.id);if(!e)return;return void e._emitData(t.payload)}case"ch.close":{const e=ie.get(t.id);if(e)return ie.delete(t.id),void e.channel._emitClose(t.code,t.reason);const n=se.get(t.id);if(!n)return;return se.delete(t.id),void n._emitClose(t.code,t.reason)}case"req":{const e=t,n=pe(e.method);if(!e.cap||e.cap!==n)return void Ie({v:2,kind:"res",id:e.id,ok:!1,error:{code:s,message:`Invalid cap for ${e.method}`}});const o=me.get(e.method);return o?void Promise.resolve().then(()=>o(e.params)).then(t=>{Ie({v:2,kind:"res",id:e.id,ok:!0,result:t})}).catch(t=>{Ie({v:2,kind:"res",id:e.id,ok:!1,error:u(t)})}):void Ie({v:2,kind:"res",id:e.id,ok:!1,error:{code:i,message:`View handler not found: ${e.method}`}})}}else L("Invalid V2 message:",e)}const Be=new Map,Oe=[];let je=!1;function Pe(){return"undefined"!=typeof window&&!(!window.webkit?.messageHandlers?.NativeComponent&&!window.NativeComponentBridge?.postMessage)}function Re(e){try{if(window.webkit?.messageHandlers?.NativeComponent)return void window.webkit.messageHandlers.NativeComponent.postMessage(e);if(window.NativeComponentBridge?.postMessage)return void window.NativeComponentBridge.postMessage(M(e))}catch(e){S("NativeComponent send error:",e)}}function Fe(){if(Pe()&&0!==Oe.length)for(je=!0;Oe.length;){const e=Oe.shift();try{Re(e)}catch{break}}}function De(e){try{if(!Pe())return void Oe.push(e);je||Fe(),Re(e)}catch(e){S("NC send failed:",e)}}function Xe(e){return`${e}_${Date.now()}_${te++}`}function $e(e,t,n){if(!t)return;if(t.aborted)return void n();let o={handleEvent:()=>{t.removeEventListener("abort",o),n()}};t.addEventListener("abort",o)}const He={call:(e,t,o)=>new Promise((i,s)=>{if(!e||"string"!=typeof e)return void s({code:r,message:"Method name must be a non-empty string"});K||_e();const a=Xe("c"),l=o?.cap||pe(e),c=o?.timeoutMs??x;re.set(a,{method:e,mode:"call",resolve:i,reject:e=>s(e),timeoutMs:c,timerId:null}),Ie({v:2,kind:"req",id:a,method:e,params:he(t),cap:l},a),$e(0,o?.signal,()=>{const e=Ee(a);ye(a,{code:n,message:"Bridge request aborted"}),!e&&V&&Ie({v:2,kind:"cancel",id:a})})}),stream(e,t,o){if(!e||"string"!=typeof e){const e=oe("invalid",()=>{});return e._reject({code:r,message:"Method name must be a non-empty string"}),e}K||_e();const i=Xe("c"),s=oe(i,()=>{Ee(i)?ye(i,{code:n,message:"Bridge request aborted"}):V&&Ie({v:2,kind:"cancel",id:i})}),a=o?.cap||pe(e),l=o?.timeoutMs??x;return re.set(i,{method:e,mode:"stream",stream:s,timeoutMs:l,timerId:null}),Ie({v:2,kind:"req",id:i,method:e,params:he(t),cap:a},i),$e(0,o?.signal,()=>s.cancel()),s},notify(e,t,n){e&&"string"==typeof e&&(K||_e(),Ie({v:2,kind:"notify",method:e,params:he(t),cap:n?.cap||pe(e)}))},state:{subscribe:Me},channel:{open:(e,t,n)=>e&&"string"==typeof e?(K||_e(),new Promise((o,r)=>{const i=Xe("ch"),s=function(e,t,n){const o=ne();let r=!1,i=0,s=!1;const a=[],l=[],d={id:e,send(n){r?t(n,i++):d._reject({code:c,message:`Channel '${e}' is closed`})},on(e,t){return"data"===e&&o.data.add(t),"close"===e&&o.close.add(t),"error"===e&&o.error.add(t),this},[Symbol.asyncIterator]:()=>({next:()=>a.length>0?Promise.resolve({done:!1,value:a.shift()}):s?Promise.resolve({done:!0,value:void 0}):new Promise((e,t)=>{l.push({resolve:e,reject:t})})}),close(e,t){r&&(r=!1,s=!0,n(e,t),d._emitClose(e,t))},_emitData(e){if(r){l.length>0?l.shift().resolve({done:!1,value:e}):a.push(e);for(const t of o.data)try{t(e)}catch(e){L("Channel listener failed:",e)}}},_emitClose(e,t){for(s=!0;l.length>0;)l.shift().resolve({done:!0,value:void 0});for(const n of o.close)try{n(e,t)}catch(e){L("Channel close listener failed:",e)}},_reject(e){for(s=!0;l.length>0;)l.shift().reject(e);for(const t of o.error)try{t(e)}catch(e){L("Channel error listener failed:",e)}},_markOpen(){r=!0,s=!1},_isOpen:()=>r,_nextSeq:()=>i++};return d}(i,(e,t)=>{Ie({v:2,kind:"ch.data",id:i,seq:t,payload:e})},(e,t)=>{const n=ie.get(i);n&&null!==n.timerId&&clearTimeout(n.timerId),ie.delete(i),se.delete(i),Ie({v:2,kind:"ch.close",id:i,code:e,reason:t})});ie.set(i,{topic:e,channel:s,resolve:o,reject:r,timerId:null}),Ie({v:2,kind:"ch.open",id:i,topic:e,params:he(t),cap:n?.cap||pe(e)},i)})):Promise.reject({code:r,message:"Topic name must be a non-empty string"})}},qe={invoke:(e,t,n)=>He.call(ze(e),t,Ge(n)).then(e=>e).catch(e=>Promise.reject(m(e))),notify(e,t,n){He.notify(ze(e),t,Ge(n))},stream:(e,t,n)=>Ue(He.stream(ze(e),t,Ge(n))),channel:(e,t,n)=>He.channel.open(ze(e),t,Ge(n)).then(e=>function(e){const t=new Set,n=new Set;return e.on("data",e=>{for(const n of t)n(e)}),e.on("close",(e,t)=>{const o={code:e,reason:t};for(const e of n)e(o)}),{send(t){e.send(t)},onMessage:e=>(t.add(e),()=>{t.delete(e)}),onClose:e=>(n.add(e),()=>{n.delete(e)}),close(t,n){e.close(t,n)}}}(e)).catch(e=>Promise.reject(m(e))),raw:He,state:{subscribe:Me},_connectWebMessagePort(e){if(A===b){if(B&&B!==e)try{B.onmessage=null,B.close()}catch{}B=e,e.onmessage=e=>{let t=e.data;if("string"==typeof t)try{t=JSON.parse(t)}catch{return}Ae(t)};try{e.start()}catch{}T("Port connected"),_e()}},_receiveEvaluateMessage(e){try{e&&Ae(JSON.parse(e))}catch(e){S("Parse error:",e)}},debug:function(e){const t={};return Object.keys(e).forEach(n=>{Object.defineProperty(t,n,{enumerable:!0,configurable:!1,get:()=>e[n],set(t){e[n]=!!t,console.log(`[LX] ${n}: ${t}`)}})}),t}(I),platform:{isHarmony:function(){return"Harmony"===p.os},isIOS:g,isAndroid:function(){return"Android"===p.os},isMacOS:v,isDesktop:function(){return v()},getOS:h},dom:{measureById(e){try{if(!e)return null;const t=document.getElementById(e);if(!t)return null;const n=t.getBoundingClientRect();let o=0;try{o=parseFloat(getComputedStyle(t).borderRadius)||0}catch{}return[n.left+window.scrollX,n.top+window.scrollY,n.width,n.height,o]}catch{return null}}},nativeComponents:{send:De,hasHandler:Pe,flush:Fe,register:(e,t)=>e&&"function"==typeof t?(Be.set(e,t),()=>Be.delete(e)):()=>{},unregister(e){Be.delete(e)}},isReady:()=>V};function ze(e){return e.startsWith("host.")?e:`host.${e}`}function Ge(e){return{...e||{},cap:e?.cap||"host"}}function Ue(e){const t=new Set,n=new Set;return e.on("data",e=>{for(const n of t)n(e)}),e.on("error",e=>{const t=m(e);for(const e of n)e(t)}),{onEvent:e=>(t.add(e),()=>{t.delete(e)}),onError:e=>(n.add(e),()=>{n.delete(e)}),result:e.result.catch(e=>Promise.reject(m(e))),cancel(){e.cancel()}}}function We(){if(window.__LX_BRIDGE_INIT_STATE)T(`Bridge already ${window.__LX_BRIDGE_INIT_STATE}, skipping duplicate init`);else{window.__LX_BRIDGE_INIT_STATE="initializing";try{T(`Method: ${A}`),function(e){if("undefined"==typeof window)return;if(window[y]=e,0===C.length)return;const t=C.splice(0,C.length);for(const n of t)try{e(n)}catch(e){L("Failed to replay queued native message:",e)}}(qe._receiveEvaluateMessage),q()?W():A===b?($(),function(){if(B)return Promise.resolve(B);if(D.promise)return D.promise;$(),D.promise=new Promise((e,t)=>{D.resolve=t=>{H(),e(t)},D.reject=e=>{H(),t(e)},D.timer=window.setTimeout(()=>{D.reject?.(new Error("MessagePort init timed out after 5000ms"))},5e3)});try{window.LingXiaProxy?.getPort("LingXiaPort")}catch(e){D.reject?.(e)}return D.promise}().catch(e=>L("Port init failed:",e))):"webkit"===A||A===k?_e():L("Unknown method"),window.LingXiaBridge=qe,f({os:h(),send:De}),window.__LX_BRIDGE_INIT_STATE="initialized",T("Init complete")}catch(e){throw delete window.__LX_BRIDGE_INIT_STATE,e}}}function Je(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function Ye(e){const{failedPath:t,reason:n}=e,o=document.createElement("style");o.textContent="\n* { margin: 0; padding: 0; box-sizing: border-box; }\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: #f5f5f7;\n color: #1d1d1f;\n padding: 20px;\n -webkit-font-smoothing: antialiased;\n}\n.lx-error {\n text-align: center;\n max-width: 400px;\n}\n.lx-error-code {\n font-size: 120px;\n font-weight: 700;\n color: #d1d1d6;\n line-height: 1;\n letter-spacing: -4px;\n}\n.lx-error-title {\n font-size: 21px;\n font-weight: 600;\n margin: 16px 0 8px;\n color: #1d1d1f;\n}\n.lx-error-desc {\n font-size: 15px;\n color: #86868b;\n line-height: 1.5;\n}\n.lx-error-path {\n display: inline-block;\n margin-top: 20px;\n padding: 10px 16px;\n background: rgba(0,0,0,0.04);\n border-radius: 8px;\n font-family: 'SF Mono', ui-monospace, Menlo, Monaco, monospace;\n font-size: 13px;\n color: #1d1d1f;\n word-break: break-all;\n max-width: 100%;\n}\n@media (prefers-color-scheme: dark) {\n body { background: #000; color: #f5f5f7; }\n .lx-error-code { color: #3a3a3c; }\n .lx-error-title { color: #f5f5f7; }\n .lx-error-desc { color: #86868b; }\n .lx-error-path { background: rgba(255,255,255,0.08); color: #f5f5f7; }\n}\n",document.head.appendChild(o),document.body.innerHTML="",document.body.style.cssText="";const r=document.createElement("div");r.className="lx-error";let i='<div class="lx-error-code">404</div>';i+='<h1 class="lx-error-title">Page Not Found</h1>',i+="<p class=\"lx-error-desc\">The page you're looking for doesn't exist.</p>",t&&(i+=`<div class="lx-error-path">${Je(t)}</div>`),n&&(i+=`<p class="lx-error-desc" style="margin-top:12px">${Je(n)}</p>`),r.innerHTML=i,document.body.appendChild(r)}function Ve(){const e=window.__LX_RUNTIME_CONFIG;return!(!e||!e.error)}function Ke(){return window.__LX_RUNTIME_CONFIG?.error||null}const Qe={handleEvent:()=>Ze()};function Ze(){if(Ve()){const e=Ke();e&&Ye(e)}}function et(){We(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Qe):Ze()}const tt="lx-action-sheet-style";let nt=null;function ot(e){const t=e,n=t?.itemList??[],o=t?.cancelText??"Cancel",r=t?.itemColor??"#007AFF",i=(nt??Promise.resolve()).then(()=>rt(n,o,r),()=>rt(n,o,r));return nt=i,i}function rt(e,t,n){return new Promise(o=>{let r=!1;const i="macOS"===h();!function(){if(document.getElementById(tt))return;const e=document.createElement("style");e.id=tt,e.textContent="\n.lx-as-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity 300ms ease;\n}\n.lx-as-backdrop.lx-as-visible { opacity: 1; }\n\n.lx-as-sheet {\n position: fixed; left: 0; right: 0; bottom: 0; z-index: 100000;\n transform: translateY(100%);\n transition: transform 300ms ease;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n}\n.lx-as-sheet.lx-as-visible { transform: translateY(0); }\n.lx-as-sheet.lx-as-desktop {\n left: 50%;\n right: auto;\n bottom: auto;\n top: 50%;\n width: min(92vw, 460px);\n transform: translate(-50%, calc(-50% + 16px));\n}\n.lx-as-sheet.lx-as-desktop.lx-as-visible { transform: translate(-50%, -50%); }\n\n.lx-as-container {\n background: #fff;\n border-radius: 16px 16px 0 0;\n overflow: hidden;\n}\n.lx-as-container.lx-as-desktop {\n border-radius: 16px;\n}\n\n.lx-as-item {\n display: block; width: 100%;\n height: 56px;\n line-height: 56px;\n padding: 0;\n border: none; background: none;\n font-size: 18px; font-weight: 400;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n position: relative;\n}\n.lx-as-item:active { background: rgba(0,0,0,0.08); }\n.lx-as-item + .lx-as-item::before {\n content: ''; position: absolute; top: 0; left: 0; right: 0;\n height: 1px; background: #E0E0E0;\n}\n.lx-as-separator {\n height: 8px;\n background: #F2F2F2;\n}\n.lx-as-cancel-btn { font-weight: 500; color: #000; }\n",document.head.appendChild(e)}();const s=document.createElement("div");s.className="lx-as-backdrop";const a=document.createElement("div");a.className="lx-as-sheet",i&&a.classList.add("lx-as-desktop");const l=document.createElement("div");l.className="lx-as-container",i&&l.classList.add("lx-as-desktop"),e.forEach((e,t)=>{const o=document.createElement("button");o.className="lx-as-item",o.textContent=e,o.style.color=n,o.addEventListener("click",()=>u(t)),l.appendChild(o)});const c=document.createElement("div");c.className="lx-as-separator",l.appendChild(c);const d=document.createElement("button");function u(e){r||(r=!0,s.classList.remove("lx-as-visible"),a.classList.remove("lx-as-visible"),setTimeout(()=>{s.remove(),a.remove(),o({tapIndex:e})},300))}d.className="lx-as-item lx-as-cancel-btn",d.textContent=t,d.addEventListener("click",()=>u(-1)),l.appendChild(d),a.appendChild(l),document.body.appendChild(s),document.body.appendChild(a),requestAnimationFrame(()=>{s.classList.add("lx-as-visible"),a.classList.add("lx-as-visible")}),s.addEventListener("click",()=>u(-1))})}const it=200,st="lx-modal-style";let at=null;function lt(e){const t=e,n=t?.title??"",o=t?.content??"",r=t?.showCancel??!0,i=t?.cancelText??"Cancel",s=t?.cancelColor,a=t?.confirmText??"OK",l=t?.confirmColor??"#007AFF",c=(at??Promise.resolve()).then(()=>ct(n,o,r,i,s,a,l),()=>ct(n,o,r,i,s,a,l));return at=c,c}function ct(e,t,n,o,r,i,s){return new Promise(a=>{let l=!1;!function(){if(document.getElementById(st))return;const e=document.createElement("style");e.id=st,e.textContent="\n.lx-modal-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity 200ms ease;\n display: flex; align-items: center; justify-content: center;\n}\n.lx-modal-backdrop.lx-modal-visible { opacity: 1; }\n\n.lx-modal-dialog {\n width: min(92vw, 320px);\n background: #fff;\n border-radius: 14px;\n overflow: hidden;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n transform: scale(0.95); opacity: 0;\n transition: transform 200ms ease, opacity 200ms ease;\n}\n.lx-modal-backdrop.lx-modal-visible .lx-modal-dialog {\n transform: scale(1); opacity: 1;\n}\n\n.lx-modal-body {\n padding: 24px 20px 16px;\n text-align: center;\n}\n.lx-modal-title {\n margin: 0 0 8px;\n font-size: 17px;\n font-weight: 600;\n color: #000;\n line-height: 1.35;\n}\n.lx-modal-content {\n margin: 0;\n font-size: 14px;\n color: #666;\n line-height: 1.5;\n word-break: break-word;\n}\n.lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n font-size: 17px;\n font-weight: 600;\n color: #000;\n}\n\n.lx-modal-footer {\n display: flex;\n border-top: 1px solid #E0E0E0;\n}\n.lx-modal-btn {\n flex: 1;\n height: 44px;\n line-height: 44px;\n padding: 0;\n border: none;\n background: none;\n font-size: 17px;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n.lx-modal-btn:active { background: rgba(0,0,0,0.06); }\n.lx-modal-btn + .lx-modal-btn {\n border-left: 1px solid #E0E0E0;\n}\n.lx-modal-btn-cancel {\n color: #666;\n font-weight: 400;\n}\n.lx-modal-btn-confirm {\n font-weight: 600;\n}\n\n@media (prefers-color-scheme: dark) {\n .lx-modal-dialog { background: #2c2c2e; }\n .lx-modal-title { color: #f5f5f7; }\n .lx-modal-content { color: #ababab; }\n .lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n color: #f5f5f7;\n }\n .lx-modal-footer { border-top-color: #3a3a3c; }\n .lx-modal-btn:active { background: rgba(255,255,255,0.08); }\n .lx-modal-btn + .lx-modal-btn { border-left-color: #3a3a3c; }\n .lx-modal-btn-cancel { color: #ababab; }\n}\n",document.head.appendChild(e)}();const c=document.createElement("div");c.className="lx-modal-backdrop";const d=document.createElement("div");d.className="lx-modal-dialog";const u=document.createElement("div");u.className="lx-modal-body";const m=document.createElement("div");if(m.className="lx-modal-title",m.textContent=e,u.appendChild(m),t){const e=document.createElement("p");e.className="lx-modal-content",e.textContent=t,u.appendChild(e)}d.appendChild(u);const f=document.createElement("div");if(f.className="lx-modal-footer",n){const e=document.createElement("button");e.className="lx-modal-btn lx-modal-btn-cancel",e.textContent=o,r&&(e.style.color=r),e.addEventListener("click",()=>h(!1)),f.appendChild(e)}const p=document.createElement("button");function h(e){l||(l=!0,c.classList.remove("lx-modal-visible"),setTimeout(()=>{c.remove(),a({confirm:e,cancel:!e})},it))}p.className="lx-modal-btn lx-modal-btn-confirm",p.textContent=i,p.style.color=s,p.addEventListener("click",()=>h(!0)),f.appendChild(p),d.appendChild(f),c.appendChild(d),document.body.appendChild(c),requestAnimationFrame(()=>{c.classList.add("lx-modal-visible")})})}const dt="lx-toast-style";let ut=null;function mt(e){const t=e,n=t?.title??"",o=t?.icon??"none",r=t?.duration??1500,i=t?.mask??!1,s=t?.position??"center";ut&&(ut.dismiss(),ut=null),function(){if(document.getElementById(dt))return;const e=document.createElement("style");e.id=dt,e.textContent="\n.lx-toast-mask {\n position: fixed; inset: 0; z-index: 99998;\n}\n.lx-toast-container {\n position: fixed; left: 0; right: 0; z-index: 99999;\n display: flex; justify-content: center;\n pointer-events: none;\n}\n.lx-toast-container.lx-toast-top { top: 0; padding-top: 80px; }\n.lx-toast-container.lx-toast-center { top: 0; bottom: 0; align-items: center; }\n.lx-toast-container.lx-toast-bottom { bottom: 0; padding-bottom: 80px; }\n\n.lx-toast-box {\n display: flex; flex-direction: column; align-items: center; gap: 10px;\n min-width: 120px; max-width: 280px;\n padding: 20px;\n background: rgba(0,0,0,0.8);\n border-radius: 12px;\n color: #fff;\n pointer-events: auto;\n transform: scale(0.8); opacity: 0;\n transition: transform 200ms ease, opacity 200ms ease;\n}\n.lx-toast-box.lx-toast-no-icon {\n min-width: auto; min-height: auto;\n padding: 12px 20px;\n}\n.lx-toast-box.lx-toast-visible {\n transform: scale(1); opacity: 1;\n}\n.lx-toast-icon {\n width: 36px; height: 36px;\n color: #fff;\n line-height: 0;\n}\n.lx-toast-title {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n font-size: 16px; font-weight: 500;\n text-align: center;\n line-height: 1.4;\n word-break: break-word;\n -webkit-font-smoothing: antialiased;\n}\n",document.head.appendChild(e)}();let a=null;i&&(a=document.createElement("div"),a.className="lx-toast-mask",document.body.appendChild(a));const l=document.createElement("div");l.className="lx-toast-container","top"===s?l.classList.add("lx-toast-top"):"bottom"===s?l.classList.add("lx-toast-bottom"):l.classList.add("lx-toast-center");const c=document.createElement("div");c.className="lx-toast-box";const d="none"!==o;if(d||c.classList.add("lx-toast-no-icon"),d){const e=document.createElement("div");e.className="lx-toast-icon","success"===o?e.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M11 18l5 5 9-9" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>':"error"===o?e.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M13 13l10 10M23 13l-10 10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>':"loading"===o&&(e.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 4a14 14 0 0 1 14 14" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.8s" repeatCount="indefinite"/></path></svg>'),c.appendChild(e)}const u=document.createElement("div");u.className="lx-toast-title",u.textContent=n,c.appendChild(u),l.appendChild(c),document.body.appendChild(l),requestAnimationFrame(()=>{c.classList.add("lx-toast-visible")});let m=!1;function f(){m||(m=!0,ut?.dismiss===f&&(ut=null),c.classList.remove("lx-toast-visible"),p&&clearTimeout(p),setTimeout(()=>{l.remove(),a?.remove()},200))}let p=null;return r>0&&(p=setTimeout(f,r)),ut={dismiss:f,timer:p},Promise.resolve()}function ft(){return ut&&(ut.dismiss(),ut=null),Promise.resolve()}return fe("ui.showActionSheet",ot),fe("ui.showModal",lt),fe("ui.showToast",mt),fe("ui.hideToast",ft),et(),e.LingXiaBridge=qe,e.boot=function(){We(),Ze()},e.bootWhenReady=et,e.channel=function(e,t,n){return qe.channel(e,t,n)},e.getErrorInfo=Ke,e.hasError=Ve,e.initBridge=We,e.invoke=function(e,t,n){return qe.invoke(e,t,n)},e.isNativeError=function(e,t){if(!e||"object"!=typeof e)return!1;const n=e;return"string"==typeof n.code&&""!==n.code.trim()&&("string"==typeof n.message&&(void 0===t||n.code===t))},e.notify=function(e,t,n){He.notify(ze(e),t,Ge(n))},e.renderErrorUI=Ye,e.stream=function(e,t,n){return Ue(He.stream(ze(e),t,Ge(n)))},e}({});
@@ -1 +1 @@
1
- var __extends=this&&this.__extends||function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])},e(n,t)};return function(n,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},__assign.apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,n,t,o){return new(t||(t=Promise))(function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t(function(e){e(n)})).then(a,l)}s((o=o.apply(e,n||[])).next())})},__generator=this&&this.__generator||function(e,n){var t,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(t=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){i.label=l[1];break}if(6===l[0]&&i.label<r[1]){i.label=r[1],r=l;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(l);break}r[2]&&i.ops.pop(),i.trys.pop();continue}l=n.call(e,i)}catch(e){l=[6,e],o=0}finally{t=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},__spreadArray=this&&this.__spreadArray||function(e,n,t){if(t||2===arguments.length)for(var o,r=0,i=n.length;r<i;r++)!o&&r in n||(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))},__LX_RUNTIME_PLATFORM__="mobile",__LingXiaBridgeBundle=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var n="BRIDGE_TIMEOUT",t="BRIDGE_CANCELED",o="BRIDGE_HANDSHAKE_FAILED",r="BRIDGE_MALFORMED_MESSAGE",i="BRIDGE_METHOD_NOT_FOUND",a="BRIDGE_CAPABILITY_DENIED",l="BRIDGE_INTERNAL_ERROR",s="BRIDGE_OUTBOX_FULL",c="BRIDGE_STREAM_CLOSED",d=function(e){function n(n,t,o){var r=e.call(this,t)||this;return r.name="BridgeInvocationError",r.code=n,r.data=o,r}return __extends(n,e),n}(Error);function u(e){if(e instanceof d)return e;if(e&&"object"==typeof e){var n=e,t=l;("string"==typeof n.code&&""!==n.code.trim()||"number"==typeof n.code&&Number.isFinite(n.code))&&(t=n.code);var o="string"==typeof n.message&&""!==n.message.trim()?n.message:"Unknown error";return new d(t,o,"data"in n?n.data:void 0)}var r=e instanceof Error?e.message:"string"==typeof e?e:"Unknown error";return new d(l,r)}function f(e){var n=u(e);return __assign({code:String(n.code||l),message:"string"==typeof n.message&&""!==n.message.trim()?n.message:"Unknown error"},void 0===n.data?{}:{data:n.data})}function m(e){var n,t=e.os,o=e.send;if("undefined"!=typeof window&&"undefined"!=typeof document){var r="iOS"===t;if(r||"Android"===t){var i=Symbol.for("LingXia.NativeComponentCoverageMonitor");if(!(null===(n=window[i])||void 0===n?void 0:n.installed)){var a={installed:!0,coveredById:new Map,coveredCount:0,anyCovered:!1,scheduled:!1,hasAnyVideo:!1,scrollLocked:!1,scrollY:0,htmlOverflow:"",bodyOverflow:"",bodyPosition:"",bodyTop:"",bodyWidth:""};window[i]=a,new MutationObserver(u).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0});var l={handleEvent:function(){(a.hasAnyVideo||0!==a.coveredById.size)&&u()}},s={handleEvent:function(){return u()}};window.addEventListener("scroll",l,{capture:!0,passive:!0}),window.addEventListener("resize",s),u()}}}function c(e){var n,t,o=null===(n=e.getBoundingClientRect)||void 0===n?void 0:n.call(e);if(!o)return!1;if(o.width<2||o.height<2)return!1;var r=o.left+o.width/2,i=o.top+o.height/2;if(r<0||i<0||r>=window.innerWidth||i>=window.innerHeight)return!1;var a=null===(t=document.elementFromPoint)||void 0===t?void 0:t.call(document,r,i);return!!a&&(a!==document.documentElement&&a!==document.body&&!(a===e||e.contains(a)))}function d(){a.scheduled=!1;var e=document.querySelectorAll("lx-video[id]");if(a.hasAnyVideo=e.length>0,a.hasAnyVideo||0!==a.coveredById.size||a.anyCovered){for(var n=new Set,t=0,i=Array.from(e);t<i.length;t++){var l=i[t];if(p=l.id){n.add(p);var s=c(l),d=a.coveredById.get(p);d!==s&&(!0===d&&(a.coveredCount-=1),!0===s&&(a.coveredCount+=1),a.coveredById.set(p,s),o({id:p,action:"component.coverage",covered:s}))}}for(var u=[],f=0,m=a.coveredById.entries();f<m.length;f++){var v=m[f],p=v[0];s=v[1];n.has(p)||(u.push(p),!0===s&&(a.coveredCount-=1))}for(var h=0,g=u;h<g.length;h++){p=g[h];a.coveredById.delete(p),o({id:p,action:"component.coverage",covered:!1})}var y=a.coveredCount>0;y!==a.anyCovered&&(a.anyCovered=y,r&&(y?function(){if(r&&!a.scrollLocked){var e=document.documentElement,n=document.body;e&&n&&(a.scrollLocked=!0,a.scrollY=window.scrollY||e.scrollTop||0,a.htmlOverflow=e.style.overflow||"",a.bodyOverflow=n.style.overflow||"",a.bodyPosition=n.style.position||"",a.bodyTop=n.style.top||"",a.bodyWidth=n.style.width||"",e.style.overflow="hidden",n.style.overflow="hidden",n.style.position="fixed",n.style.top="".concat(-a.scrollY,"px"),n.style.width="100%")}}():function(){if(r&&a.scrollLocked){var e=document.documentElement,n=document.body;e&&n&&(a.scrollLocked=!1,e.style.overflow=a.htmlOverflow,n.style.overflow=a.bodyOverflow,n.style.position=a.bodyPosition,n.style.top=a.bodyTop,n.style.width=a.bodyWidth,window.scrollTo(0,a.scrollY))}}()))}}function u(){a.scheduled||(a.scheduled=!0,requestAnimationFrame(d))}}var v="undefined"!=typeof window&&window.__LX_BRIDGE_CFG||{};function p(){return v.os||"unknown"}function h(){return"iOS"===v.os}function g(){return"macOS"===v.os}var y="__LingXiaRecvMessage",x=5e3,w="[LX.Bridge]",b="messageport",_="jsinterface",k={data:!1,proto:!1,all:!1},E=[];function I(e){return k.all||k[e]}function C(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.log.apply(console,__spreadArray([w],e,!1))}function T(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.warn.apply(console,__spreadArray([w],e,!1))}function L(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.error.apply(console,__spreadArray([w],e,!1))}function S(e){try{return JSON.stringify(e)}catch(n){return function(e,n){var t=new WeakSet;return JSON.stringify(e,function(e,n){if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n},n)}(e)}}function M(e){try{return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch(e){return{}}}var N,A,O="iOS"===v.os||"macOS"===v.os?"webkit":"Harmony"===v.os?"messageport":"Android"===v.os?(null===(A=null===(N=window.LingXiaProxy)||void 0===N?void 0:N.supportsMessagePort)||void 0===A?void 0:A.call(N))?"messageport":"jsinterface":"unknown";"undefined"!=typeof window&&"function"!=typeof window[y]&&(window[y]=function(e){E.push(e)});var j=null,P=!1,B=null,R=null,F=null,D=200,X={listenerInstalled:!1,promise:null,resolve:null,reject:null,timer:null},H={handleEvent:function(e){var n,t,o=e;if("LingXia-port-init"===o.data){var r=null===(n=o.ports)||void 0===n?void 0:n[0];r&&(Ge._connectWebMessagePort(r),null===(t=X.resolve)||void 0===t||t.call(X,r))}}};function q(){X.listenerInstalled||(X.listenerInstalled=!0,window.addEventListener("message",H))}function z(){null!==X.timer&&(window.clearTimeout(X.timer),X.timer=null),X.resolve=null,X.reject=null,X.promise=null}function G(){return"webkit"===O&&(h()||g())}function U(){null!==F&&(clearTimeout(F),F=null)}function W(e){for(var n=0,t=Array.from(ie.keys());n<t.length;n++){xe(t[n],{code:c,message:e})}for(var o=0,r=Array.from(ae.keys());o<r.length;o++){we(r[o],{code:c,message:e})}!function(e){for(var n=0,t=Array.from(le.entries());n<t.length;n++){var o=t[n],r=o[0],i=o[1];le.delete(r),i._emitClose(c,e)}}(e)}function J(){return __awaiter(this,void 0,void 0,function(){var e,n,t,o,r,i,a,l,s;return __generator(this,function(c){switch(c.label){case 0:e=new AbortController,R=e,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,fetch("lx-apple://bridge/downstream",{method:"GET",cache:"no-store",headers:{Accept:"application/x-ndjson"},signal:e.signal})];case 2:return n=c.sent(),[3,4];case 3:if(t=c.sent(),e.signal.aborted)return[2];throw t;case 4:if(!n.ok)throw new Error("Apple downstream HTTP ".concat(n.status));if(!n.body)throw new Error("Apple downstream response body unavailable");P=!0,D=200,I("proto")&&C("Apple downstream connected"),Te(),o=n.body.getReader(),r=new TextDecoder,i="",c.label=5;case 5:c.trys.push([5,,9,10]),c.label=6;case 6:return[4,o.read()];case 7:return a=c.sent(),l=a.value,a.done?[3,8]:(i=function(e){for(var n=e;;){var t=n.indexOf("\n");if(t<0)break;var o=n.slice(0,t).trim();if(n=n.slice(t+1),o)try{Oe(JSON.parse(o))}catch(e){T("Apple downstream parse error:",e,o)}}return n}(i+=r.decode(l,{stream:!0})),[3,6]);case 8:if(i+=r.decode(),s=i.trim())try{Oe(JSON.parse(s))}catch(e){T("Apple downstream trailing parse error:",e,s)}return[3,10];case 9:try{o.releaseLock()}catch(e){}return[7];case 10:return[2]}})})}function Y(){G()&&(B||(U(),B=J().catch(function(e){(null==R?void 0:R.signal.aborted)||T("Apple downstream failed:",e)}).finally(function(){var e,n=null!==(e=null==R?void 0:R.signal.aborted)&&void 0!==e&&e;B=null,R=null;var t,o,r=P;P=!1,t="Apple downstream closed",o=r,Ce(),$=null,K=!1,Q=!1,Z=0,o&&W(t),n||function(e){if(G()){U();var n=D;D=Math.min(2*D,2e3);var t="Apple downstream disconnected, retrying in ".concat(n,"ms: ").concat(e);n<=200?C(t):T(t),F=setTimeout(function(){F=null,Y()},n)}}("stream closed")})))}function V(e){var n,t,o,r=e.kind;"req"!==r&&"notify"!==r||C("postToNative: ".concat(r," ").concat(e.method)),I("proto")&&console.log("→",JSON.stringify(e,null,2));try{if("webkit"===O)return void(null===(t=null===(n=window.webkit)||void 0===n?void 0:n.messageHandlers.LingXia)||void 0===t||t.postMessage(e));var i=S(e);if(O===b&&j)return void j.postMessage(i);if(O===_&&(null===(o=window.LingXiaProxy)||void 0===o?void 0:o.postMessage))return void window.LingXiaProxy.postMessage(i);T("Transport not ready")}catch(e){L("Send error:",e)}}var $=null,K=!1,Q=!1,Z=0,ee=null,ne={},te=0;function oe(){return{data:new Set,end:new Set,error:new Set,close:new Set}}function re(e,n){var t,o=oe(),r=!1,i=function(){},a=function(){},l=[],s=[],c=new Promise(function(e,n){i=e,a=n});return(t={id:e,result:c,on:function(e,n){return"data"===e&&o.data.add(n),"end"===e&&o.end.add(n),"error"===e&&o.error.add(n),this}})[Symbol.asyncIterator]=function(){return{next:function(){return l.length>0?Promise.resolve({done:!1,value:l.shift()}):r?c.then(function(e){return{done:!0,value:e}},function(e){return Promise.reject(e)}):new Promise(function(e,n){s.push({resolve:e,reject:n})})}}},t.cancel=function(){r||n()},t._emitData=function(e){if(!r){s.length>0?s.shift().resolve({done:!1,value:e}):l.push(e);for(var n=0,t=o.data;n<t.length;n++){var i=t[n];try{i(e)}catch(e){T("Stream data listener failed:",e)}}}},t._resolve=function(e){if(!r){for(r=!0,i(e);s.length>0;)s.shift().resolve({done:!0,value:e});for(var n=0,t=o.end;n<t.length;n++){var a=t[n];try{a(e)}catch(e){T("Stream end listener failed:",e)}}}},t._reject=function(e){if(!r){for(r=!0,a(e);s.length>0;)s.shift().reject(e);for(var n=0,t=o.error;n<t.length;n++){var i=t[n];try{i(e)}catch(e){T("Stream error listener failed:",e)}}}},t}var ie=new Map,ae=new Map,le=new Map,se=[],ce=-1,de={},ue=new Set,fe=new WeakMap,me=new Map;function ve(e,n){me.set(e,n)}function pe(e){if(e.startsWith("host."))return"host";var n=e.indexOf(".");return n>0?e.slice(0,n):"page"}function he(e){if(null!=e)return e}function ge(){return O===b?!!j:G()?P:"webkit"===O||O===_}function ye(){return ge()&&K}function xe(e,n){var t,o=ie.get(e);if(o){ie.delete(e),null!==o.timerId&&clearTimeout(o.timerId);var r=u(n);if("stream"===o.mode&&o.stream)return void o.stream._reject(r);null===(t=o.reject)||void 0===t||t.call(o,r)}}function we(e,n){var t=ae.get(e);if(t){ae.delete(e),null!==t.timerId&&clearTimeout(t.timerId);var o=u(n);t.channel._reject(o),t.reject(o)}}function be(e,n){ie.has(e)?xe(e,n):ae.has(e)&&we(e,n)}function _e(e){var t=ie.get(e);t&&(!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0?null!==t.timerId&&(clearTimeout(t.timerId),t.timerId=null):(null!==t.timerId&&clearTimeout(t.timerId),t.timerId=setTimeout(function(){ie.has(e)&&xe(e,{code:n,message:"'".concat(t.method,"' timed out")})},t.timeoutMs)))}function ke(e){ie.has(e)?_e(e):ae.has(e)&&function(e){var t=ae.get(e);t&&(null!==t.timerId&&clearTimeout(t.timerId),t.timerId=setTimeout(function(){we(e,{code:n,message:"Channel '".concat(t.topic,"' timed out")})},x))}(e)}function Ee(e){for(var n,t=se.length-1;t>=0;t--)if((null===(n=se[t])||void 0===n?void 0:n.reqId)===e)return se.splice(t,1),!0;return!1}function Ie(e,n){var t=e.kind,o="hello"===t||"helloAck"===t||"ready"===t;if(!ye()&&!o)return se.length>=256?(L("Outbox full"),void(n&&be(n,{code:s,message:"Bridge outbox is full"}))):void se.push({msg:e,reqId:n});n&&ke(n),V(e)}function Ce(){null!==ee&&(clearTimeout(ee),ee=null)}function Te(){if(!K&&ge()){Ce();var e={v:2,kind:"hello",nonce:v.nonce||"",role:"view",protocolsSupported:[2]};Q=!0,V(e),ee=setTimeout(function(){if(!K)if(++Z<3)T("Handshake timeout (".concat(Z,"/").concat(3,"), retrying...")),Q=!1,Te();else{for(L("Handshake failed"),Ce(),Q=!1,Z=0;se.length;){var e=se.shift();(null==e?void 0:e.reqId)&&be(e.reqId,{code:o,message:"Bridge handshake failed"})}for(var n=0,t=Array.from(ae.keys());n<t.length;n++){we(t[n],{code:o,message:"Bridge handshake failed"})}}},1e4)}}function Le(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Se(e,n,t){void 0===t&&(t=!1);var o=function(e){if(""===e)return[];if(!e.startsWith("/"))throw new Error("Invalid JSON pointer: ".concat(e));return e.split("/").slice(1).map(Le)}(n);if(0===o.length)return{container:{$root:e},key:"$root"};for(var r=e,i=0;i<o.length-1;i++){var a=o[i];if(Array.isArray(r))r=r[Number(a)];else{if(!r||"object"!=typeof r)throw new Error("Invalid container at ".concat(a));var l=r;if(t&&void 0===l[a]){var s=o[i+1];l[a]=s&&/^\d+$/.test(s)?[]:{}}r=l[a]}}return{container:r,key:o[o.length-1]}}function Me(e){ue.forEach(function(n){try{if(!fe.has(n))return fe.set(n,!0),void n(M(de),{rev:ce,initial:!0});n(M(de),{rev:ce,initial:e})}catch(e){T("Subscriber error:",e)}})}function Ne(e){if("function"!=typeof e)return function(){};if(ue.add(e),ce>=0){fe.set(e,!0);try{e(M(de),{rev:ce,initial:!0})}catch(e){L("Callback error:",e)}}return function(){ue.delete(e),fe.delete(e)}}function Ae(e){ze.call("state.getSnapshot",{scope:e}).catch(function(){})}function Oe(e){var n,t;if(e&&"object"==typeof e){var o=e;if("event"===o.type&&"nativecomponent"===o.name&&o.payload){var r=o.payload,l=r.id||r.componentId;if("string"==typeof l){var s=je.get(l);if(s)try{s(r)}catch(e){L("NC handler error:",e)}}return}}var c=function(e){if(!e||"object"!=typeof e)return null;var n=e.v,t=e.kind;return 2!==n||"string"!=typeof t?null:e}(e);if(c)switch(c.kind){case"helloAck":return void($=c.sessionId);case"ready":if($&&c.sessionId!==$)return void T("sessionId mismatch");if(Ce(),K=!0,Z=0,c.hostMethods)for(var d=0,f=Object.entries(c.hostMethods);d<f.length;d++){var m=f[d],v=m[0],p=m[1];ne[v]=p}return I("proto")&&C("Handshake complete, hostMethods:",Object.keys(ne).length),void function(){if(ye())for(;se.length;){var e=se.shift();e&&(e.reqId&&ke(e.reqId),V(e.msg))}}();case"res":var h=ie.get(c.id);if(!h)return;if(ie.delete(c.id),null!==h.timerId&&clearTimeout(h.timerId),c.ok){if("state.getSnapshot"===h.method&&(function(e){if(!e||"object"!=typeof e)return!1;var n=e;return!("number"!=typeof n.rev||!Number.isFinite(n.rev)||!n.state||"object"!=typeof n.state||(de=n.state,ce=n.rev,I("data")&&(console.group("[LX] snapshot(res)"),console.log("rev:",ce,"state:",M(de)),console.groupEnd()),Me(!0),0))}(c.result)||T("Invalid state.getSnapshot result")),"stream"===h.mode&&h.stream)return void h.stream._resolve(c.result);null===(n=h.resolve)||void 0===n||n.call(h,c.result)}else{var g=u(c.error);if("stream"===h.mode&&h.stream)return void h.stream._reject(g);null===(t=h.reject)||void 0===t||t.call(h,g)}return;case"event":if(ie.has(c.id)){var y=ie.get(c.id);return void("stream"===(null==y?void 0:y.mode)&&y.stream?(_e(c.id),y.stream._emitData(c.payload)):T("Received event for non-stream request '".concat(c.id,"'")))}return;case"state.snapshot":return de=c.state||{},ce=c.rev,I("data")&&(console.group("[LX] snapshot"),console.log("rev:",ce,"state:",M(de)),console.groupEnd()),void Me(!0);case"state.patch":if(c.baseRev!==ce)return T("baseRev mismatch",{have:ce,want:c.baseRev}),void Ae(c.scope);try{!function(e,n){for(var t=0,o=n;t<o.length;t++){var r=o[t],i="add"===r.op||"replace"===r.op,a=Se(e,r.path,i),l=a.container,s=a.key;if("$root"!==s)if(Array.isArray(l)){var c="-"===s?l.length:Number(s);if(!Number.isFinite(c)||c<0)throw new Error("Invalid index");"remove"===r.op?l.splice(c,1):"add"===r.op?l.splice(c,0,r.value):"replace"===r.op&&(l[c]=r.value)}else{if(!l||"object"!=typeof l)throw new Error("Invalid container");var d=l;"remove"===r.op?delete d[s]:d[s]=r.value}else{for(var u=0,f=Object.keys(e);u<f.length;u++)delete e[f[u]];if("remove"!==r.op){var m=r.value;m&&"object"==typeof m&&Object.assign(e,m)}}}}(de,c.ops||[]),ce=c.rev}catch(e){return L("Patch failed:",e),void Ae(c.scope)}return I("data")&&(console.group("[LX] patch"),console.log("rev:",ce,"ops:",c.ops),console.groupEnd()),Me(!1),void(c.ack&&Ie({v:2,kind:"state.ack",scope:c.scope,rev:c.rev}));case"ch.ack":if(!(w=ae.get(c.id)))return;if(ae.delete(c.id),null!==w.timerId&&clearTimeout(w.timerId),c.ok)w.channel._markOpen(),le.set(c.id,w.channel),w.resolve(w.channel);else{g=u(c.error);w.channel._reject(g),w.reject(g)}return;case"ch.data":var x=le.get(c.id);if(!x)return;return void x._emitData(c.payload);case"ch.close":var w;if(w=ae.get(c.id))return ae.delete(c.id),void w.channel._emitClose(c.code,c.reason);var b=le.get(c.id);if(!b)return;return le.delete(c.id),void b._emitClose(c.code,c.reason);case"req":var _=c,k=pe(_.method);if(!_.cap||_.cap!==k)return void Ie({v:2,kind:"res",id:_.id,ok:!1,error:{code:a,message:"Invalid cap for ".concat(_.method)}});var E=me.get(_.method);return E?void Promise.resolve().then(function(){return E(_.params)}).then(function(e){Ie({v:2,kind:"res",id:_.id,ok:!0,result:e})}).catch(function(e){Ie({v:2,kind:"res",id:_.id,ok:!1,error:u(e)})}):void Ie({v:2,kind:"res",id:_.id,ok:!1,error:{code:i,message:"View handler not found: ".concat(_.method)}})}else T("Invalid V2 message:",e)}var je=new Map,Pe=[],Be=!1;function Re(){var e,n,t;return"undefined"!=typeof window&&!(!(null===(n=null===(e=window.webkit)||void 0===e?void 0:e.messageHandlers)||void 0===n?void 0:n.NativeComponent)&&!(null===(t=window.NativeComponentBridge)||void 0===t?void 0:t.postMessage))}function Fe(e){var n,t,o;try{if(null===(t=null===(n=window.webkit)||void 0===n?void 0:n.messageHandlers)||void 0===t?void 0:t.NativeComponent)return void window.webkit.messageHandlers.NativeComponent.postMessage(e);if(null===(o=window.NativeComponentBridge)||void 0===o?void 0:o.postMessage)return void window.NativeComponentBridge.postMessage(S(e))}catch(e){L("NativeComponent send error:",e)}}function De(){if(Re()&&0!==Pe.length)for(Be=!0;Pe.length;){var e=Pe.shift();try{Fe(e)}catch(e){break}}}function Xe(e){try{if(!Re())return void Pe.push(e);Be||De(),Fe(e)}catch(e){L("NC send failed:",e)}}function He(e){return"".concat(e,"_").concat(Date.now(),"_").concat(te++)}function qe(e,n,t){if(n)if(n.aborted)t();else{var o={handleEvent:function(){n.removeEventListener("abort",o),t()}};n.addEventListener("abort",o)}}var ze={call:function(e,n,o){return new Promise(function(i,a){var l;if(e&&"string"==typeof e){Q||Te();var s=He("c"),c=(null==o?void 0:o.cap)||pe(e),d=null!==(l=null==o?void 0:o.timeoutMs)&&void 0!==l?l:x;ie.set(s,{method:e,mode:"call",resolve:i,reject:function(e){return a(e)},timeoutMs:d,timerId:null}),Ie({v:2,kind:"req",id:s,method:e,params:he(n),cap:c},s),qe(0,null==o?void 0:o.signal,function(){var e=Ee(s);xe(s,{code:t,message:"Bridge request aborted"}),!e&&K&&Ie({v:2,kind:"cancel",id:s})})}else a({code:r,message:"Method name must be a non-empty string"})})},stream:function(e,n,o){var i;if(!e||"string"!=typeof e){var a=re("invalid",function(){});return a._reject({code:r,message:"Method name must be a non-empty string"}),a}Q||Te();var l=He("c"),s=re(l,function(){Ee(l)?xe(l,{code:t,message:"Bridge request aborted"}):K&&Ie({v:2,kind:"cancel",id:l})}),c=(null==o?void 0:o.cap)||pe(e),d=null!==(i=null==o?void 0:o.timeoutMs)&&void 0!==i?i:x;return ie.set(l,{method:e,mode:"stream",stream:s,timeoutMs:d,timerId:null}),Ie({v:2,kind:"req",id:l,method:e,params:he(n),cap:c},l),qe(0,null==o?void 0:o.signal,function(){return s.cancel()}),s},notify:function(e,n,t){e&&"string"==typeof e&&(Q||Te(),Ie({v:2,kind:"notify",method:e,params:he(n),cap:(null==t?void 0:t.cap)||pe(e)}))},state:{subscribe:Ne},channel:{open:function(e,n,t){return e&&"string"==typeof e?(Q||Te(),new Promise(function(o,r){var i=He("ch"),a=function(e,n,t){var o,r=oe(),i=!1,a=0,l=!1,s=[],d=[],u=((o={id:e,send:function(t){i?n(t,a++):u._reject({code:c,message:"Channel '".concat(e,"' is closed")})},on:function(e,n){return"data"===e&&r.data.add(n),"close"===e&&r.close.add(n),"error"===e&&r.error.add(n),this}})[Symbol.asyncIterator]=function(){return{next:function(){return s.length>0?Promise.resolve({done:!1,value:s.shift()}):l?Promise.resolve({done:!0,value:void 0}):new Promise(function(e,n){d.push({resolve:e,reject:n})})}}},o.close=function(e,n){i&&(i=!1,l=!0,t(e,n),u._emitClose(e,n))},o._emitData=function(e){if(i){d.length>0?d.shift().resolve({done:!1,value:e}):s.push(e);for(var n=0,t=r.data;n<t.length;n++){var o=t[n];try{o(e)}catch(e){T("Channel listener failed:",e)}}}},o._emitClose=function(e,n){for(l=!0;d.length>0;)d.shift().resolve({done:!0,value:void 0});for(var t=0,o=r.close;t<o.length;t++){var i=o[t];try{i(e,n)}catch(e){T("Channel close listener failed:",e)}}},o._reject=function(e){for(l=!0;d.length>0;)d.shift().reject(e);for(var n=0,t=r.error;n<t.length;n++){var o=t[n];try{o(e)}catch(e){T("Channel error listener failed:",e)}}},o._markOpen=function(){i=!0,l=!1},o._isOpen=function(){return i},o._nextSeq=function(){return a++},o);return u}(i,function(e,n){Ie({v:2,kind:"ch.data",id:i,seq:n,payload:e})},function(e,n){var t=ae.get(i);t&&null!==t.timerId&&clearTimeout(t.timerId),ae.delete(i),le.delete(i),Ie({v:2,kind:"ch.close",id:i,code:e,reason:n})});ae.set(i,{topic:e,channel:a,resolve:o,reject:r,timerId:null}),Ie({v:2,kind:"ch.open",id:i,topic:e,params:he(n),cap:(null==t?void 0:t.cap)||pe(e)},i)})):Promise.reject({code:r,message:"Topic name must be a non-empty string"})}}},Ge={invoke:function(e,n,t){return ze.call(Ue(e),n,We(t)).then(function(e){return e}).catch(function(e){return Promise.reject(f(e))})},notify:function(e,n,t){ze.notify(Ue(e),n,We(t))},stream:function(e,n,t){return Je(ze.stream(Ue(e),n,We(t)))},channel:function(e,n,t){return ze.channel.open(Ue(e),n,We(t)).then(function(e){return function(e){var n=new Set,t=new Set;return e.on("data",function(e){for(var t=0,o=n;t<o.length;t++){(0,o[t])(e)}}),e.on("close",function(e,n){for(var o={code:e,reason:n},r=0,i=t;r<i.length;r++){(0,i[r])(o)}}),{send:function(n){e.send(n)},onMessage:function(e){return n.add(e),function(){n.delete(e)}},onClose:function(e){return t.add(e),function(){t.delete(e)}},close:function(n,t){e.close(n,t)}}}(e)}).catch(function(e){return Promise.reject(f(e))})},raw:ze,state:{subscribe:Ne},_connectWebMessagePort:function(e){if(O===b){if(j&&j!==e)try{j.onmessage=null,j.close()}catch(e){}j=e,e.onmessage=function(e){var n=e.data;if("string"==typeof n)try{n=JSON.parse(n)}catch(e){return}Oe(n)};try{e.start()}catch(e){}C("Port connected"),Te()}},_receiveEvaluateMessage:function(e){try{e&&Oe(JSON.parse(e))}catch(e){L("Parse error:",e)}},debug:new Proxy(k,{get:function(e,n){return e[n]},set:function(e,n,t){return n in e&&(e[n]=!!t,console.log("[LX] ".concat(n,": ").concat(t)),!0)}}),platform:{isHarmony:function(){return"Harmony"===v.os},isIOS:h,isAndroid:function(){return"Android"===v.os},isMacOS:g,isDesktop:function(){return g()},getOS:p},dom:{measureById:function(e){try{if(!e)return null;var n=document.getElementById(e);if(!n)return null;var t=n.getBoundingClientRect(),o=0;try{o=parseFloat(getComputedStyle(n).borderRadius)||0}catch(e){}return[t.left+window.scrollX,t.top+window.scrollY,t.width,t.height,o]}catch(e){return null}}},nativeComponents:{send:Xe,hasHandler:Re,flush:De,register:function(e,n){return e&&"function"==typeof n?(je.set(e,n),function(){return je.delete(e)}):function(){}},unregister:function(e){je.delete(e)}},isReady:function(){return K}};function Ue(e){return e.startsWith("host.")?e:"host.".concat(e)}function We(e){return __assign(__assign({},e||{}),{cap:(null==e?void 0:e.cap)||"host"})}function Je(e){var n=new Set,t=new Set;return e.on("data",function(e){for(var t=0,o=n;t<o.length;t++){(0,o[t])(e)}}),e.on("error",function(e){for(var n=f(e),o=0,r=t;o<r.length;o++){(0,r[o])(n)}}),{onEvent:function(e){return n.add(e),function(){n.delete(e)}},onError:function(e){return t.add(e),function(){t.delete(e)}},result:e.result.catch(function(e){return Promise.reject(f(e))}),cancel:function(){e.cancel()}}}function Ye(){if(window.__LX_BRIDGE_INIT_STATE)C("Bridge already ".concat(window.__LX_BRIDGE_INIT_STATE,", skipping duplicate init"));else{window.__LX_BRIDGE_INIT_STATE="initializing";try{C("Method: ".concat(O)),function(e){if("undefined"!=typeof window&&(window[y]=e,0!==E.length))for(var n=0,t=E.splice(0,E.length);n<t.length;n++){var o=t[n];try{e(o)}catch(e){T("Failed to replay queued native message:",e)}}}(Ge._receiveEvaluateMessage),G()?Y():O===b?(q(),function(){var e,n;if(j)return Promise.resolve(j);if(X.promise)return X.promise;q(),X.promise=new Promise(function(e,n){X.resolve=function(n){z(),e(n)},X.reject=function(e){z(),n(e)},X.timer=window.setTimeout(function(){var e;null===(e=X.reject)||void 0===e||e.call(X,new Error("MessagePort init timed out after ".concat(5e3,"ms")))},5e3)});try{null===(e=window.LingXiaProxy)||void 0===e||e.getPort("LingXiaPort")}catch(e){null===(n=X.reject)||void 0===n||n.call(X,e)}return X.promise}().catch(function(e){return T("Port init failed:",e)})):"webkit"===O||O===_?Te():T("Unknown method"),window.LingXiaBridge=Ge,m({os:p(),send:Xe}),window.__LX_BRIDGE_INIT_STATE="initialized",C("Init complete")}catch(e){throw delete window.__LX_BRIDGE_INIT_STATE,e}}}function Ve(e){var n=document.createElement("div");return n.textContent=e,n.innerHTML}function $e(e){var n=e.failedPath,t=e.reason,o=document.createElement("style");o.textContent="\n* { margin: 0; padding: 0; box-sizing: border-box; }\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: #f5f5f7;\n color: #1d1d1f;\n padding: 20px;\n -webkit-font-smoothing: antialiased;\n}\n.lx-error {\n text-align: center;\n max-width: 400px;\n}\n.lx-error-code {\n font-size: 120px;\n font-weight: 700;\n color: #d1d1d6;\n line-height: 1;\n letter-spacing: -4px;\n}\n.lx-error-title {\n font-size: 21px;\n font-weight: 600;\n margin: 16px 0 8px;\n color: #1d1d1f;\n}\n.lx-error-desc {\n font-size: 15px;\n color: #86868b;\n line-height: 1.5;\n}\n.lx-error-path {\n display: inline-block;\n margin-top: 20px;\n padding: 10px 16px;\n background: rgba(0,0,0,0.04);\n border-radius: 8px;\n font-family: 'SF Mono', ui-monospace, Menlo, Monaco, monospace;\n font-size: 13px;\n color: #1d1d1f;\n word-break: break-all;\n max-width: 100%;\n}\n@media (prefers-color-scheme: dark) {\n body { background: #000; color: #f5f5f7; }\n .lx-error-code { color: #3a3a3c; }\n .lx-error-title { color: #f5f5f7; }\n .lx-error-desc { color: #86868b; }\n .lx-error-path { background: rgba(255,255,255,0.08); color: #f5f5f7; }\n}\n",document.head.appendChild(o),document.body.innerHTML="",document.body.style.cssText="";var r=document.createElement("div");r.className="lx-error";var i='<div class="lx-error-code">404</div>';i+='<h1 class="lx-error-title">Page Not Found</h1>',i+="<p class=\"lx-error-desc\">The page you're looking for doesn't exist.</p>",n&&(i+='<div class="lx-error-path">'.concat(Ve(n),"</div>")),t&&(i+='<p class="lx-error-desc" style="margin-top:12px">'.concat(Ve(t),"</p>")),r.innerHTML=i,document.body.appendChild(r)}function Ke(){var e=window.__LX_RUNTIME_CONFIG;return!(!e||!e.error)}function Qe(){var e;return(null===(e=window.__LX_RUNTIME_CONFIG)||void 0===e?void 0:e.error)||null}var Ze={handleEvent:function(){return en()}};function en(){if(Ke()){var e=Qe();e&&$e(e)}}function nn(){Ye(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Ze):en()}var tn="lx-action-sheet-style",on=null;function rn(e){var n,t,o,r=e,i=null!==(n=null==r?void 0:r.itemList)&&void 0!==n?n:[],a=null!==(t=null==r?void 0:r.cancelText)&&void 0!==t?t:"Cancel",l=null!==(o=null==r?void 0:r.itemColor)&&void 0!==o?o:"#007AFF",s=(null!=on?on:Promise.resolve()).then(function(){return an(i,a,l)},function(){return an(i,a,l)});return on=s,s}function an(e,n,t){return new Promise(function(o){var r=!1,i="macOS"===p();!function(){if(!document.getElementById(tn)){var e=document.createElement("style");e.id=tn,e.textContent="\n.lx-as-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity ".concat(300,"ms ease;\n}\n.lx-as-backdrop.lx-as-visible { opacity: 1; }\n\n.lx-as-sheet {\n position: fixed; left: 0; right: 0; bottom: 0; z-index: 100000;\n transform: translateY(100%);\n transition: transform ").concat(300,"ms ease;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n}\n.lx-as-sheet.lx-as-visible { transform: translateY(0); }\n.lx-as-sheet.lx-as-desktop {\n left: 50%;\n right: auto;\n bottom: auto;\n top: 50%;\n width: min(92vw, 460px);\n transform: translate(-50%, calc(-50% + 16px));\n}\n.lx-as-sheet.lx-as-desktop.lx-as-visible { transform: translate(-50%, -50%); }\n\n.lx-as-container {\n background: #fff;\n border-radius: 16px 16px 0 0;\n overflow: hidden;\n}\n.lx-as-container.lx-as-desktop {\n border-radius: 16px;\n}\n\n.lx-as-item {\n display: block; width: 100%;\n height: 56px;\n line-height: 56px;\n padding: 0;\n border: none; background: none;\n font-size: 18px; font-weight: 400;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n position: relative;\n}\n.lx-as-item:active { background: rgba(0,0,0,0.08); }\n.lx-as-item + .lx-as-item::before {\n content: ''; position: absolute; top: 0; left: 0; right: 0;\n height: 1px; background: #E0E0E0;\n}\n.lx-as-separator {\n height: 8px;\n background: #F2F2F2;\n}\n.lx-as-cancel-btn { font-weight: 500; color: #000; }\n"),document.head.appendChild(e)}}();var a=document.createElement("div");a.className="lx-as-backdrop";var l=document.createElement("div");l.className="lx-as-sheet",i&&l.classList.add("lx-as-desktop");var s=document.createElement("div");s.className="lx-as-container",i&&s.classList.add("lx-as-desktop"),e.forEach(function(e,n){var o=document.createElement("button");o.className="lx-as-item",o.textContent=e,o.style.color=t,o.addEventListener("click",function(){return u(n)}),s.appendChild(o)});var c=document.createElement("div");c.className="lx-as-separator",s.appendChild(c);var d=document.createElement("button");function u(e){r||(r=!0,a.classList.remove("lx-as-visible"),l.classList.remove("lx-as-visible"),setTimeout(function(){a.remove(),l.remove(),o({tapIndex:e})},300))}d.className="lx-as-item lx-as-cancel-btn",d.textContent=n,d.addEventListener("click",function(){return u(-1)}),s.appendChild(d),l.appendChild(s),document.body.appendChild(a),document.body.appendChild(l),requestAnimationFrame(function(){a.classList.add("lx-as-visible"),l.classList.add("lx-as-visible")}),a.addEventListener("click",function(){return u(-1)})})}var ln=200,sn="lx-modal-style",cn=null;function dn(e){var n,t,o,r,i,a,l=e,s=null!==(n=null==l?void 0:l.title)&&void 0!==n?n:"",c=null!==(t=null==l?void 0:l.content)&&void 0!==t?t:"",d=null===(o=null==l?void 0:l.showCancel)||void 0===o||o,u=null!==(r=null==l?void 0:l.cancelText)&&void 0!==r?r:"Cancel",f=null==l?void 0:l.cancelColor,m=null!==(i=null==l?void 0:l.confirmText)&&void 0!==i?i:"OK",v=null!==(a=null==l?void 0:l.confirmColor)&&void 0!==a?a:"#007AFF",p=(null!=cn?cn:Promise.resolve()).then(function(){return un(s,c,d,u,f,m,v)},function(){return un(s,c,d,u,f,m,v)});return cn=p,p}function un(e,n,t,o,r,i,a){return new Promise(function(l){var s=!1;!function(){if(!document.getElementById(sn)){var e=document.createElement("style");e.id=sn,e.textContent="\n.lx-modal-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity ".concat(ln,"ms ease;\n display: flex; align-items: center; justify-content: center;\n}\n.lx-modal-backdrop.lx-modal-visible { opacity: 1; }\n\n.lx-modal-dialog {\n width: min(92vw, 320px);\n background: #fff;\n border-radius: 14px;\n overflow: hidden;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n transform: scale(0.95); opacity: 0;\n transition: transform ").concat(ln,"ms ease, opacity ").concat(ln,"ms ease;\n}\n.lx-modal-backdrop.lx-modal-visible .lx-modal-dialog {\n transform: scale(1); opacity: 1;\n}\n\n.lx-modal-body {\n padding: 24px 20px 16px;\n text-align: center;\n}\n.lx-modal-title {\n margin: 0 0 8px;\n font-size: 17px;\n font-weight: 600;\n color: #000;\n line-height: 1.35;\n}\n.lx-modal-content {\n margin: 0;\n font-size: 14px;\n color: #666;\n line-height: 1.5;\n word-break: break-word;\n}\n.lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n font-size: 17px;\n font-weight: 600;\n color: #000;\n}\n\n.lx-modal-footer {\n display: flex;\n border-top: 1px solid #E0E0E0;\n}\n.lx-modal-btn {\n flex: 1;\n height: 44px;\n line-height: 44px;\n padding: 0;\n border: none;\n background: none;\n font-size: 17px;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n.lx-modal-btn:active { background: rgba(0,0,0,0.06); }\n.lx-modal-btn + .lx-modal-btn {\n border-left: 1px solid #E0E0E0;\n}\n.lx-modal-btn-cancel {\n color: #666;\n font-weight: 400;\n}\n.lx-modal-btn-confirm {\n font-weight: 600;\n}\n\n@media (prefers-color-scheme: dark) {\n .lx-modal-dialog { background: #2c2c2e; }\n .lx-modal-title { color: #f5f5f7; }\n .lx-modal-content { color: #ababab; }\n .lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n color: #f5f5f7;\n }\n .lx-modal-footer { border-top-color: #3a3a3c; }\n .lx-modal-btn:active { background: rgba(255,255,255,0.08); }\n .lx-modal-btn + .lx-modal-btn { border-left-color: #3a3a3c; }\n .lx-modal-btn-cancel { color: #ababab; }\n}\n"),document.head.appendChild(e)}}();var c=document.createElement("div");c.className="lx-modal-backdrop";var d=document.createElement("div");d.className="lx-modal-dialog";var u=document.createElement("div");u.className="lx-modal-body";var f=document.createElement("div");if(f.className="lx-modal-title",f.textContent=e,u.appendChild(f),n){var m=document.createElement("p");m.className="lx-modal-content",m.textContent=n,u.appendChild(m)}d.appendChild(u);var v=document.createElement("div");if(v.className="lx-modal-footer",t){var p=document.createElement("button");p.className="lx-modal-btn lx-modal-btn-cancel",p.textContent=o,r&&(p.style.color=r),p.addEventListener("click",function(){return g(!1)}),v.appendChild(p)}var h=document.createElement("button");function g(e){s||(s=!0,c.classList.remove("lx-modal-visible"),setTimeout(function(){c.remove(),l({confirm:e,cancel:!e})},ln))}h.className="lx-modal-btn lx-modal-btn-confirm",h.textContent=i,h.style.color=a,h.addEventListener("click",function(){return g(!0)}),v.appendChild(h),d.appendChild(v),c.appendChild(d),document.body.appendChild(c),requestAnimationFrame(function(){c.classList.add("lx-modal-visible")})})}var fn="lx-toast-style",mn=null;function vn(e){var n,t,o,r,i,a=e,l=null!==(n=null==a?void 0:a.title)&&void 0!==n?n:"",s=null!==(t=null==a?void 0:a.icon)&&void 0!==t?t:"none",c=null!==(o=null==a?void 0:a.duration)&&void 0!==o?o:1500,d=null!==(r=null==a?void 0:a.mask)&&void 0!==r&&r,u=null!==(i=null==a?void 0:a.position)&&void 0!==i?i:"center";mn&&(mn.dismiss(),mn=null),function(){if(!document.getElementById(fn)){var e=document.createElement("style");e.id=fn,e.textContent="\n.lx-toast-mask {\n position: fixed; inset: 0; z-index: 99998;\n}\n.lx-toast-container {\n position: fixed; left: 0; right: 0; z-index: 99999;\n display: flex; justify-content: center;\n pointer-events: none;\n}\n.lx-toast-container.lx-toast-top { top: 0; padding-top: 80px; }\n.lx-toast-container.lx-toast-center { top: 0; bottom: 0; align-items: center; }\n.lx-toast-container.lx-toast-bottom { bottom: 0; padding-bottom: 80px; }\n\n.lx-toast-box {\n display: flex; flex-direction: column; align-items: center; gap: 10px;\n min-width: 120px; max-width: 280px;\n padding: 20px;\n background: rgba(0,0,0,0.8);\n border-radius: 12px;\n color: #fff;\n pointer-events: auto;\n transform: scale(0.8); opacity: 0;\n transition: transform ".concat(200,"ms ease, opacity ").concat(200,"ms ease;\n}\n.lx-toast-box.lx-toast-no-icon {\n min-width: auto; min-height: auto;\n padding: 12px 20px;\n}\n.lx-toast-box.lx-toast-visible {\n transform: scale(1); opacity: 1;\n}\n.lx-toast-icon {\n width: 36px; height: 36px;\n color: #fff;\n line-height: 0;\n}\n.lx-toast-title {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n font-size: 16px; font-weight: 500;\n text-align: center;\n line-height: 1.4;\n word-break: break-word;\n -webkit-font-smoothing: antialiased;\n}\n"),document.head.appendChild(e)}}();var f=null;d&&((f=document.createElement("div")).className="lx-toast-mask",document.body.appendChild(f));var m=document.createElement("div");m.className="lx-toast-container","top"===u?m.classList.add("lx-toast-top"):"bottom"===u?m.classList.add("lx-toast-bottom"):m.classList.add("lx-toast-center");var v=document.createElement("div");v.className="lx-toast-box";var p="none"!==s;if(p||v.classList.add("lx-toast-no-icon"),p){var h=document.createElement("div");h.className="lx-toast-icon","success"===s?h.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M11 18l5 5 9-9" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>':"error"===s?h.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M13 13l10 10M23 13l-10 10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>':"loading"===s&&(h.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 4a14 14 0 0 1 14 14" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.8s" repeatCount="indefinite"/></path></svg>'),v.appendChild(h)}var g=document.createElement("div");g.className="lx-toast-title",g.textContent=l,v.appendChild(g),m.appendChild(v),document.body.appendChild(m),requestAnimationFrame(function(){v.classList.add("lx-toast-visible")});var y=!1;function x(){y||(y=!0,(null==mn?void 0:mn.dismiss)===x&&(mn=null),v.classList.remove("lx-toast-visible"),w&&clearTimeout(w),setTimeout(function(){m.remove(),null==f||f.remove()},200))}var w=null;return c>0&&(w=setTimeout(x,c)),mn={dismiss:x,timer:w},Promise.resolve()}function pn(){return mn&&(mn.dismiss(),mn=null),Promise.resolve()}return"all"!==__LX_RUNTIME_PLATFORM__&&"desktop"!==__LX_RUNTIME_PLATFORM__||(ve("ui.showActionSheet",rn),ve("ui.showModal",dn),ve("ui.showToast",vn),ve("ui.hideToast",pn)),nn(),e.LingXiaBridge=Ge,e.boot=function(){Ye(),en()},e.bootWhenReady=nn,e.channel=function(e,n,t){return Ge.channel(e,n,t)},e.getErrorInfo=Qe,e.hasError=Ke,e.initBridge=Ye,e.invoke=function(e,n,t){return Ge.invoke(e,n,t)},e.isNativeError=function(e,n){if(!e||"object"!=typeof e)return!1;var t=e;return"string"==typeof t.code&&""!==t.code.trim()&&("string"==typeof t.message&&(void 0===n||t.code===n))},e.notify=function(e,n,t){ze.notify(Ue(e),n,We(t))},e.renderErrorUI=$e,e.stream=function(e,n,t){return Je(ze.stream(Ue(e),n,We(t)))},e}({});
1
+ var __extends=this&&this.__extends||function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])},e(n,t)};return function(n,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},__assign.apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,n,t,o){return new(t||(t=Promise))(function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t(function(e){e(n)})).then(a,l)}s((o=o.apply(e,n||[])).next())})},__generator=this&&this.__generator||function(e,n){var t,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(t=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){i.label=l[1];break}if(6===l[0]&&i.label<r[1]){i.label=r[1],r=l;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(l);break}r[2]&&i.ops.pop(),i.trys.pop();continue}l=n.call(e,i)}catch(e){l=[6,e],o=0}finally{t=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},__spreadArray=this&&this.__spreadArray||function(e,n,t){if(t||2===arguments.length)for(var o,r=0,i=n.length;r<i;r++)!o&&r in n||(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))},__LX_RUNTIME_PLATFORM__="mobile",__LingXiaBridgeBundle=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var n="BRIDGE_TIMEOUT",t="BRIDGE_CANCELED",o="BRIDGE_HANDSHAKE_FAILED",r="BRIDGE_MALFORMED_MESSAGE",i="BRIDGE_METHOD_NOT_FOUND",a="BRIDGE_CAPABILITY_DENIED",l="BRIDGE_INTERNAL_ERROR",s="BRIDGE_OUTBOX_FULL",c="BRIDGE_STREAM_CLOSED",d=function(e){function n(n,t,o){var r=e.call(this,t)||this;return r.name="BridgeInvocationError",r.code=n,r.data=o,r}return __extends(n,e),n}(Error);function u(e){if(e instanceof d)return e;if(e&&"object"==typeof e){var n=e,t=l;("string"==typeof n.code&&""!==n.code.trim()||"number"==typeof n.code&&Number.isFinite(n.code))&&(t=n.code);var o="string"==typeof n.message&&""!==n.message.trim()?n.message:"Unknown error";return new d(t,o,"data"in n?n.data:void 0)}var r=e instanceof Error?e.message:"string"==typeof e?e:"Unknown error";return new d(l,r)}function f(e){var n=u(e);return __assign({code:String(n.code||l),message:"string"==typeof n.message&&""!==n.message.trim()?n.message:"Unknown error"},void 0===n.data?{}:{data:n.data})}function m(e){var n,t=e.os,o=e.send;if("undefined"!=typeof window&&"undefined"!=typeof document){var r="iOS"===t;if(r||"Android"===t){var i=Symbol.for("LingXia.NativeComponentCoverageMonitor");if(!(null===(n=window[i])||void 0===n?void 0:n.installed)){var a={installed:!0,coveredById:new Map,coveredCount:0,anyCovered:!1,scheduled:!1,hasAnyVideo:!1,scrollLocked:!1,scrollY:0,htmlOverflow:"",bodyOverflow:"",bodyPosition:"",bodyTop:"",bodyWidth:""};window[i]=a,new MutationObserver(u).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0});var l={handleEvent:function(){(a.hasAnyVideo||0!==a.coveredById.size)&&u()}},s={handleEvent:function(){return u()}};window.addEventListener("scroll",l,{capture:!0,passive:!0}),window.addEventListener("resize",s),u()}}}function c(e){var n,t,o=null===(n=e.getBoundingClientRect)||void 0===n?void 0:n.call(e);if(!o)return!1;if(o.width<2||o.height<2)return!1;var r=o.left+o.width/2,i=o.top+o.height/2;if(r<0||i<0||r>=window.innerWidth||i>=window.innerHeight)return!1;var a=null===(t=document.elementFromPoint)||void 0===t?void 0:t.call(document,r,i);return!!a&&(a!==document.documentElement&&a!==document.body&&!(a===e||e.contains(a)))}function d(){a.scheduled=!1;var e=document.querySelectorAll("lx-video[id]");if(a.hasAnyVideo=e.length>0,a.hasAnyVideo||0!==a.coveredById.size||a.anyCovered){for(var n=new Set,t=0,i=Array.from(e);t<i.length;t++){var l=i[t];if(p=l.id){n.add(p);var s=c(l),d=a.coveredById.get(p);d!==s&&(!0===d&&(a.coveredCount-=1),!0===s&&(a.coveredCount+=1),a.coveredById.set(p,s),o({id:p,action:"component.coverage",covered:s}))}}for(var u=[],f=0,m=a.coveredById.entries();f<m.length;f++){var v=m[f],p=v[0];s=v[1];n.has(p)||(u.push(p),!0===s&&(a.coveredCount-=1))}for(var h=0,g=u;h<g.length;h++){p=g[h];a.coveredById.delete(p),o({id:p,action:"component.coverage",covered:!1})}var y=a.coveredCount>0;y!==a.anyCovered&&(a.anyCovered=y,r&&(y?function(){if(r&&!a.scrollLocked){var e=document.documentElement,n=document.body;e&&n&&(a.scrollLocked=!0,a.scrollY=window.scrollY||e.scrollTop||0,a.htmlOverflow=e.style.overflow||"",a.bodyOverflow=n.style.overflow||"",a.bodyPosition=n.style.position||"",a.bodyTop=n.style.top||"",a.bodyWidth=n.style.width||"",e.style.overflow="hidden",n.style.overflow="hidden",n.style.position="fixed",n.style.top="".concat(-a.scrollY,"px"),n.style.width="100%")}}():function(){if(r&&a.scrollLocked){var e=document.documentElement,n=document.body;e&&n&&(a.scrollLocked=!1,e.style.overflow=a.htmlOverflow,n.style.overflow=a.bodyOverflow,n.style.position=a.bodyPosition,n.style.top=a.bodyTop,n.style.width=a.bodyWidth,window.scrollTo(0,a.scrollY))}}()))}}function u(){a.scheduled||(a.scheduled=!0,requestAnimationFrame(d))}}var v="undefined"!=typeof window&&window.__LX_BRIDGE_CFG||{};function p(){return v.os||"unknown"}function h(){return"iOS"===v.os}function g(){return"macOS"===v.os}var y="__LingXiaRecvMessage",w=5e3,x="[LX.Bridge]",b="messageport",_="jsinterface",k=v.appleDownstreamURL,E={data:!1,proto:!1,all:!1},I=[];function C(e){return E.all||E[e]}function T(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.log.apply(console,__spreadArray([x],e,!1))}function L(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.warn.apply(console,__spreadArray([x],e,!1))}function S(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.error.apply(console,__spreadArray([x],e,!1))}function M(e){try{return JSON.stringify(e)}catch(n){return function(e,n){var t=new WeakSet;return JSON.stringify(e,function(e,n){if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n},n)}(e)}}function N(e){try{return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}catch(e){return{}}}var O,A,j="iOS"===v.os||"macOS"===v.os?"webkit":"Harmony"===v.os?"messageport":"Android"===v.os?(null===(A=null===(O=window.LingXiaProxy)||void 0===O?void 0:O.supportsMessagePort)||void 0===A?void 0:A.call(O))?"messageport":"jsinterface":"unknown";"undefined"!=typeof window&&"function"!=typeof window[y]&&(window[y]=function(e){I.push(e)});var P=null,B=!1,R=null,F=null,D=null,X=200,H={listenerInstalled:!1,promise:null,resolve:null,reject:null,timer:null},q={handleEvent:function(e){var n,t,o=e;if("LingXia-port-init"===o.data){var r=null===(n=o.ports)||void 0===n?void 0:n[0];r&&(Je._connectWebMessagePort(r),null===(t=H.resolve)||void 0===t||t.call(H,r))}}};function z(){H.listenerInstalled||(H.listenerInstalled=!0,window.addEventListener("message",q))}function G(){null!==H.timer&&(window.clearTimeout(H.timer),H.timer=null),H.resolve=null,H.reject=null,H.promise=null}function U(){return"webkit"===j&&(h()||g())}function W(){null!==D&&(clearTimeout(D),D=null)}function J(e){for(var n=0,t=Array.from(ae.keys());n<t.length;n++){xe(t[n],{code:c,message:e})}for(var o=0,r=Array.from(le.keys());o<r.length;o++){be(r[o],{code:c,message:e})}!function(e){for(var n=0,t=Array.from(se.entries());n<t.length;n++){var o=t[n],r=o[0],i=o[1];se.delete(r),i._emitClose(c,e)}}(e)}function Y(){return __awaiter(this,void 0,void 0,function(){var e,n,t,o,r,i,a,l,s;return __generator(this,function(c){switch(c.label){case 0:if(!k)throw new Error("Apple downstream URL is not configured");return e=new AbortController,F=e,[4,fetch(k,{method:"GET",cache:"no-store",headers:{Accept:"application/x-ndjson"},signal:e.signal})];case 1:if(!(n=c.sent()).ok)throw new Error("Apple downstream HTTP ".concat(n.status));if(!n.body)throw new Error("Apple downstream response body unavailable");B=!0,X=200,C("proto")&&T("Apple downstream connected"),Le(),t=n.body.getReader(),o=new TextDecoder,r="",c.label=2;case 2:c.trys.push([2,6,7,8]),c.label=3;case 3:return[4,t.read()];case 4:return i=c.sent(),a=i.value,i.done?[3,5]:(r=function(e){for(var n=e;;){var t=n.indexOf("\n");if(t<0)break;var o=n.slice(0,t).trim();if(n=n.slice(t+1),o)try{je(JSON.parse(o))}catch(e){L("Apple downstream parse error:",e,o)}}return n}(r+=o.decode(a,{stream:!0})),[3,3]);case 5:if(r+=o.decode(),l=r.trim())try{je(JSON.parse(l))}catch(e){L("Apple downstream trailing parse error:",e,l)}return[3,8];case 6:if(s=c.sent(),e.signal.aborted)return[2];throw s;case 7:try{t.releaseLock()}catch(e){}return[7];case 8:return[2]}})})}function V(){U()&&(R||(W(),R=Y().catch(function(e){(null==F?void 0:F.signal.aborted)||L("Apple downstream failed:",e)}).finally(function(){var e,n=null!==(e=null==F?void 0:F.signal.aborted)&&void 0!==e&&e;R=null,F=null;var t,o,r=B;B=!1,t="Apple downstream closed",o=r,Te(),K=null,Q=!1,Z=!1,ee=0,o&&J(t),n||function(e){if(U()){W();var n=X;X=Math.min(2*X,2e3);var t="Apple downstream disconnected, retrying in ".concat(n,"ms: ").concat(e);n<=200?T(t):L(t),D=setTimeout(function(){D=null,V()},n)}}("stream closed")})))}function $(e){var n,t,o,r=e.kind;"req"!==r&&"notify"!==r||T("postToNative: ".concat(r," ").concat(e.method)),C("proto")&&console.log("→",JSON.stringify(e,null,2));try{if("webkit"===j)return void(null===(t=null===(n=window.webkit)||void 0===n?void 0:n.messageHandlers.LingXia)||void 0===t||t.postMessage(e));var i=M(e);if(j===b&&P)return void P.postMessage(i);if(j===_&&(null===(o=window.LingXiaProxy)||void 0===o?void 0:o.postMessage))return void window.LingXiaProxy.postMessage(i);L("Transport not ready")}catch(e){S("Send error:",e)}}var K=null,Q=!1,Z=!1,ee=0,ne=null,te={},oe=0;function re(){return{data:new Set,end:new Set,error:new Set,close:new Set}}function ie(e,n){var t,o=re(),r=!1,i=function(){},a=function(){},l=[],s=[],c=new Promise(function(e,n){i=e,a=n});return(t={id:e,result:c,on:function(e,n){return"data"===e&&o.data.add(n),"end"===e&&o.end.add(n),"error"===e&&o.error.add(n),this}})[Symbol.asyncIterator]=function(){return{next:function(){return l.length>0?Promise.resolve({done:!1,value:l.shift()}):r?c.then(function(e){return{done:!0,value:e}},function(e){return Promise.reject(e)}):new Promise(function(e,n){s.push({resolve:e,reject:n})})}}},t.cancel=function(){r||n()},t._emitData=function(e){if(!r){s.length>0?s.shift().resolve({done:!1,value:e}):l.push(e);for(var n=0,t=o.data;n<t.length;n++){var i=t[n];try{i(e)}catch(e){L("Stream data listener failed:",e)}}}},t._resolve=function(e){if(!r){for(r=!0,i(e);s.length>0;)s.shift().resolve({done:!0,value:e});for(var n=0,t=o.end;n<t.length;n++){var a=t[n];try{a(e)}catch(e){L("Stream end listener failed:",e)}}}},t._reject=function(e){if(!r){for(r=!0,a(e);s.length>0;)s.shift().reject(e);for(var n=0,t=o.error;n<t.length;n++){var i=t[n];try{i(e)}catch(e){L("Stream error listener failed:",e)}}}},t}var ae=new Map,le=new Map,se=new Map,ce=[],de=-1,ue={},fe=new Set,me=new WeakMap,ve=new Map;function pe(e,n){ve.set(e,n)}function he(e){if(e.startsWith("host."))return"host";var n=e.indexOf(".");return n>0?e.slice(0,n):"page"}function ge(e){if(null!=e)return e}function ye(){return j===b?!!P:U()?B:"webkit"===j||j===_}function we(){return ye()&&Q}function xe(e,n){var t,o=ae.get(e);if(o){ae.delete(e),null!==o.timerId&&clearTimeout(o.timerId);var r=u(n);if("stream"===o.mode&&o.stream)return void o.stream._reject(r);null===(t=o.reject)||void 0===t||t.call(o,r)}}function be(e,n){var t=le.get(e);if(t){le.delete(e),null!==t.timerId&&clearTimeout(t.timerId);var o=u(n);t.channel._reject(o),t.reject(o)}}function _e(e,n){ae.has(e)?xe(e,n):le.has(e)&&be(e,n)}function ke(e){var t=ae.get(e);t&&(!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0?null!==t.timerId&&(clearTimeout(t.timerId),t.timerId=null):(null!==t.timerId&&clearTimeout(t.timerId),t.timerId=setTimeout(function(){ae.has(e)&&xe(e,{code:n,message:"'".concat(t.method,"' timed out")})},t.timeoutMs)))}function Ee(e){ae.has(e)?ke(e):le.has(e)&&function(e){var t=le.get(e);t&&(null!==t.timerId&&clearTimeout(t.timerId),t.timerId=setTimeout(function(){be(e,{code:n,message:"Channel '".concat(t.topic,"' timed out")})},w))}(e)}function Ie(e){for(var n,t=ce.length-1;t>=0;t--)if((null===(n=ce[t])||void 0===n?void 0:n.reqId)===e)return ce.splice(t,1),!0;return!1}function Ce(e,n){var t=e.kind,o="hello"===t||"helloAck"===t||"ready"===t;if(!we()&&!o)return ce.length>=256?(S("Outbox full"),void(n&&_e(n,{code:s,message:"Bridge outbox is full"}))):void ce.push({msg:e,reqId:n});n&&Ee(n),$(e)}function Te(){null!==ne&&(clearTimeout(ne),ne=null)}function Le(){if(!Q&&ye()){Te();var e={v:2,kind:"hello",nonce:v.nonce||"",role:"view",protocolsSupported:[2]};Z=!0,$(e),ne=setTimeout(function(){if(!Q)if(++ee<3)L("Handshake timeout (".concat(ee,"/").concat(3,"), retrying...")),Z=!1,Le();else{for(S("Handshake failed"),Te(),Z=!1,ee=0;ce.length;){var e=ce.shift();(null==e?void 0:e.reqId)&&_e(e.reqId,{code:o,message:"Bridge handshake failed"})}for(var n=0,t=Array.from(le.keys());n<t.length;n++){be(t[n],{code:o,message:"Bridge handshake failed"})}}},1e4)}}function Se(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Me(e,n,t){void 0===t&&(t=!1);var o=function(e){if(""===e)return[];if(!e.startsWith("/"))throw new Error("Invalid JSON pointer: ".concat(e));return e.split("/").slice(1).map(Se)}(n);if(0===o.length)return{container:{$root:e},key:"$root"};for(var r=e,i=0;i<o.length-1;i++){var a=o[i];if(Array.isArray(r))r=r[Number(a)];else{if(!r||"object"!=typeof r)throw new Error("Invalid container at ".concat(a));var l=r;if(t&&void 0===l[a]){var s=o[i+1];l[a]=s&&/^\d+$/.test(s)?[]:{}}r=l[a]}}return{container:r,key:o[o.length-1]}}function Ne(e){fe.forEach(function(n){try{if(!me.has(n))return me.set(n,!0),void n(N(ue),{rev:de,initial:!0});n(N(ue),{rev:de,initial:e})}catch(e){L("Subscriber error:",e)}})}function Oe(e){if("function"!=typeof e)return function(){};if(fe.add(e),de>=0){me.set(e,!0);try{e(N(ue),{rev:de,initial:!0})}catch(e){S("Callback error:",e)}}return function(){fe.delete(e),me.delete(e)}}function Ae(e){We.call("state.getSnapshot",{scope:e}).catch(function(){})}function je(e){var n,t;if(e&&"object"==typeof e){var o=e;if("event"===o.type&&"nativecomponent"===o.name&&o.payload){var r=o.payload,l=r.id||r.componentId;if("string"==typeof l){var s=Pe.get(l);if(s)try{s(r)}catch(e){S("NC handler error:",e)}}return}}var c=function(e){if(!e||"object"!=typeof e)return null;var n=e.v,t=e.kind;return 2!==n||"string"!=typeof t?null:e}(e);if(c)switch(c.kind){case"helloAck":return void(K=c.sessionId);case"ready":if(K&&c.sessionId!==K)return void L("sessionId mismatch");if(Te(),Q=!0,ee=0,c.hostMethods)for(var d=0,f=Object.entries(c.hostMethods);d<f.length;d++){var m=f[d],v=m[0],p=m[1];te[v]=p}return C("proto")&&T("Handshake complete, hostMethods:",Object.keys(te).length),void function(){if(we())for(;ce.length;){var e=ce.shift();e&&(e.reqId&&Ee(e.reqId),$(e.msg))}}();case"res":var h=ae.get(c.id);if(!h)return;if(ae.delete(c.id),null!==h.timerId&&clearTimeout(h.timerId),c.ok){if("state.getSnapshot"===h.method&&(function(e){if(!e||"object"!=typeof e)return!1;var n=e;return!("number"!=typeof n.rev||!Number.isFinite(n.rev)||!n.state||"object"!=typeof n.state||(ue=n.state,de=n.rev,C("data")&&(console.group("[LX] snapshot(res)"),console.log("rev:",de,"state:",N(ue)),console.groupEnd()),Ne(!0),0))}(c.result)||L("Invalid state.getSnapshot result")),"stream"===h.mode&&h.stream)return void h.stream._resolve(c.result);null===(n=h.resolve)||void 0===n||n.call(h,c.result)}else{var g=u(c.error);if("stream"===h.mode&&h.stream)return void h.stream._reject(g);null===(t=h.reject)||void 0===t||t.call(h,g)}return;case"event":if(ae.has(c.id)){var y=ae.get(c.id);return void("stream"===(null==y?void 0:y.mode)&&y.stream?(ke(c.id),y.stream._emitData(c.payload)):L("Received event for non-stream request '".concat(c.id,"'")))}return;case"state.snapshot":return ue=c.state||{},de=c.rev,C("data")&&(console.group("[LX] snapshot"),console.log("rev:",de,"state:",N(ue)),console.groupEnd()),void Ne(!0);case"state.patch":if(c.baseRev!==de)return L("baseRev mismatch",{have:de,want:c.baseRev}),void Ae(c.scope);try{!function(e,n){for(var t=0,o=n;t<o.length;t++){var r=o[t],i="add"===r.op||"replace"===r.op,a=Me(e,r.path,i),l=a.container,s=a.key;if("$root"!==s)if(Array.isArray(l)){var c="-"===s?l.length:Number(s);if(!Number.isFinite(c)||c<0)throw new Error("Invalid index");"remove"===r.op?l.splice(c,1):"add"===r.op?l.splice(c,0,r.value):"replace"===r.op&&(l[c]=r.value)}else{if(!l||"object"!=typeof l)throw new Error("Invalid container");var d=l;"remove"===r.op?delete d[s]:d[s]=r.value}else{for(var u=0,f=Object.keys(e);u<f.length;u++)delete e[f[u]];if("remove"!==r.op){var m=r.value;m&&"object"==typeof m&&Object.assign(e,m)}}}}(ue,c.ops||[]),de=c.rev}catch(e){return S("Patch failed:",e),void Ae(c.scope)}return C("data")&&(console.group("[LX] patch"),console.log("rev:",de,"ops:",c.ops),console.groupEnd()),Ne(!1),void(c.ack&&Ce({v:2,kind:"state.ack",scope:c.scope,rev:c.rev}));case"ch.ack":if(!(x=le.get(c.id)))return;if(le.delete(c.id),null!==x.timerId&&clearTimeout(x.timerId),c.ok)x.channel._markOpen(),se.set(c.id,x.channel),x.resolve(x.channel);else{g=u(c.error);x.channel._reject(g),x.reject(g)}return;case"ch.data":var w=se.get(c.id);if(!w)return;return void w._emitData(c.payload);case"ch.close":var x;if(x=le.get(c.id))return le.delete(c.id),void x.channel._emitClose(c.code,c.reason);var b=se.get(c.id);if(!b)return;return se.delete(c.id),void b._emitClose(c.code,c.reason);case"req":var _=c,k=he(_.method);if(!_.cap||_.cap!==k)return void Ce({v:2,kind:"res",id:_.id,ok:!1,error:{code:a,message:"Invalid cap for ".concat(_.method)}});var E=ve.get(_.method);return E?void Promise.resolve().then(function(){return E(_.params)}).then(function(e){Ce({v:2,kind:"res",id:_.id,ok:!0,result:e})}).catch(function(e){Ce({v:2,kind:"res",id:_.id,ok:!1,error:u(e)})}):void Ce({v:2,kind:"res",id:_.id,ok:!1,error:{code:i,message:"View handler not found: ".concat(_.method)}})}else L("Invalid V2 message:",e)}var Pe=new Map,Be=[],Re=!1;function Fe(){var e,n,t;return"undefined"!=typeof window&&!(!(null===(n=null===(e=window.webkit)||void 0===e?void 0:e.messageHandlers)||void 0===n?void 0:n.NativeComponent)&&!(null===(t=window.NativeComponentBridge)||void 0===t?void 0:t.postMessage))}function De(e){var n,t,o;try{if(null===(t=null===(n=window.webkit)||void 0===n?void 0:n.messageHandlers)||void 0===t?void 0:t.NativeComponent)return void window.webkit.messageHandlers.NativeComponent.postMessage(e);if(null===(o=window.NativeComponentBridge)||void 0===o?void 0:o.postMessage)return void window.NativeComponentBridge.postMessage(M(e))}catch(e){S("NativeComponent send error:",e)}}function Xe(){if(Fe()&&0!==Be.length)for(Re=!0;Be.length;){var e=Be.shift();try{De(e)}catch(e){break}}}function He(e){try{if(!Fe())return void Be.push(e);Re||Xe(),De(e)}catch(e){S("NC send failed:",e)}}function qe(e){return"".concat(e,"_").concat(Date.now(),"_").concat(oe++)}function ze(e,n,t){if(n)if(n.aborted)t();else{var o={handleEvent:function(){n.removeEventListener("abort",o),t()}};n.addEventListener("abort",o)}}var Ge,Ue,We={call:function(e,n,o){return new Promise(function(i,a){var l;if(e&&"string"==typeof e){Z||Le();var s=qe("c"),c=(null==o?void 0:o.cap)||he(e),d=null!==(l=null==o?void 0:o.timeoutMs)&&void 0!==l?l:w;ae.set(s,{method:e,mode:"call",resolve:i,reject:function(e){return a(e)},timeoutMs:d,timerId:null}),Ce({v:2,kind:"req",id:s,method:e,params:ge(n),cap:c},s),ze(0,null==o?void 0:o.signal,function(){var e=Ie(s);xe(s,{code:t,message:"Bridge request aborted"}),!e&&Q&&Ce({v:2,kind:"cancel",id:s})})}else a({code:r,message:"Method name must be a non-empty string"})})},stream:function(e,n,o){var i;if(!e||"string"!=typeof e){var a=ie("invalid",function(){});return a._reject({code:r,message:"Method name must be a non-empty string"}),a}Z||Le();var l=qe("c"),s=ie(l,function(){Ie(l)?xe(l,{code:t,message:"Bridge request aborted"}):Q&&Ce({v:2,kind:"cancel",id:l})}),c=(null==o?void 0:o.cap)||he(e),d=null!==(i=null==o?void 0:o.timeoutMs)&&void 0!==i?i:w;return ae.set(l,{method:e,mode:"stream",stream:s,timeoutMs:d,timerId:null}),Ce({v:2,kind:"req",id:l,method:e,params:ge(n),cap:c},l),ze(0,null==o?void 0:o.signal,function(){return s.cancel()}),s},notify:function(e,n,t){e&&"string"==typeof e&&(Z||Le(),Ce({v:2,kind:"notify",method:e,params:ge(n),cap:(null==t?void 0:t.cap)||he(e)}))},state:{subscribe:Oe},channel:{open:function(e,n,t){return e&&"string"==typeof e?(Z||Le(),new Promise(function(o,r){var i=qe("ch"),a=function(e,n,t){var o,r=re(),i=!1,a=0,l=!1,s=[],d=[],u=((o={id:e,send:function(t){i?n(t,a++):u._reject({code:c,message:"Channel '".concat(e,"' is closed")})},on:function(e,n){return"data"===e&&r.data.add(n),"close"===e&&r.close.add(n),"error"===e&&r.error.add(n),this}})[Symbol.asyncIterator]=function(){return{next:function(){return s.length>0?Promise.resolve({done:!1,value:s.shift()}):l?Promise.resolve({done:!0,value:void 0}):new Promise(function(e,n){d.push({resolve:e,reject:n})})}}},o.close=function(e,n){i&&(i=!1,l=!0,t(e,n),u._emitClose(e,n))},o._emitData=function(e){if(i){d.length>0?d.shift().resolve({done:!1,value:e}):s.push(e);for(var n=0,t=r.data;n<t.length;n++){var o=t[n];try{o(e)}catch(e){L("Channel listener failed:",e)}}}},o._emitClose=function(e,n){for(l=!0;d.length>0;)d.shift().resolve({done:!0,value:void 0});for(var t=0,o=r.close;t<o.length;t++){var i=o[t];try{i(e,n)}catch(e){L("Channel close listener failed:",e)}}},o._reject=function(e){for(l=!0;d.length>0;)d.shift().reject(e);for(var n=0,t=r.error;n<t.length;n++){var o=t[n];try{o(e)}catch(e){L("Channel error listener failed:",e)}}},o._markOpen=function(){i=!0,l=!1},o._isOpen=function(){return i},o._nextSeq=function(){return a++},o);return u}(i,function(e,n){Ce({v:2,kind:"ch.data",id:i,seq:n,payload:e})},function(e,n){var t=le.get(i);t&&null!==t.timerId&&clearTimeout(t.timerId),le.delete(i),se.delete(i),Ce({v:2,kind:"ch.close",id:i,code:e,reason:n})});le.set(i,{topic:e,channel:a,resolve:o,reject:r,timerId:null}),Ce({v:2,kind:"ch.open",id:i,topic:e,params:ge(n),cap:(null==t?void 0:t.cap)||he(e)},i)})):Promise.reject({code:r,message:"Topic name must be a non-empty string"})}}},Je={invoke:function(e,n,t){return We.call(Ye(e),n,Ve(t)).then(function(e){return e}).catch(function(e){return Promise.reject(f(e))})},notify:function(e,n,t){We.notify(Ye(e),n,Ve(t))},stream:function(e,n,t){return $e(We.stream(Ye(e),n,Ve(t)))},channel:function(e,n,t){return We.channel.open(Ye(e),n,Ve(t)).then(function(e){return function(e){var n=new Set,t=new Set;return e.on("data",function(e){for(var t=0,o=n;t<o.length;t++){(0,o[t])(e)}}),e.on("close",function(e,n){for(var o={code:e,reason:n},r=0,i=t;r<i.length;r++){(0,i[r])(o)}}),{send:function(n){e.send(n)},onMessage:function(e){return n.add(e),function(){n.delete(e)}},onClose:function(e){return t.add(e),function(){t.delete(e)}},close:function(n,t){e.close(n,t)}}}(e)}).catch(function(e){return Promise.reject(f(e))})},raw:We,state:{subscribe:Oe},_connectWebMessagePort:function(e){if(j===b){if(P&&P!==e)try{P.onmessage=null,P.close()}catch(e){}P=e,e.onmessage=function(e){var n=e.data;if("string"==typeof n)try{n=JSON.parse(n)}catch(e){return}je(n)};try{e.start()}catch(e){}T("Port connected"),Le()}},_receiveEvaluateMessage:function(e){try{e&&je(JSON.parse(e))}catch(e){S("Parse error:",e)}},debug:(Ge=E,Ue={},Object.keys(Ge).forEach(function(e){Object.defineProperty(Ue,e,{enumerable:!0,configurable:!1,get:function(){return Ge[e]},set:function(n){Ge[e]=!!n,console.log("[LX] ".concat(e,": ").concat(n))}})}),Ue),platform:{isHarmony:function(){return"Harmony"===v.os},isIOS:h,isAndroid:function(){return"Android"===v.os},isMacOS:g,isDesktop:function(){return g()},getOS:p},dom:{measureById:function(e){try{if(!e)return null;var n=document.getElementById(e);if(!n)return null;var t=n.getBoundingClientRect(),o=0;try{o=parseFloat(getComputedStyle(n).borderRadius)||0}catch(e){}return[t.left+window.scrollX,t.top+window.scrollY,t.width,t.height,o]}catch(e){return null}}},nativeComponents:{send:He,hasHandler:Fe,flush:Xe,register:function(e,n){return e&&"function"==typeof n?(Pe.set(e,n),function(){return Pe.delete(e)}):function(){}},unregister:function(e){Pe.delete(e)}},isReady:function(){return Q}};function Ye(e){return e.startsWith("host.")?e:"host.".concat(e)}function Ve(e){return __assign(__assign({},e||{}),{cap:(null==e?void 0:e.cap)||"host"})}function $e(e){var n=new Set,t=new Set;return e.on("data",function(e){for(var t=0,o=n;t<o.length;t++){(0,o[t])(e)}}),e.on("error",function(e){for(var n=f(e),o=0,r=t;o<r.length;o++){(0,r[o])(n)}}),{onEvent:function(e){return n.add(e),function(){n.delete(e)}},onError:function(e){return t.add(e),function(){t.delete(e)}},result:e.result.catch(function(e){return Promise.reject(f(e))}),cancel:function(){e.cancel()}}}function Ke(){if(window.__LX_BRIDGE_INIT_STATE)T("Bridge already ".concat(window.__LX_BRIDGE_INIT_STATE,", skipping duplicate init"));else{window.__LX_BRIDGE_INIT_STATE="initializing";try{T("Method: ".concat(j)),function(e){if("undefined"!=typeof window&&(window[y]=e,0!==I.length))for(var n=0,t=I.splice(0,I.length);n<t.length;n++){var o=t[n];try{e(o)}catch(e){L("Failed to replay queued native message:",e)}}}(Je._receiveEvaluateMessage),U()?V():j===b?(z(),function(){var e,n;if(P)return Promise.resolve(P);if(H.promise)return H.promise;z(),H.promise=new Promise(function(e,n){H.resolve=function(n){G(),e(n)},H.reject=function(e){G(),n(e)},H.timer=window.setTimeout(function(){var e;null===(e=H.reject)||void 0===e||e.call(H,new Error("MessagePort init timed out after ".concat(5e3,"ms")))},5e3)});try{null===(e=window.LingXiaProxy)||void 0===e||e.getPort("LingXiaPort")}catch(e){null===(n=H.reject)||void 0===n||n.call(H,e)}return H.promise}().catch(function(e){return L("Port init failed:",e)})):"webkit"===j||j===_?Le():L("Unknown method"),window.LingXiaBridge=Je,m({os:p(),send:He}),window.__LX_BRIDGE_INIT_STATE="initialized",T("Init complete")}catch(e){throw delete window.__LX_BRIDGE_INIT_STATE,e}}}function Qe(e){var n=document.createElement("div");return n.textContent=e,n.innerHTML}function Ze(e){var n=e.failedPath,t=e.reason,o=document.createElement("style");o.textContent="\n* { margin: 0; padding: 0; box-sizing: border-box; }\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: #f5f5f7;\n color: #1d1d1f;\n padding: 20px;\n -webkit-font-smoothing: antialiased;\n}\n.lx-error {\n text-align: center;\n max-width: 400px;\n}\n.lx-error-code {\n font-size: 120px;\n font-weight: 700;\n color: #d1d1d6;\n line-height: 1;\n letter-spacing: -4px;\n}\n.lx-error-title {\n font-size: 21px;\n font-weight: 600;\n margin: 16px 0 8px;\n color: #1d1d1f;\n}\n.lx-error-desc {\n font-size: 15px;\n color: #86868b;\n line-height: 1.5;\n}\n.lx-error-path {\n display: inline-block;\n margin-top: 20px;\n padding: 10px 16px;\n background: rgba(0,0,0,0.04);\n border-radius: 8px;\n font-family: 'SF Mono', ui-monospace, Menlo, Monaco, monospace;\n font-size: 13px;\n color: #1d1d1f;\n word-break: break-all;\n max-width: 100%;\n}\n@media (prefers-color-scheme: dark) {\n body { background: #000; color: #f5f5f7; }\n .lx-error-code { color: #3a3a3c; }\n .lx-error-title { color: #f5f5f7; }\n .lx-error-desc { color: #86868b; }\n .lx-error-path { background: rgba(255,255,255,0.08); color: #f5f5f7; }\n}\n",document.head.appendChild(o),document.body.innerHTML="",document.body.style.cssText="";var r=document.createElement("div");r.className="lx-error";var i='<div class="lx-error-code">404</div>';i+='<h1 class="lx-error-title">Page Not Found</h1>',i+="<p class=\"lx-error-desc\">The page you're looking for doesn't exist.</p>",n&&(i+='<div class="lx-error-path">'.concat(Qe(n),"</div>")),t&&(i+='<p class="lx-error-desc" style="margin-top:12px">'.concat(Qe(t),"</p>")),r.innerHTML=i,document.body.appendChild(r)}function en(){var e=window.__LX_RUNTIME_CONFIG;return!(!e||!e.error)}function nn(){var e;return(null===(e=window.__LX_RUNTIME_CONFIG)||void 0===e?void 0:e.error)||null}var tn={handleEvent:function(){return on()}};function on(){if(en()){var e=nn();e&&Ze(e)}}function rn(){Ke(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",tn):on()}var an="lx-action-sheet-style",ln=null;function sn(e){var n,t,o,r=e,i=null!==(n=null==r?void 0:r.itemList)&&void 0!==n?n:[],a=null!==(t=null==r?void 0:r.cancelText)&&void 0!==t?t:"Cancel",l=null!==(o=null==r?void 0:r.itemColor)&&void 0!==o?o:"#007AFF",s=(null!=ln?ln:Promise.resolve()).then(function(){return cn(i,a,l)},function(){return cn(i,a,l)});return ln=s,s}function cn(e,n,t){return new Promise(function(o){var r=!1,i="macOS"===p();!function(){if(!document.getElementById(an)){var e=document.createElement("style");e.id=an,e.textContent="\n.lx-as-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity ".concat(300,"ms ease;\n}\n.lx-as-backdrop.lx-as-visible { opacity: 1; }\n\n.lx-as-sheet {\n position: fixed; left: 0; right: 0; bottom: 0; z-index: 100000;\n transform: translateY(100%);\n transition: transform ").concat(300,"ms ease;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n}\n.lx-as-sheet.lx-as-visible { transform: translateY(0); }\n.lx-as-sheet.lx-as-desktop {\n left: 50%;\n right: auto;\n bottom: auto;\n top: 50%;\n width: min(92vw, 460px);\n transform: translate(-50%, calc(-50% + 16px));\n}\n.lx-as-sheet.lx-as-desktop.lx-as-visible { transform: translate(-50%, -50%); }\n\n.lx-as-container {\n background: #fff;\n border-radius: 16px 16px 0 0;\n overflow: hidden;\n}\n.lx-as-container.lx-as-desktop {\n border-radius: 16px;\n}\n\n.lx-as-item {\n display: block; width: 100%;\n height: 56px;\n line-height: 56px;\n padding: 0;\n border: none; background: none;\n font-size: 18px; font-weight: 400;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n position: relative;\n}\n.lx-as-item:active { background: rgba(0,0,0,0.08); }\n.lx-as-item + .lx-as-item::before {\n content: ''; position: absolute; top: 0; left: 0; right: 0;\n height: 1px; background: #E0E0E0;\n}\n.lx-as-separator {\n height: 8px;\n background: #F2F2F2;\n}\n.lx-as-cancel-btn { font-weight: 500; color: #000; }\n"),document.head.appendChild(e)}}();var a=document.createElement("div");a.className="lx-as-backdrop";var l=document.createElement("div");l.className="lx-as-sheet",i&&l.classList.add("lx-as-desktop");var s=document.createElement("div");s.className="lx-as-container",i&&s.classList.add("lx-as-desktop"),e.forEach(function(e,n){var o=document.createElement("button");o.className="lx-as-item",o.textContent=e,o.style.color=t,o.addEventListener("click",function(){return u(n)}),s.appendChild(o)});var c=document.createElement("div");c.className="lx-as-separator",s.appendChild(c);var d=document.createElement("button");function u(e){r||(r=!0,a.classList.remove("lx-as-visible"),l.classList.remove("lx-as-visible"),setTimeout(function(){a.remove(),l.remove(),o({tapIndex:e})},300))}d.className="lx-as-item lx-as-cancel-btn",d.textContent=n,d.addEventListener("click",function(){return u(-1)}),s.appendChild(d),l.appendChild(s),document.body.appendChild(a),document.body.appendChild(l),requestAnimationFrame(function(){a.classList.add("lx-as-visible"),l.classList.add("lx-as-visible")}),a.addEventListener("click",function(){return u(-1)})})}var dn=200,un="lx-modal-style",fn=null;function mn(e){var n,t,o,r,i,a,l=e,s=null!==(n=null==l?void 0:l.title)&&void 0!==n?n:"",c=null!==(t=null==l?void 0:l.content)&&void 0!==t?t:"",d=null===(o=null==l?void 0:l.showCancel)||void 0===o||o,u=null!==(r=null==l?void 0:l.cancelText)&&void 0!==r?r:"Cancel",f=null==l?void 0:l.cancelColor,m=null!==(i=null==l?void 0:l.confirmText)&&void 0!==i?i:"OK",v=null!==(a=null==l?void 0:l.confirmColor)&&void 0!==a?a:"#007AFF",p=(null!=fn?fn:Promise.resolve()).then(function(){return vn(s,c,d,u,f,m,v)},function(){return vn(s,c,d,u,f,m,v)});return fn=p,p}function vn(e,n,t,o,r,i,a){return new Promise(function(l){var s=!1;!function(){if(!document.getElementById(un)){var e=document.createElement("style");e.id=un,e.textContent="\n.lx-modal-backdrop {\n position: fixed; inset: 0; z-index: 99999;\n background: rgba(0,0,0,0.4);\n opacity: 0; transition: opacity ".concat(dn,"ms ease;\n display: flex; align-items: center; justify-content: center;\n}\n.lx-modal-backdrop.lx-modal-visible { opacity: 1; }\n\n.lx-modal-dialog {\n width: min(92vw, 320px);\n background: #fff;\n border-radius: 14px;\n overflow: hidden;\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n -webkit-font-smoothing: antialiased;\n transform: scale(0.95); opacity: 0;\n transition: transform ").concat(dn,"ms ease, opacity ").concat(dn,"ms ease;\n}\n.lx-modal-backdrop.lx-modal-visible .lx-modal-dialog {\n transform: scale(1); opacity: 1;\n}\n\n.lx-modal-body {\n padding: 24px 20px 16px;\n text-align: center;\n}\n.lx-modal-title {\n margin: 0 0 8px;\n font-size: 17px;\n font-weight: 600;\n color: #000;\n line-height: 1.35;\n}\n.lx-modal-content {\n margin: 0;\n font-size: 14px;\n color: #666;\n line-height: 1.5;\n word-break: break-word;\n}\n.lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n font-size: 17px;\n font-weight: 600;\n color: #000;\n}\n\n.lx-modal-footer {\n display: flex;\n border-top: 1px solid #E0E0E0;\n}\n.lx-modal-btn {\n flex: 1;\n height: 44px;\n line-height: 44px;\n padding: 0;\n border: none;\n background: none;\n font-size: 17px;\n text-align: center;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n.lx-modal-btn:active { background: rgba(0,0,0,0.06); }\n.lx-modal-btn + .lx-modal-btn {\n border-left: 1px solid #E0E0E0;\n}\n.lx-modal-btn-cancel {\n color: #666;\n font-weight: 400;\n}\n.lx-modal-btn-confirm {\n font-weight: 600;\n}\n\n@media (prefers-color-scheme: dark) {\n .lx-modal-dialog { background: #2c2c2e; }\n .lx-modal-title { color: #f5f5f7; }\n .lx-modal-content { color: #ababab; }\n .lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {\n color: #f5f5f7;\n }\n .lx-modal-footer { border-top-color: #3a3a3c; }\n .lx-modal-btn:active { background: rgba(255,255,255,0.08); }\n .lx-modal-btn + .lx-modal-btn { border-left-color: #3a3a3c; }\n .lx-modal-btn-cancel { color: #ababab; }\n}\n"),document.head.appendChild(e)}}();var c=document.createElement("div");c.className="lx-modal-backdrop";var d=document.createElement("div");d.className="lx-modal-dialog";var u=document.createElement("div");u.className="lx-modal-body";var f=document.createElement("div");if(f.className="lx-modal-title",f.textContent=e,u.appendChild(f),n){var m=document.createElement("p");m.className="lx-modal-content",m.textContent=n,u.appendChild(m)}d.appendChild(u);var v=document.createElement("div");if(v.className="lx-modal-footer",t){var p=document.createElement("button");p.className="lx-modal-btn lx-modal-btn-cancel",p.textContent=o,r&&(p.style.color=r),p.addEventListener("click",function(){return g(!1)}),v.appendChild(p)}var h=document.createElement("button");function g(e){s||(s=!0,c.classList.remove("lx-modal-visible"),setTimeout(function(){c.remove(),l({confirm:e,cancel:!e})},dn))}h.className="lx-modal-btn lx-modal-btn-confirm",h.textContent=i,h.style.color=a,h.addEventListener("click",function(){return g(!0)}),v.appendChild(h),d.appendChild(v),c.appendChild(d),document.body.appendChild(c),requestAnimationFrame(function(){c.classList.add("lx-modal-visible")})})}var pn="lx-toast-style",hn=null;function gn(e){var n,t,o,r,i,a=e,l=null!==(n=null==a?void 0:a.title)&&void 0!==n?n:"",s=null!==(t=null==a?void 0:a.icon)&&void 0!==t?t:"none",c=null!==(o=null==a?void 0:a.duration)&&void 0!==o?o:1500,d=null!==(r=null==a?void 0:a.mask)&&void 0!==r&&r,u=null!==(i=null==a?void 0:a.position)&&void 0!==i?i:"center";hn&&(hn.dismiss(),hn=null),function(){if(!document.getElementById(pn)){var e=document.createElement("style");e.id=pn,e.textContent="\n.lx-toast-mask {\n position: fixed; inset: 0; z-index: 99998;\n}\n.lx-toast-container {\n position: fixed; left: 0; right: 0; z-index: 99999;\n display: flex; justify-content: center;\n pointer-events: none;\n}\n.lx-toast-container.lx-toast-top { top: 0; padding-top: 80px; }\n.lx-toast-container.lx-toast-center { top: 0; bottom: 0; align-items: center; }\n.lx-toast-container.lx-toast-bottom { bottom: 0; padding-bottom: 80px; }\n\n.lx-toast-box {\n display: flex; flex-direction: column; align-items: center; gap: 10px;\n min-width: 120px; max-width: 280px;\n padding: 20px;\n background: rgba(0,0,0,0.8);\n border-radius: 12px;\n color: #fff;\n pointer-events: auto;\n transform: scale(0.8); opacity: 0;\n transition: transform ".concat(200,"ms ease, opacity ").concat(200,"ms ease;\n}\n.lx-toast-box.lx-toast-no-icon {\n min-width: auto; min-height: auto;\n padding: 12px 20px;\n}\n.lx-toast-box.lx-toast-visible {\n transform: scale(1); opacity: 1;\n}\n.lx-toast-icon {\n width: 36px; height: 36px;\n color: #fff;\n line-height: 0;\n}\n.lx-toast-title {\n font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;\n font-size: 16px; font-weight: 500;\n text-align: center;\n line-height: 1.4;\n word-break: break-word;\n -webkit-font-smoothing: antialiased;\n}\n"),document.head.appendChild(e)}}();var f=null;d&&((f=document.createElement("div")).className="lx-toast-mask",document.body.appendChild(f));var m=document.createElement("div");m.className="lx-toast-container","top"===u?m.classList.add("lx-toast-top"):"bottom"===u?m.classList.add("lx-toast-bottom"):m.classList.add("lx-toast-center");var v=document.createElement("div");v.className="lx-toast-box";var p="none"!==s;if(p||v.classList.add("lx-toast-no-icon"),p){var h=document.createElement("div");h.className="lx-toast-icon","success"===s?h.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M11 18l5 5 9-9" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>':"error"===s?h.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="17" stroke="currentColor" stroke-width="2"/><path d="M13 13l10 10M23 13l-10 10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>':"loading"===s&&(h.innerHTML='<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 4a14 14 0 0 1 14 14" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.8s" repeatCount="indefinite"/></path></svg>'),v.appendChild(h)}var g=document.createElement("div");g.className="lx-toast-title",g.textContent=l,v.appendChild(g),m.appendChild(v),document.body.appendChild(m),requestAnimationFrame(function(){v.classList.add("lx-toast-visible")});var y=!1;function w(){y||(y=!0,(null==hn?void 0:hn.dismiss)===w&&(hn=null),v.classList.remove("lx-toast-visible"),x&&clearTimeout(x),setTimeout(function(){m.remove(),null==f||f.remove()},200))}var x=null;return c>0&&(x=setTimeout(w,c)),hn={dismiss:w,timer:x},Promise.resolve()}function yn(){return hn&&(hn.dismiss(),hn=null),Promise.resolve()}return"all"!==__LX_RUNTIME_PLATFORM__&&"desktop"!==__LX_RUNTIME_PLATFORM__||(pe("ui.showActionSheet",sn),pe("ui.showModal",mn),pe("ui.showToast",gn),pe("ui.hideToast",yn)),rn(),e.LingXiaBridge=Je,e.boot=function(){Ke(),on()},e.bootWhenReady=rn,e.channel=function(e,n,t){return Je.channel(e,n,t)},e.getErrorInfo=nn,e.hasError=en,e.initBridge=Ke,e.invoke=function(e,n,t){return Je.invoke(e,n,t)},e.isNativeError=function(e,n){if(!e||"object"!=typeof e)return!1;var t=e;return"string"==typeof t.code&&""!==t.code.trim()&&("string"==typeof t.message&&(void 0===n||t.code===n))},e.notify=function(e,n,t){We.notify(Ye(e),n,Ve(t))},e.renderErrorUI=Ze,e.stream=function(e,n,t){return $e(We.stream(Ye(e),n,Ve(t)))},e}({});
@@ -11,11 +11,31 @@ const LOG_PREFIX = "[LX.Bridge]";
11
11
  const MESSAGE_PORT_TYPE = "messageport";
12
12
  const JS_INTERFACE_TYPE = "jsinterface";
13
13
  const OUTBOX_LIMIT = 256;
14
- const APPLE_DOWNSTREAM_URL = "lx-apple://bridge/downstream";
14
+ const APPLE_DOWNSTREAM_URL = BRIDGE_CONFIG.appleDownstreamURL;
15
15
  const APPLE_RECONNECT_BASE_MS = 200;
16
16
  const APPLE_RECONNECT_MAX_MS = 2000;
17
17
  const debugFlags = { data: false, proto: false, all: false };
18
18
  const earlyNativeMessages = [];
19
+ // Plain-object equivalent of `new Proxy(debugFlags, ...)`. Avoids referencing
20
+ // the `Proxy` global so the module loads on older WebViews (Android 5.x stock
21
+ // WebView is Chromium 37–39, which predates Chromium 49's Proxy support).
22
+ function createDebugObject(flags) {
23
+ const target = {};
24
+ Object.keys(flags).forEach((key) => {
25
+ Object.defineProperty(target, key, {
26
+ enumerable: true,
27
+ configurable: false,
28
+ get() {
29
+ return flags[key];
30
+ },
31
+ set(value) {
32
+ flags[key] = !!value;
33
+ console.log(`[LX] ${key}: ${value}`);
34
+ },
35
+ });
36
+ });
37
+ return target;
38
+ }
19
39
  function installEarlyReceiver() {
20
40
  if (typeof window === "undefined")
21
41
  return;
@@ -184,22 +204,17 @@ function processAppleDownstreamBuffer(buffer) {
184
204
  return remaining;
185
205
  }
186
206
  async function runAppleDownstream() {
207
+ if (!APPLE_DOWNSTREAM_URL) {
208
+ throw new Error("Apple downstream URL is not configured");
209
+ }
187
210
  const controller = new AbortController();
188
211
  appleDownstreamAbortController = controller;
189
- let response;
190
- try {
191
- response = await fetch(APPLE_DOWNSTREAM_URL, {
192
- method: "GET",
193
- cache: "no-store",
194
- headers: { Accept: "application/x-ndjson" },
195
- signal: controller.signal,
196
- });
197
- }
198
- catch (e) {
199
- if (controller.signal.aborted)
200
- return;
201
- throw e;
202
- }
212
+ const response = await fetch(APPLE_DOWNSTREAM_URL, {
213
+ method: "GET",
214
+ cache: "no-store",
215
+ headers: { Accept: "application/x-ndjson" },
216
+ signal: controller.signal,
217
+ });
203
218
  if (!response.ok) {
204
219
  throw new Error(`Apple downstream HTTP ${response.status}`);
205
220
  }
@@ -233,6 +248,11 @@ async function runAppleDownstream() {
233
248
  }
234
249
  }
235
250
  }
251
+ catch (e) {
252
+ if (controller.signal.aborted)
253
+ return;
254
+ throw e;
255
+ }
236
256
  finally {
237
257
  try {
238
258
  reader.releaseLock();
@@ -1411,19 +1431,7 @@ export const LingXiaBridge = {
1411
1431
  error("Parse error:", e);
1412
1432
  }
1413
1433
  },
1414
- debug: new Proxy(debugFlags, {
1415
- get(target, prop) {
1416
- return target[prop];
1417
- },
1418
- set(target, prop, value) {
1419
- if (prop in target) {
1420
- target[prop] = !!value;
1421
- console.log(`[LX] ${prop}: ${value}`);
1422
- return true;
1423
- }
1424
- return false;
1425
- },
1426
- }),
1434
+ debug: createDebugObject(debugFlags),
1427
1435
  platform: {
1428
1436
  isHarmony,
1429
1437
  isIOS,
@@ -94,11 +94,31 @@ var LOG_PREFIX = "[LX.Bridge]";
94
94
  var MESSAGE_PORT_TYPE = "messageport";
95
95
  var JS_INTERFACE_TYPE = "jsinterface";
96
96
  var OUTBOX_LIMIT = 256;
97
- var APPLE_DOWNSTREAM_URL = "lx-apple://bridge/downstream";
97
+ var APPLE_DOWNSTREAM_URL = BRIDGE_CONFIG.appleDownstreamURL;
98
98
  var APPLE_RECONNECT_BASE_MS = 200;
99
99
  var APPLE_RECONNECT_MAX_MS = 2000;
100
100
  var debugFlags = { data: false, proto: false, all: false };
101
101
  var earlyNativeMessages = [];
102
+ // Plain-object equivalent of `new Proxy(debugFlags, ...)`. Avoids referencing
103
+ // the `Proxy` global so the module loads on older WebViews (Android 5.x stock
104
+ // WebView is Chromium 37–39, which predates Chromium 49's Proxy support).
105
+ function createDebugObject(flags) {
106
+ var target = {};
107
+ Object.keys(flags).forEach(function (key) {
108
+ Object.defineProperty(target, key, {
109
+ enumerable: true,
110
+ configurable: false,
111
+ get: function () {
112
+ return flags[key];
113
+ },
114
+ set: function (value) {
115
+ flags[key] = !!value;
116
+ console.log("[LX] ".concat(key, ": ").concat(value));
117
+ },
118
+ });
119
+ });
120
+ return target;
121
+ }
102
122
  function installEarlyReceiver() {
103
123
  if (typeof window === "undefined")
104
124
  return;
@@ -324,30 +344,23 @@ function processAppleDownstreamBuffer(buffer) {
324
344
  }
325
345
  function runAppleDownstream() {
326
346
  return __awaiter(this, void 0, void 0, function () {
327
- var controller, response, e_5, reader, decoder, buffered, _a, value, done, tail;
347
+ var controller, response, reader, decoder, buffered, _a, value, done, tail, e_5;
328
348
  return __generator(this, function (_b) {
329
349
  switch (_b.label) {
330
350
  case 0:
351
+ if (!APPLE_DOWNSTREAM_URL) {
352
+ throw new Error("Apple downstream URL is not configured");
353
+ }
331
354
  controller = new AbortController();
332
355
  appleDownstreamAbortController = controller;
333
- _b.label = 1;
334
- case 1:
335
- _b.trys.push([1, 3, , 4]);
336
356
  return [4 /*yield*/, fetch(APPLE_DOWNSTREAM_URL, {
337
357
  method: "GET",
338
358
  cache: "no-store",
339
359
  headers: { Accept: "application/x-ndjson" },
340
360
  signal: controller.signal,
341
361
  })];
342
- case 2:
362
+ case 1:
343
363
  response = _b.sent();
344
- return [3 /*break*/, 4];
345
- case 3:
346
- e_5 = _b.sent();
347
- if (controller.signal.aborted)
348
- return [2 /*return*/];
349
- throw e_5;
350
- case 4:
351
364
  if (!response.ok) {
352
365
  throw new Error("Apple downstream HTTP ".concat(response.status));
353
366
  }
@@ -362,21 +375,21 @@ function runAppleDownstream() {
362
375
  reader = response.body.getReader();
363
376
  decoder = new TextDecoder();
364
377
  buffered = "";
365
- _b.label = 5;
366
- case 5:
367
- _b.trys.push([5, , 9, 10]);
368
- _b.label = 6;
369
- case 6:
370
- if (!true) return [3 /*break*/, 8];
378
+ _b.label = 2;
379
+ case 2:
380
+ _b.trys.push([2, 6, 7, 8]);
381
+ _b.label = 3;
382
+ case 3:
383
+ if (!true) return [3 /*break*/, 5];
371
384
  return [4 /*yield*/, reader.read()];
372
- case 7:
385
+ case 4:
373
386
  _a = _b.sent(), value = _a.value, done = _a.done;
374
387
  if (done)
375
- return [3 /*break*/, 8];
388
+ return [3 /*break*/, 5];
376
389
  buffered += decoder.decode(value, { stream: true });
377
390
  buffered = processAppleDownstreamBuffer(buffered);
378
- return [3 /*break*/, 6];
379
- case 8:
391
+ return [3 /*break*/, 3];
392
+ case 5:
380
393
  buffered += decoder.decode();
381
394
  tail = buffered.trim();
382
395
  if (tail) {
@@ -387,14 +400,19 @@ function runAppleDownstream() {
387
400
  warn("Apple downstream trailing parse error:", e, tail);
388
401
  }
389
402
  }
390
- return [3 /*break*/, 10];
391
- case 9:
403
+ return [3 /*break*/, 8];
404
+ case 6:
405
+ e_5 = _b.sent();
406
+ if (controller.signal.aborted)
407
+ return [2 /*return*/];
408
+ throw e_5;
409
+ case 7:
392
410
  try {
393
411
  reader.releaseLock();
394
412
  }
395
413
  catch (_c) { }
396
414
  return [7 /*endfinally*/];
397
- case 10: return [2 /*return*/];
415
+ case 8: return [2 /*return*/];
398
416
  }
399
417
  });
400
418
  });
@@ -1696,19 +1714,7 @@ export var LingXiaBridge = {
1696
1714
  error("Parse error:", e);
1697
1715
  }
1698
1716
  },
1699
- debug: new Proxy(debugFlags, {
1700
- get: function (target, prop) {
1701
- return target[prop];
1702
- },
1703
- set: function (target, prop, value) {
1704
- if (prop in target) {
1705
- target[prop] = !!value;
1706
- console.log("[LX] ".concat(prop, ": ").concat(value));
1707
- return true;
1708
- }
1709
- return false;
1710
- },
1711
- }),
1717
+ debug: createDebugObject(debugFlags),
1712
1718
  platform: {
1713
1719
  isHarmony: isHarmony,
1714
1720
  isIOS: isIOS,
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export interface BridgeConfig {
2
2
  os?: 'Harmony' | 'iOS' | 'Android' | 'macOS';
3
3
  nonce?: string;
4
+ appleDownstreamURL?: string;
4
5
  }
5
6
  export interface RuntimeConfig {
6
7
  error?: ErrorInfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxia/bridge",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "private": false,
5
5
  "description": "LingXia Web Runtime - Bridge, boot, and error handling for WebView",
6
6
  "type": "module",