clipoox-render 0.4.6 → 0.4.8
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.
- package/package.json +2 -2
- package/scripts/render-local.mjs +2656 -1672
- package/shared/photocraft/LICENSE.txt +206 -0
- package/shared/photocraft/clipoox_photo.js +396 -0
- package/shared/photocraft/clipoox_photo_bg.wasm +0 -0
- package/web/assets/{FxEmbed-ROS6C_HI.js → FxEmbed-adbxHEBi.js} +1 -1
- package/web/assets/ImageStudio-CMxiT1jp.js +3 -0
- package/web/assets/ImageStudio-De_DCTrz.css +1 -0
- package/web/assets/{MotionEmbed-E2hCysi-.js → MotionEmbed-CDUIyjk0.js} +1 -1
- package/web/assets/{PluginStore-CwUSpwPp.js → PluginStore-By_pdOOg.js} +2 -2
- package/web/assets/ShotComposer-DcwWZ-eP.css +1 -0
- package/web/assets/ShotComposer-XIbJ4nNm.js +287 -0
- package/web/assets/{TemplateEmbed-qG1AXdtf.js → TemplateEmbed-a01nKECT.js} +1 -1
- package/web/assets/{TimelinePlugins-CB1b6-Cb.js → TimelinePlugins-CqLMVjuh.js} +4 -4
- package/web/assets/TimelineShotFx-QmkyCg31.js +2 -0
- package/web/assets/{TransitionEmbed-Dym9P7--.js → TransitionEmbed-Cbwlxfl2.js} +1 -1
- package/web/assets/{Whiteboard-BdGjJZXW.js → Whiteboard-ChYqIr3v.js} +1 -1
- package/web/assets/{aerial-yLD_gDzw.js → aerial-CZeCeacv.js} +2 -2
- package/web/assets/{agentTools-B7g6tXTR.js → agentTools-DW2ETnxE.js} +2 -2
- package/web/assets/{aiInbetween-6eKDYbYS.js → aiInbetween-De98iM4m.js} +2 -2
- package/web/assets/analyzerRun-D5-g-Vxe.js +1 -0
- package/web/assets/{analyzerSandbox-N92T6amg.js → analyzerSandbox-E3CdovIk.js} +1 -1
- package/web/assets/{api-Dnl2uaKO.js → api-CZoVJ9Fy.js} +87 -87
- package/web/assets/auraTrack-ClhHuqlf.js +1 -0
- package/web/assets/{breakthrough-DSiuVwEX.js → breakthrough-DTpiUIZd.js} +2 -2
- package/web/assets/{cameraPresets-Cfn7qhXK.js → cameraPresets-DD0WmxiI.js} +1 -1
- package/web/assets/{cameraTracker-DHdF8Zqx.js → cameraTracker-Df9jWmz6.js} +2 -2
- package/web/assets/{captionLayout-cckQ7p-t.js → captionLayout-eiu9QPJu.js} +1 -1
- package/web/assets/{clientExport-pkLbOmEF.js → clientExport-BXegTdNc.js} +1 -1
- package/web/assets/{clientJobs-CcsLDqFM.js → clientJobs-eB-lNyin.js} +2 -2
- package/web/assets/clipoox_photo_bg-BQ0aVNY0.wasm +0 -0
- package/web/assets/depthEstimate-CfwX-tXP.js +1 -0
- package/web/assets/{directorTools-DMsatulF.js → directorTools-ABbI8m0e.js} +1 -1
- package/web/assets/distortFrames-DMnZ8OYh.js +2 -0
- package/web/assets/distortGL-DQu0Df2c.js +18 -0
- package/web/assets/{domino-DBrinEUu.js → domino-trmDBvfH.js} +1 -1
- package/web/assets/{editTools-BNnAvCw-.js → editTools-DEFo9Ahv.js} +1 -1
- package/web/assets/{engine-Co-ivzlQ.js → engine-Y-GotDIy.js} +1 -1
- package/web/assets/exportGlb-BeLpJKJT.js +2 -0
- package/web/assets/{faceTracker-ClR-lS6Y.js → faceTracker-BeSFnLM8.js} +1 -1
- package/web/assets/{fightDirector-BlpVAURl.js → fightDirector-Dfz3vu5-.js} +1 -1
- package/web/assets/{fightDrama-BK0QidpM.js → fightDrama-CNVn69s0.js} +2 -2
- package/web/assets/{focusTool-sVOb2GGS.js → focusTool-Dd2UDkiO.js} +1 -1
- package/web/assets/{frameSink-CSRqCnwI.js → frameSink-Rj02YES5.js} +3 -3
- package/web/assets/{glTransitionSources.generated-q0H-ZbnZ.js → glTransitionSources.generated-Cs8lVRqs.js} +438 -2
- package/web/assets/{gpuCompose-B5bgbHdQ.js → gpuCompose-DkkKH1Ab.js} +1 -1
- package/web/assets/gpuExport-DwrXpVGF.js +199 -0
- package/web/assets/{handMatte-Dj2taFoC.js → handMatte-B5sUeqKi.js} +1 -1
- package/web/assets/{handTracker-c6_rvuwA.js → handTracker-CQV-D7va.js} +2 -2
- package/web/assets/i18n-ClNt3LKg.js +3 -0
- package/web/assets/{index-Ds_8isyf.js → index-D2u6mD-8.js} +1 -1
- package/web/assets/layer-worker-DP0N05Ua.js +5 -0
- package/web/assets/library-cb43ZEmy.js +1 -0
- package/web/assets/{lottieLayer-Cv8ub9f6.js → lottieLayer-DEw0c3to.js} +4 -4
- package/web/assets/main-C_XcvNyC.js +311 -0
- package/web/assets/{main-B_MAOvi6.css → main-DlzdW5C4.css} +1 -1
- package/web/assets/{mapBake-DtQboFIX.js → mapBake-BUWz0cSx.js} +1 -1
- package/web/assets/maskTrack-GYpJyKFw.js +1 -0
- package/web/assets/matteFixRun-BCVsuSxf.js +1 -0
- package/web/assets/{objectLocate-XuAcemlO.js → objectLocate-CjIlo_u0.js} +1 -1
- package/web/assets/{objectSegmenter-D66spD7o.js → objectSegmenter-C4T9qgUL.js} +1 -1
- package/web/assets/{objectTrack.worker-BZS6WZ6l.js → objectTrack.worker-BVvsDmR0.js} +1450 -908
- package/web/assets/{pathTracer-DykgPkkh.js → pathTracer-DgL1_83l.js} +2 -2
- package/web/assets/{pendingMatte-BWBIWajI.js → pendingMatte-DPTe6xoZ.js} +2 -2
- package/web/assets/peopleMatte-C1hruEM6.js +1 -0
- package/web/assets/{personAi-EhBknW6X.js → personAi-Cjg9KKeH.js} +2 -2
- package/web/assets/{personHq-Ca351o06.js → personHq-CBP8v_cw.js} +2 -2
- package/web/assets/photo.worker-DK_ulTzR.js +1 -0
- package/web/assets/photoRun-lZ2BdSEk.js +2 -0
- package/web/assets/photoTools-DmUh69Qk.js +1 -0
- package/web/assets/plateCamera-DLqlXhMp.js +1 -0
- package/web/assets/{plateCameraMatch-GPZl1fQQ.js → plateCameraMatch-4VUlUMi-.js} +2 -2
- package/web/assets/{plateFollow-CJUilsNV.js → plateFollow-D2rjnmZA.js} +2 -2
- package/web/assets/plateMatte-0tTG7oeO.js +2 -0
- package/web/assets/{pluginAutomation-DAPHWZPN.js → pluginAutomation-ClFdpcCR.js} +1 -1
- package/web/assets/popTools-B38V4wub.js +1 -0
- package/web/assets/{poseTracker-CzEKvJph.js → poseTracker-qtuytI-L.js} +1 -1
- package/web/assets/{productTools-ce-zyZO0.js → productTools-DlC5vWjx.js} +2 -2
- package/web/assets/remote-CpkPQOQH.js +989 -0
- package/web/assets/{rigTrack-DMyqb0pb.js → rigTrack-BbKqZGs7.js} +1 -1
- package/web/assets/{rotoMaskStore-pE1AIt3I.js → rotoMaskStore-BZBJLcCp.js} +1 -1
- package/web/assets/{rotoMatte-7b7Ow64f.js → rotoMatte-BI-vjjrv.js} +1 -1
- package/web/assets/rotoscope-DuNcCxQy.js +1 -0
- package/web/assets/{sceneTrack-DlAH5s74.js → sceneTrack-CO4fTjft.js} +1 -1
- package/web/assets/{sceneTrack-CA21MCOP.js → sceneTrack-_n6WKKQv.js} +1 -1
- package/web/assets/{sceneTrack.worker-COlhlHRe.js → sceneTrack.worker-f2d-WOzw.js} +1496 -954
- package/web/assets/{shot-worker-DL1ZoIym.js → shot-worker-BSmfIXHO.js} +1 -1
- package/web/assets/{shotFxAgent-DqngnGFb.js → shotFxAgent-L2GG88W3.js} +1 -1
- package/web/assets/{skin-xFScwS3T.js → skin-CirUiqcr.js} +1 -1
- package/web/assets/{spark.module-DjaIF6J1.js → spark.module-3Q8DniuL.js} +1 -1
- package/web/assets/{spellDuel-BYNtnE8f.js → spellDuel-2CDLbiLQ.js} +2 -2
- package/web/assets/{store-CpqHUcA2.js → store-D3Y663py.js} +1 -1
- package/web/assets/{surfaceLight-C7YI9SV8.js → surfaceLight--HQj7xhO.js} +1 -1
- package/web/assets/{surfacePin-CzpUj1Cw.js → surfacePin-BCmgw-40.js} +2 -2
- package/web/assets/{textAnimators-B9vO_hbP.js → textAnimators-C4eMnVRD.js} +1 -1
- package/web/assets/{thumb-BTFsBS1u.js → thumb-M9B_goj-.js} +1 -1
- package/web/assets/{timeline3d-DrFaMPPB.js → timeline3d-BcW68fQr.js} +2 -2
- package/web/assets/{timeline3dExport-Uo0S0CR0.js → timeline3dExport-DgnorHLm.js} +1 -1
- package/web/assets/timelineComp-Ciu9JCWJ.js +1 -0
- package/web/assets/timelineOps-f1WsVbgS.js +526 -0
- package/web/assets/{timelineProps-0v-s69pw.js → timelineProps-CE1R11Hx.js} +1 -1
- package/web/assets/{timelineText-DurRhyuh.js → timelineText-Cppd4KB7.js} +1 -1
- package/web/assets/{titleArt-CnC0A7x7.js → titleArt-D0YI5xT2.js} +3 -3
- package/web/assets/{titleFrameBudget-DsM0V482.js → titleFrameBudget-h4nOQ5u9.js} +1717 -1175
- package/web/assets/titleFrames-DnCzi_AI.js +1 -0
- package/web/assets/{tool-D1FpErrX.js → tool-tp6gat1J.js} +1 -1
- package/web/assets/{tools-DIvrRu-5.js → tools-C07G9KUM.js} +1 -1
- package/web/assets/{toonTools-D9MNdRty.js → toonTools-Cazx2CL7.js} +2 -2
- package/web/assets/{trackAnchor-XvUuvkWP.js → trackAnchor-DoqFDcJB.js} +1 -1
- package/web/assets/{userFonts-Djka6RJX.js → userFonts-BlVEJfDk.js} +1 -1
- package/web/assets/{vfxAlpha-B-JzzRI1.js → vfxAlpha-Bp6VgIGN.js} +1 -1
- package/web/assets/vfxBackground-BFq44Srn.js +2 -0
- package/web/assets/{videoExport-NN-QijHd.js → videoExport-Cz02XKtX.js} +1 -1
- package/web/assets/{views-RQBs4zva.js → views-CNF3Afse.js} +1 -1
- package/web/assets/{weaponDuel-DKAEYJjO.js → weaponDuel-ChqBQo_b.js} +1 -1
- package/web/assets/{windowFrames-DhhJLIs-.js → windowFrames-dBMXwGek.js} +1 -1
- package/web/layer-worker.html +3 -3
- package/web/shot-worker.html +24 -24
- package/web/assets/ShotComposer-DLxWpdYH.js +0 -287
- package/web/assets/ShotComposer-deLi4grZ.css +0 -1
- package/web/assets/TimelineShotFx-CyHTgJHj.js +0 -2
- package/web/assets/analyzerRun-Cr-_79RH.js +0 -1
- package/web/assets/auraTrack-C8eAEIWQ.js +0 -1
- package/web/assets/depthEstimate-Cav4MmQ1.js +0 -1
- package/web/assets/distortFrames-D_v-aSVO.js +0 -2
- package/web/assets/distortGL-vhnBRB59.js +0 -12
- package/web/assets/exportGlb-D3PrWUvi.js +0 -2
- package/web/assets/gpuExport-oA2mUsdm.js +0 -198
- package/web/assets/i18n-C9zFX25m.js +0 -3
- package/web/assets/layer-worker-ClVZG6ZW.js +0 -5
- package/web/assets/library-BK0QVG4O.js +0 -1
- package/web/assets/main-CwrkBJ63.js +0 -309
- package/web/assets/maskTrack-D4QZfMWc.js +0 -1
- package/web/assets/matteFixRun-CytaeRzS.js +0 -1
- package/web/assets/plateCamera-BcdXD1uI.js +0 -1
- package/web/assets/plateMatte-CoEoVjxZ.js +0 -2
- package/web/assets/remote-8XzEAnAJ.js +0 -974
- package/web/assets/rotoscope-BUqNTKLd.js +0 -1
- package/web/assets/timelineComp-i-zdaoB2.js +0 -1
- package/web/assets/timelineOps-DSSaDsU2.js +0 -525
- package/web/assets/titleFrames-C8kvflgT.js +0 -1
- package/web/assets/vfxBackground-b053ziDK.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/clientExport-
|
|
2
|
-
import{
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/clientExport-BXegTdNc.js","assets/titleFrameBudget-h4nOQ5u9.js","assets/timelineComp-Ciu9JCWJ.js","assets/gpuExport-DwrXpVGF.js","assets/glTransitionSources.generated-Cs8lVRqs.js","assets/gpuCompose-DkkKH1Ab.js","assets/motionBlur-uAm030t9.js","assets/distortGL-DQu0Df2c.js","assets/id3-arvEpAg7.js","assets/output-p-Q7qous.js","assets/i18n-ClNt3LKg.js","assets/index-CKtv7gGE.js","assets/timelineText-Cppd4KB7.js","assets/store-D3Y663py.js","assets/titleArt-D0YI5xT2.js","assets/textAnimators-C4eMnVRD.js","assets/frameSink-Rj02YES5.js","assets/distortFrames-DMnZ8OYh.js","assets/timeline3dExport-DgnorHLm.js","assets/timeline3d-BcW68fQr.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/titleFrames-DnCzi_AI.js","assets/lottieLayer-DEw0c3to.js","assets/rigTrack-BbKqZGs7.js","assets/rotoMatte-BI-vjjrv.js","assets/windowFrames-dBMXwGek.js","assets/rotoMaskStore-BZBJLcCp.js","assets/sceneTrack-CO4fTjft.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{nr as vd,ik as Ed,mW as Td,ns as wd,nt as Id,ih as Ad,b_ as Xt,_ as pe,nu as bd,hN as Rd,eW as Sd,eG as Fa,iJ as ja,f as Cd}from"./titleFrameBudget-h4nOQ5u9.js";import{g as Yn,t as De}from"./i18n-ClNt3LKg.js";import{r as Pd}from"./index-CKtv7gGE.js";const kd=["alpha","alpha-inverted","luma","luma-inverted","depth"],Yw=.04,Yi=.05,Zw=n=>n.mode.endsWith("-inverted"),eI=n=>new Set(n.filter(e=>e.matte&&!e.disabled).map(e=>e.matte.source));function Od(n){const e=new Map(n.map(r=>[r.id,r])),t=new Set;for(const r of n){if(r.matte===void 0)continue;const s=r.matte;if(!s||typeof s!="object"||Object.keys(s).some(a=>!["source","mode","feather","depth"].includes(a))||!kd.includes(s.mode)||typeof s.source!="string")throw Error("Invalid track matte");if(s.mode==="depth"!=(s.depth!==void 0)||s.depth!==void 0&&!(Number.isFinite(s.depth)&&s.depth>=0&&s.depth<=1))throw Error("Invalid track matte depth");if(s.feather!==void 0&&!(Number.isFinite(s.feather)&&s.feather>=0&&s.feather<=Yi))throw Error("Invalid track matte feather");const o=e.get(s.source);if(!o||o.id===r.id||r.kind==="audio"||o.kind==="audio"||o.nullLayer||o.adjust||r.adjust||r.nullLayer)throw Error("Invalid track matte source");if(o.matte)throw Error("A matte source cannot have its own track matte");if(t.has(o.id))throw Error("A layer can be the matte of only one layer");t.add(o.id)}}const tI=n=>+(Math.max(0,Math.min(1,n))*Yi).toFixed(5),nI=n=>+Math.max(0,Math.min(1,(n??0)/Yi)).toFixed(4),Ba=Object.freeze([["audioFx"],["audioTools"],["duck"],["muffle"],["captionWords","captionStyle"],["captions"],["bubble"],["layout"],["effects"],["distort"],["shadow"],["glow"],["sticker"],["edge"],["enter"],["exit"],["blend"],["motionBlur"],["grade"],["key"],["face"],["colorPerson"],["depthMap"],["roto"],["planar"],["pin"],["pendingPin"],["mask"],["person","personPending"],["revealType","reveal"],["visualFadeIn","visualFadeOut","fadeInColor","fadeOutColor"],["motionKeys"],["speedRamp"],["timeRemap"],["transition"],["join"],["matte"],["seam"]]),Ru={opacity:[0,1],volume:[0,1],brightness:[0,2],contrast:[0,2],visualFadeIn:[0,4],visualFadeOut:[0,4]};function Dd(n){let e=n;for(const[t,[r,s]]of Object.entries(Ru)){const o=n[t];o===void 0||Number.isFinite(o)&&o>=r&&o<=s||(e===n&&(e={...n}),Number.isFinite(o)?e[t]=Math.min(s,Math.max(r,o)):delete e[t])}return e}const $a=n=>{try{return Id(n),null}catch(e){return String(e?.message||e)}},Nd=(n,e)=>e.some(t=>n[t]!==void 0),Hr=(n,e)=>{const t={...n};for(const r of e)delete t[r];return t};function Vd(n){let e=$a(n);if(!e)return{clip:n,dropped:[],reason:null};const t=e;let r=n;const s=[];for(let o=0,a=!0;a&&o<Ba.length;o++){a=!1;for(const u of Ba){if(!Nd(r,u))continue;const l=Hr(r,u),d=$a(l);if(!d)return s.push(...u.filter(p=>r[p]!==void 0)),{clip:l,dropped:s,reason:t};if(d!==e){s.push(...u.filter(p=>r[p]!==void 0)),r=l,e=d,a=!0;break}}}return{clip:null,dropped:s,reason:t}}function Md(n){if(!Array.isArray(n))return{clips:n,fixes:[]};const e=[],t=(a,u,l)=>e.push({clipId:a.id,label:String(a.label??"").slice(0,60),start:a.start,track:a.track,dropped:u,reason:String(l||"").slice(0,160)});let s=vd(n).map((a,u)=>{if(!a||typeof a!="object")return a;const l=n[u];l&&(JSON.stringify(l.captions)!==JSON.stringify(a.captions)||JSON.stringify(l.captionWords)!==JSON.stringify(a.captionWords))&&t(a,["captions"],"subtitle cues overlapped or ran past the clip");const d=Dd(a);d!==a&&t(a,Object.keys(Ru).filter(v=>d[v]!==a[v]),"value out of range (clamped)");const p=Vd(d);return!p.clip||!p.dropped.length?d:(t(d,p.dropped,p.reason),p.clip)});const o=new Set(s.map(a=>a?.id));s=s.map(a=>{if(!a||typeof a!="object")return a;let u=a;if(u.parentId&&(!o.has(u.parentId)||Ed(s,u.id,u.parentId))&&(t(u,["parentId"],"parent layer missing or looping"),u=Hr(u,["parentId"])),u.transition!==void 0)try{Td(u,s)}catch(l){wd(s,u)||t(u,["transition"],l?.message),u=Hr(u,["transition"])}return u});for(let a=0;a<8;a++)try{Od(s);break}catch(u){const l=s.findIndex(d=>d?.matte!==void 0);if(l<0)break;t(s[l],["matte"],u?.message),s=s.map((d,p)=>p===l?Hr(d,["matte"]):d)}return{clips:s,fixes:e}}const xd=["mp3","wav","m4a","aac","flac","ogg","oga","opus","weba","aif","aiff"];function Ld(n){if(!n)return!1;if(typeof n.type=="string"&&n.type.startsWith("audio/"))return!0;if(typeof n.type=="string"&&n.type)return!1;const e=typeof n.name=="string"?n.name.split(".").pop().toLowerCase():"";return xd.includes(e)}let Ii=null,qa=Promise.resolve();const ns=new Set,za=()=>ns.forEach(n=>n());function Ud(n){const e=()=>new Promise(r=>{if(!ns.size)return r(!1);Ii={names:n,resolve:s=>{Ii=null,za(),r(s)}},za()}),t=qa.then(e,e);return qa=t,t}function rI(){return Pd.useSyncExternalStore(n=>(ns.add(n),()=>{ns.delete(n)}),()=>Ii,()=>null)}const Ha="application/vnd.clipoox.export-progress";new TextEncoder;function Fd(){let n=new Uint8Array(0),e=-1,t=!1;const r=new TextDecoder;return{push(s){const o=[];if(e>=0)return s.length&&o.push({type:"data",chunk:s}),e-=s.length,o;const a=new Uint8Array(n.length+s.length);a.set(n),a.set(s,n.length);let u=0;for(;;){const l=a.indexOf(10,u);if(l<0)break;const d=r.decode(a.subarray(u,l)),p=d[0],v=d.slice(2);if(u=l+1,p==="P"){const E=Number(v);Number.isFinite(E)&&o.push({type:"progress",value:Math.max(0,Math.min(1,E))})}else if(p==="R")try{o.push({type:"review",review:JSON.parse(decodeURIComponent(v))})}catch{o.push({type:"review",review:null})}else if(p==="T")try{o.push({type:"timings",timings:JSON.parse(decodeURIComponent(v))})}catch{}else if(p==="E"){let E={};try{E=JSON.parse(v)}catch{}o.push({type:"error",error:String(E.error||"Export failed"),status:Number(E.status)||500})}else if(p==="S"){let E={};try{E=JSON.parse(decodeURIComponent(v))}catch{}typeof E.gcsUri=="string"&&(t=!0,o.push({type:"stored",gcsUri:E.gcsUri,size:Number(E.size)||0}))}else if(p==="F"){e=Number(v)||0,o.push({type:"file",size:e});const E=a.subarray(u);return E.length&&o.push({type:"data",chunk:E}),e-=E.length,n=new Uint8Array(0),o}}return n=a.slice(u),o},get complete(){return e===0||t}}}async function jd(n){let e;try{e=await n.text()}catch(t){if(n.ok)throw Wa(t);return{}}if(!e)return{};try{return JSON.parse(e)}catch(t){if(n.ok&&/^\s*([{[]|$)/.test(e))throw Wa(t);return{}}}const Wa=n=>Object.assign(Error("reply lost"),{code:"reply_lost",cause:n}),Bd=600,sI=600,ui=n=>String(n).padStart(2,"0");function iI(n){const e=Math.max(0,Math.round(Number(n)||0)),t=Math.floor(e/3600),r=Math.floor(e/60)%60;return t?`${t}:${ui(r)}:${ui(e%60)}`:`${r}:${ui(e%60)}`}const rs="application/vnd.clipoox.analysis-progress+json";function Su(n,e){const t=Math.max(1,Number(e)||1),r=Math.max(0,Number(n)||0);return r<=t?.9*r/t:.9+.079*(1-Math.exp(-(r-t)/t))}const $d=30;function qd(n){const e=Number(n?.duration),t=Number.isFinite(e)&&e>0?Math.min(e,Bd):$d,r={id:"fetch",seconds:2+t*.03};if(n?.mode==="music")return[r,{id:"beats",seconds:2+t*.08}];if(n?.mode==="reference")return[r,{id:"rhythm",seconds:12+t*.25}];const s=t>600?3:1,o={id:"cuts",seconds:1+t*.08},a={id:"speech",seconds:4+t*.12/s};return n?.audioOnly?[r,o,a]:[r,o,{id:"scenes",seconds:(Math.ceil(t/120)*15+t*.15)/s},a]}function oI(n,e){const t=(n||[]).map(qd),r=t.flat().reduce((l,d)=>l+d.seconds,0)||1,s=Su(e,r);let o=Math.min(r,s/.9*r)-1e-9,a=0,u=t[0]?.[0]?.id||"fetch";e:for(const[l,d]of t.entries())for(const p of d){if(a=l,u=p.id,o<p.seconds)break e;o-=p.seconds}return{fraction:s,index:a,count:t.length,stage:u}}const Ga={video:{fetch:.03,cuts:.12,scenes:.7,speech:1},audio:{fetch:.03,cuts:.12,scenes:.12,speech:1}};function aI(n,e=!1){const t=e?Ga.audio:Ga.video,r=["fetch","cuts","scenes","speech"],s=r.indexOf(n?.stage);if(s<0)return 0;const o=s?t[r[s-1]]:0,a=t[r[s]],u=Number(n.total)>0?Math.min(1,Math.max(0,Number(n.done)||0)/Number(n.total)):0,l=Math.max(1,Number(n.count)||1),d=Math.min(l-1,Math.max(0,Number(n.index)||0));return Math.min(.99,(d+o+(a-o)*u)/l)}function cI(n,e=!0){const t=Math.round(Math.max(0,Math.min(1,Number(n)||0))*100);return e?Math.min(99,t):t}const zd=()=>{};var Ka={};/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
5
5
|
*
|
|
@@ -163,7 +163,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
163
163
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
164
164
|
* See the License for the specific language governing permissions and
|
|
165
165
|
* limitations under the License.
|
|
166
|
-
*/function
|
|
166
|
+
*/function Le(n){return n&&n._delegate?n._delegate:n}class $t{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/**
|
|
167
167
|
* @license
|
|
168
168
|
* Copyright 2019 Google LLC
|
|
169
169
|
*
|
|
@@ -223,7 +223,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
223
223
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
224
224
|
* See the License for the specific language governing permissions and
|
|
225
225
|
* limitations under the License.
|
|
226
|
-
*/var G;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(G||(G={}));const Af={debug:G.DEBUG,verbose:G.VERBOSE,info:G.INFO,warn:G.WARN,error:G.ERROR,silent:G.SILENT},bf=G.INFO,Rf={[G.DEBUG]:"log",[G.VERBOSE]:"log",[G.INFO]:"info",[G.WARN]:"warn",[G.ERROR]:"error"},Sf=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=Rf[e];if(s)console[s](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Zi{constructor(e){this.name=e,this._logLevel=bf,this._logHandler=Sf,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in G))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Af[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,G.DEBUG,...e),this._logHandler(this,G.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,G.VERBOSE,...e),this._logHandler(this,G.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,G.INFO,...e),this._logHandler(this,G.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,G.WARN,...e),this._logHandler(this,G.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,G.ERROR,...e),this._logHandler(this,G.ERROR,...e)}}const Cf=(n,e)=>e.some(t=>n instanceof t);let Xa,Ya;function Pf(){return Xa||(Xa=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function kf(){return Ya||(Ya=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const
|
|
226
|
+
*/var G;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(G||(G={}));const Af={debug:G.DEBUG,verbose:G.VERBOSE,info:G.INFO,warn:G.WARN,error:G.ERROR,silent:G.SILENT},bf=G.INFO,Rf={[G.DEBUG]:"log",[G.VERBOSE]:"log",[G.INFO]:"info",[G.WARN]:"warn",[G.ERROR]:"error"},Sf=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=Rf[e];if(s)console[s](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Zi{constructor(e){this.name=e,this._logLevel=bf,this._logHandler=Sf,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in G))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Af[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,G.DEBUG,...e),this._logHandler(this,G.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,G.VERBOSE,...e),this._logHandler(this,G.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,G.INFO,...e),this._logHandler(this,G.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,G.WARN,...e),this._logHandler(this,G.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,G.ERROR,...e),this._logHandler(this,G.ERROR,...e)}}const Cf=(n,e)=>e.some(t=>n instanceof t);let Xa,Ya;function Pf(){return Xa||(Xa=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function kf(){return Ya||(Ya=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const xu=new WeakMap,Ai=new WeakMap,Lu=new WeakMap,hi=new WeakMap,eo=new WeakMap;function Of(n){const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("success",o),n.removeEventListener("error",a)},o=()=>{t(_t(n.result)),s()},a=()=>{r(n.error),s()};n.addEventListener("success",o),n.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&xu.set(t,n)}).catch(()=>{}),eo.set(e,n),e}function Df(n){if(Ai.has(n))return;const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("complete",o),n.removeEventListener("error",a),n.removeEventListener("abort",a)},o=()=>{t(),s()},a=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",o),n.addEventListener("error",a),n.addEventListener("abort",a)});Ai.set(n,e)}let bi={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return Ai.get(n);if(e==="objectStoreNames")return n.objectStoreNames||Lu.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return _t(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Nf(n){bi=n(bi)}function Vf(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const r=n.call(di(this),e,...t);return Lu.set(r,e.sort?e.sort():[e]),_t(r)}:kf().includes(n)?function(...e){return n.apply(di(this),e),_t(xu.get(this))}:function(...e){return _t(n.apply(di(this),e))}}function Mf(n){return typeof n=="function"?Vf(n):(n instanceof IDBTransaction&&Df(n),Cf(n,Pf())?new Proxy(n,bi):n)}function _t(n){if(n instanceof IDBRequest)return Of(n);if(hi.has(n))return hi.get(n);const e=Mf(n);return e!==n&&(hi.set(n,e),eo.set(e,n)),e}const di=n=>eo.get(n);function xf(n,e,{blocked:t,upgrade:r,blocking:s,terminated:o}={}){const a=indexedDB.open(n,e),u=_t(a);return r&&a.addEventListener("upgradeneeded",l=>{r(_t(a.result),l.oldVersion,l.newVersion,_t(a.transaction),l)}),t&&a.addEventListener("blocked",l=>t(l.oldVersion,l.newVersion,l)),u.then(l=>{o&&l.addEventListener("close",()=>o()),s&&l.addEventListener("versionchange",d=>s(d.oldVersion,d.newVersion,d))}).catch(()=>{}),u}const Lf=["get","getKey","getAll","getAllKeys","count"],Uf=["put","add","delete","clear"],fi=new Map;function Za(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(fi.get(e))return fi.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,s=Uf.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(s||Lf.includes(t)))return;const o=async function(a,...u){const l=this.transaction(a,s?"readwrite":"readonly");let d=l.store;return r&&(d=d.index(u.shift())),(await Promise.all([d[t](...u),s&&l.done]))[0]};return fi.set(e,o),o}Nf(n=>({...n,get:(e,t,r)=>Za(e,t)||n.get(e,t,r),has:(e,t)=>!!Za(e,t)||n.has(e,t)}));/**
|
|
227
227
|
* @license
|
|
228
228
|
* Copyright 2019 Google LLC
|
|
229
229
|
*
|
|
@@ -343,7 +343,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
343
343
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
344
344
|
* See the License for the specific language governing permissions and
|
|
345
345
|
* limitations under the License.
|
|
346
|
-
*/const vp="firebase-heartbeat-database",Ep=1,er="firebase-heartbeat-store";let pi=null;function ju(){return pi||(pi=
|
|
346
|
+
*/const vp="firebase-heartbeat-database",Ep=1,er="firebase-heartbeat-store";let pi=null;function ju(){return pi||(pi=xf(vp,Ep,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(er)}catch(t){console.warn(t)}}}}).catch(n=>{throw yt.create("idb-open",{originalErrorMessage:n.message})})),pi}async function Tp(n){try{const t=(await ju()).transaction(er),r=await t.objectStore(er).get(Bu(n));return await t.done,r}catch(e){if(e instanceof st)et.warn(e.message);else{const t=yt.create("idb-get",{originalErrorMessage:e?.message});et.warn(t.message)}}}async function nc(n,e){try{const r=(await ju()).transaction(er,"readwrite");await r.objectStore(er).put(e,Bu(n)),await r.done}catch(t){if(t instanceof st)et.warn(t.message);else{const r=yt.create("idb-set",{originalErrorMessage:t?.message});et.warn(r.message)}}}function Bu(n){return`${n.name}!${n.options.appId}`}/**
|
|
347
347
|
* @license
|
|
348
348
|
* Copyright 2021 Google LLC
|
|
349
349
|
*
|
|
@@ -418,7 +418,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
418
418
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
419
419
|
* See the License for the specific language governing permissions and
|
|
420
420
|
* limitations under the License.
|
|
421
|
-
*/function Ne(n,...e){throw so(n,...e)}function
|
|
421
|
+
*/function Ne(n,...e){throw so(n,...e)}function xe(n,...e){return so(n,...e)}function ro(n,e,t){const r=Object.assign(Object.assign({},Op()),{[e]:t});return new cr("auth","Firebase",r).create(e,{appName:n.name})}function $e(n){return ro(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function zu(n,e,t){const r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&Ne(n,"argument-error"),ro(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function so(n,...e){if(typeof n!="string"){const t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return qu.create(n,...e)}function j(n,e,...t){if(!n)throw so(e,...t)}function Ye(n){const e="INTERNAL ASSERTION FAILED: "+n;throw Wr(e),new Error(e)}function tt(n,e){n||Ye(e)}/**
|
|
422
422
|
* @license
|
|
423
423
|
* Copyright 2020 Google LLC
|
|
424
424
|
*
|
|
@@ -508,7 +508,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
508
508
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
509
509
|
* See the License for the specific language governing permissions and
|
|
510
510
|
* limitations under the License.
|
|
511
|
-
*/const
|
|
511
|
+
*/const xp={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/**
|
|
512
512
|
* @license
|
|
513
513
|
* Copyright 2020 Google LLC
|
|
514
514
|
*
|
|
@@ -523,7 +523,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
523
523
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
524
524
|
* See the License for the specific language governing permissions and
|
|
525
525
|
* limitations under the License.
|
|
526
|
-
*/const
|
|
526
|
+
*/const Lp=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Up=new lr(3e4,6e4);function it(n,e){return n.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:n.tenantId}):e}async function ot(n,e,t,r,s={}){return Wu(n,s,async()=>{let o={},a={};r&&(e==="GET"?a=r:o={body:JSON.stringify(r)});const u=ur(Object.assign({key:n.config.apiKey},a)).slice(1),l=await n._getAdditionalHeaders();l["Content-Type"]="application/json",n.languageCode&&(l["X-Firebase-Locale"]=n.languageCode);const d=Object.assign({method:e,headers:l},o);return of()||(d.referrerPolicy="no-referrer"),n.emulatorConfig&&_n(n.emulatorConfig.host)&&(d.credentials="include"),Hu.fetch()(await Gu(n,n.config.apiHost,t,u),d)})}async function Wu(n,e,t){n._canInitEmulator=!1;const r=Object.assign(Object.assign({},xp),e);try{const s=new jp(n),o=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const a=await o.json();if("needConfirmation"in a)throw Fr(n,"account-exists-with-different-credential",a);if(o.ok&&!("errorMessage"in a))return a;{const u=o.ok?a.errorMessage:a.error.message,[l,d]=u.split(" : ");if(l==="FEDERATED_USER_ID_ALREADY_LINKED")throw Fr(n,"credential-already-in-use",a);if(l==="EMAIL_EXISTS")throw Fr(n,"email-already-in-use",a);if(l==="USER_DISABLED")throw Fr(n,"user-disabled",a);const p=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(d)throw ro(n,p,d);Ne(n,p)}}catch(s){if(s instanceof st)throw s;Ne(n,"network-request-failed",{message:String(s)})}}async function hr(n,e,t,r,s={}){const o=await ot(n,e,t,r,s);return"mfaPendingCredential"in o&&Ne(n,"multi-factor-auth-required",{_serverResponse:o}),o}async function Gu(n,e,t,r){const s=`${e}${t}?${r}`,o=n,a=o.config.emulator?io(n.config,s):`${n.config.apiScheme}://${s}`;return Lp.includes(t)&&(await o._persistenceManagerAvailable,o._getPersistenceType()==="COOKIE")?o._getPersistence()._getFinalTarget(a).toString():a}function Fp(n){switch(n){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class jp{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(xe(this.auth,"network-request-failed")),Up.get())})}}function Fr(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=xe(n,e,r);return s.customData._tokenResponse=t,s}function oc(n){return n!==void 0&&n.enterprise!==void 0}class Bp{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return Fp(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function $p(n,e){return ot(n,"GET","/v2/recaptchaConfig",it(n,e))}/**
|
|
527
527
|
* @license
|
|
528
528
|
* Copyright 2020 Google LLC
|
|
529
529
|
*
|
|
@@ -553,7 +553,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
553
553
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
554
554
|
* See the License for the specific language governing permissions and
|
|
555
555
|
* limitations under the License.
|
|
556
|
-
*/function Gn(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function zp(n,e=!1){const t=
|
|
556
|
+
*/function Gn(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function zp(n,e=!1){const t=Le(n),r=await t.getIdToken(e),s=oo(r);j(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const o=typeof s.firebase=="object"?s.firebase:void 0,a=o?.sign_in_provider;return{claims:s,token:r,authTime:Gn(mi(s.auth_time)),issuedAtTime:Gn(mi(s.iat)),expirationTime:Gn(mi(s.exp)),signInProvider:a||null,signInSecondFactor:o?.sign_in_second_factor||null}}function mi(n){return Number(n)*1e3}function oo(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return Wr("JWT malformed, contained fewer than 3 sections"),null;try{const s=ku(t);return s?JSON.parse(s):(Wr("Failed to decode base64 JWT payload"),null)}catch(s){return Wr("Caught error parsing JWT payload as JSON",s?.toString()),null}}function ac(n){const e=oo(n);return j(e,"internal-error"),j(typeof e.exp<"u","internal-error"),j(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/**
|
|
557
557
|
* @license
|
|
558
558
|
* Copyright 2020 Google LLC
|
|
559
559
|
*
|
|
@@ -613,7 +613,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
613
613
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
614
614
|
* See the License for the specific language governing permissions and
|
|
615
615
|
* limitations under the License.
|
|
616
|
-
*/async function as(n){var e;const t=n.auth,r=await n.getIdToken(),s=await tr(n,os(t,{idToken:r}));
|
|
616
|
+
*/async function as(n){var e;const t=n.auth,r=await n.getIdToken(),s=await tr(n,os(t,{idToken:r}));j(s?.users.length,t,"internal-error");const o=s.users[0];n._notifyReloadListener(o);const a=!((e=o.providerUserInfo)===null||e===void 0)&&e.length?Ku(o.providerUserInfo):[],u=Kp(n.providerData,a),l=n.isAnonymous,d=!(n.email&&o.passwordHash)&&!u?.length,p=l?d:!1,v={uid:o.localId,displayName:o.displayName||null,photoURL:o.photoUrl||null,email:o.email||null,emailVerified:o.emailVerified||!1,phoneNumber:o.phoneNumber||null,tenantId:o.tenantId||null,providerData:u,metadata:new ki(o.createdAt,o.lastLoginAt),isAnonymous:p};Object.assign(n,v)}async function Gp(n){const e=Le(n);await as(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function Kp(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function Ku(n){return n.map(e=>{var{providerId:t}=e,r=no(e,["providerId"]);return{providerId:t,uid:r.rawId||"",displayName:r.displayName||null,email:r.email||null,phoneNumber:r.phoneNumber||null,photoURL:r.photoUrl||null}})}/**
|
|
617
617
|
* @license
|
|
618
618
|
* Copyright 2020 Google LLC
|
|
619
619
|
*
|
|
@@ -643,7 +643,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
643
643
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
644
644
|
* See the License for the specific language governing permissions and
|
|
645
645
|
* limitations under the License.
|
|
646
|
-
*/class nn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){
|
|
646
|
+
*/class nn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){j(e.idToken,"internal-error"),j(typeof e.idToken<"u","internal-error"),j(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):ac(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){j(e.length!==0,"internal-error");const t=ac(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(j(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:r,refreshToken:s,expiresIn:o}=await Qp(e,t);this.updateTokensAndExpiration(r,s,Number(o))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){const{refreshToken:r,accessToken:s,expirationTime:o}=t,a=new nn;return r&&(j(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),s&&(j(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),o&&(j(typeof o=="number","internal-error",{appName:e}),a.expirationTime=o),a}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new nn,this.toJSON())}_performRefresh(){return Ye("not implemented")}}/**
|
|
647
647
|
* @license
|
|
648
648
|
* Copyright 2020 Google LLC
|
|
649
649
|
*
|
|
@@ -658,7 +658,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
658
658
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
659
659
|
* See the License for the specific language governing permissions and
|
|
660
660
|
* limitations under the License.
|
|
661
|
-
*/function ht(n,e){
|
|
661
|
+
*/function ht(n,e){j(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Me{constructor(e){var{uid:t,auth:r,stsTokenManager:s}=e,o=no(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new Wp(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=r,this.stsTokenManager=s,this.accessToken=s.accessToken,this.displayName=o.displayName||null,this.email=o.email||null,this.emailVerified=o.emailVerified||!1,this.phoneNumber=o.phoneNumber||null,this.photoURL=o.photoURL||null,this.isAnonymous=o.isAnonymous||!1,this.tenantId=o.tenantId||null,this.providerData=o.providerData?[...o.providerData]:[],this.metadata=new ki(o.createdAt||void 0,o.lastLoginAt||void 0)}async getIdToken(e){const t=await tr(this,this.stsTokenManager.getToken(this.auth,e));return j(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return zp(this,e)}reload(){return Gp(this)}_assign(e){this!==e&&(j(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>Object.assign({},t)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Me(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){j(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await as(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(ke(this.auth.app))return Promise.reject($e(this.auth));const e=await this.getIdToken();return await tr(this,qp(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var r,s,o,a,u,l,d,p;const v=(r=t.displayName)!==null&&r!==void 0?r:void 0,E=(s=t.email)!==null&&s!==void 0?s:void 0,C=(o=t.phoneNumber)!==null&&o!==void 0?o:void 0,V=(a=t.photoURL)!==null&&a!==void 0?a:void 0,M=(u=t.tenantId)!==null&&u!==void 0?u:void 0,k=(l=t._redirectEventId)!==null&&l!==void 0?l:void 0,q=(d=t.createdAt)!==null&&d!==void 0?d:void 0,z=(p=t.lastLoginAt)!==null&&p!==void 0?p:void 0,{uid:B,emailVerified:Y,isAnonymous:he,providerData:P,stsTokenManager:_}=t;j(B&&_,e,"internal-error");const m=nn.fromJSON(this.name,_);j(typeof B=="string",e,"internal-error"),ht(v,e.name),ht(E,e.name),j(typeof Y=="boolean",e,"internal-error"),j(typeof he=="boolean",e,"internal-error"),ht(C,e.name),ht(V,e.name),ht(M,e.name),ht(k,e.name),ht(q,e.name),ht(z,e.name);const g=new Me({uid:B,auth:e,email:E,emailVerified:Y,displayName:v,isAnonymous:he,photoURL:V,phoneNumber:C,tenantId:M,stsTokenManager:m,createdAt:q,lastLoginAt:z});return P&&Array.isArray(P)&&(g.providerData=P.map(T=>Object.assign({},T))),k&&(g._redirectEventId=k),g}static async _fromIdTokenResponse(e,t,r=!1){const s=new nn;s.updateFromServerResponse(t);const o=new Me({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await as(o),o}static async _fromGetAccountInfoResponse(e,t,r){const s=t.users[0];j(s.localId!==void 0,"internal-error");const o=s.providerUserInfo!==void 0?Ku(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!o?.length,u=new nn;u.updateFromIdToken(r);const l=new Me({uid:s.localId,auth:e,stsTokenManager:u,isAnonymous:a}),d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:o,metadata:new ki(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!o?.length};return Object.assign(l,d),l}}/**
|
|
662
662
|
* @license
|
|
663
663
|
* Copyright 2020 Google LLC
|
|
664
664
|
*
|
|
@@ -793,7 +793,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
793
793
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
794
794
|
* See the License for the specific language governing permissions and
|
|
795
795
|
* limitations under the License.
|
|
796
|
-
*/class rm{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new hc(this),this.idTokenSubscription=new hc(this),this.beforeStateQueue=new Zp(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=qu,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(o=>this._resolvePersistenceManagerAvailable=o)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=Ze(t)),this._initializationPromise=this.queue(async()=>{var r,s,o;if(!this._deleted&&(this.persistenceManager=await rn.create(this,e),(r=this._resolvePersistenceManagerAvailable)===null||r===void 0||r.call(this),!this._deleted)){if(!((s=this._popupRedirectResolver)===null||s===void 0)&&s._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=((o=this.currentUser)===null||o===void 0?void 0:o.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await os(this,{idToken:e}),r=await Me._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(ke(this.app)){const a=this.app.settings.authIdToken;return a?new Promise(u=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(a).then(u,u))}):this.directlySetCurrentUser(null)}const r=await this.assertedPersistence.getCurrentUser();let s=r,o=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const a=(t=this.redirectUser)===null||t===void 0?void 0:t._redirectEventId,u=s?._redirectEventId,l=await this.tryRedirectSignIn(e);(!a||a===u)&&l?.user&&(s=l.user,o=!0)}if(!s)return this.directlySetCurrentUser(null);if(!s._redirectEventId){if(o)try{await this.beforeStateQueue.runMiddleware(s)}catch(a){s=r,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(a))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}return F(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===s._redirectEventId?this.directlySetCurrentUser(s):this.reloadAndSetCurrentUserOrClear(s)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await as(e)}catch(t){if(t?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=Mp()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(ke(this.app))return Promise.reject($e(this));const t=e?xe(e):null;return t&&F(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&F(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return ke(this.app)?Promise.reject($e(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return ke(this.app)?Promise.reject($e(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(Ze(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await em(this),t=new nm(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new cr("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await Jp(this,r)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&Ze(e)||this._popupRedirectResolver;F(t,this,"argument-error"),this.redirectPersistenceManager=await rn.create(this,[Ze(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,r;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)===null||t===void 0?void 0:t._redirectEventId)===e?this._currentUser:((r=this.redirectUser)===null||r===void 0?void 0:r._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const r=(t=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&t!==void 0?t:null;this.lastNotifiedUid!==r&&(this.lastNotifiedUid=r,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,s){if(this._deleted)return()=>{};const o=typeof t=="function"?t:t.next.bind(t);let a=!1;const u=this._isInitialized?Promise.resolve():this._initializationPromise;if(F(u,this,"internal-error"),u.then(()=>{a||o(this.currentUser)}),typeof t=="function"){const l=e.addObserver(t,r,s);return()=>{a=!0,l()}}else{const l=e.addObserver(t);return()=>{a=!0,l()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return F(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=sl(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const r=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());r&&(t["X-Firebase-Client"]=r);const s=await this._getAppCheckToken();return s&&(t["X-Firebase-AppCheck"]=s),t}async _getAppCheckToken(){var e;if(ke(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const t=await((e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken());return t?.error&&Dp(`Error while retrieving App Check token: ${t.error}`),t?.token}}function Ue(n){return xe(n)}class hc{constructor(e){this.auth=e,this.observer=null,this.addObserver=_f(t=>this.observer=t)}get next(){return F(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/**
|
|
796
|
+
*/class rm{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new hc(this),this.idTokenSubscription=new hc(this),this.beforeStateQueue=new Zp(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=qu,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(o=>this._resolvePersistenceManagerAvailable=o)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=Ze(t)),this._initializationPromise=this.queue(async()=>{var r,s,o;if(!this._deleted&&(this.persistenceManager=await rn.create(this,e),(r=this._resolvePersistenceManagerAvailable)===null||r===void 0||r.call(this),!this._deleted)){if(!((s=this._popupRedirectResolver)===null||s===void 0)&&s._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=((o=this.currentUser)===null||o===void 0?void 0:o.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await os(this,{idToken:e}),r=await Me._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(ke(this.app)){const a=this.app.settings.authIdToken;return a?new Promise(u=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(a).then(u,u))}):this.directlySetCurrentUser(null)}const r=await this.assertedPersistence.getCurrentUser();let s=r,o=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const a=(t=this.redirectUser)===null||t===void 0?void 0:t._redirectEventId,u=s?._redirectEventId,l=await this.tryRedirectSignIn(e);(!a||a===u)&&l?.user&&(s=l.user,o=!0)}if(!s)return this.directlySetCurrentUser(null);if(!s._redirectEventId){if(o)try{await this.beforeStateQueue.runMiddleware(s)}catch(a){s=r,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(a))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}return j(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===s._redirectEventId?this.directlySetCurrentUser(s):this.reloadAndSetCurrentUserOrClear(s)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await as(e)}catch(t){if(t?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=Mp()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(ke(this.app))return Promise.reject($e(this));const t=e?Le(e):null;return t&&j(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&j(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return ke(this.app)?Promise.reject($e(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return ke(this.app)?Promise.reject($e(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(Ze(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await em(this),t=new nm(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new cr("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await Jp(this,r)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&Ze(e)||this._popupRedirectResolver;j(t,this,"argument-error"),this.redirectPersistenceManager=await rn.create(this,[Ze(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,r;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)===null||t===void 0?void 0:t._redirectEventId)===e?this._currentUser:((r=this.redirectUser)===null||r===void 0?void 0:r._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const r=(t=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&t!==void 0?t:null;this.lastNotifiedUid!==r&&(this.lastNotifiedUid=r,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,s){if(this._deleted)return()=>{};const o=typeof t=="function"?t:t.next.bind(t);let a=!1;const u=this._isInitialized?Promise.resolve():this._initializationPromise;if(j(u,this,"internal-error"),u.then(()=>{a||o(this.currentUser)}),typeof t=="function"){const l=e.addObserver(t,r,s);return()=>{a=!0,l()}}else{const l=e.addObserver(t);return()=>{a=!0,l()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return j(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=sl(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const r=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());r&&(t["X-Firebase-Client"]=r);const s=await this._getAppCheckToken();return s&&(t["X-Firebase-AppCheck"]=s),t}async _getAppCheckToken(){var e;if(ke(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const t=await((e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken());return t?.error&&Dp(`Error while retrieving App Check token: ${t.error}`),t?.token}}function Ue(n){return Le(n)}class hc{constructor(e){this.auth=e,this.observer=null,this.addObserver=_f(t=>this.observer=t)}get next(){return j(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/**
|
|
797
797
|
* @license
|
|
798
798
|
* Copyright 2020 Google LLC
|
|
799
799
|
*
|
|
@@ -823,7 +823,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
823
823
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
824
824
|
* See the License for the specific language governing permissions and
|
|
825
825
|
* limitations under the License.
|
|
826
|
-
*/function dm(n,e){const t=to(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),o=t.getOptions();if(Bt(o,e??{}))return s;Ne(s,"already-initialized")}return t.initialize({options:e})}function fm(n,e){const t=e?.persistence||[],r=(Array.isArray(t)?t:[t]).map(Ze);e?.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e?.popupRedirectResolver)}function pm(n,e,t){const r=Ue(n);
|
|
826
|
+
*/function dm(n,e){const t=to(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),o=t.getOptions();if(Bt(o,e??{}))return s;Ne(s,"already-initialized")}return t.initialize({options:e})}function fm(n,e){const t=e?.persistence||[],r=(Array.isArray(t)?t:[t]).map(Ze);e?.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e?.popupRedirectResolver)}function pm(n,e,t){const r=Ue(n);j(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,o=al(e),{host:a,port:u}=mm(e),l=u===null?"":`:${u}`,d={url:`${o}//${a}${l}/`},p=Object.freeze({host:a,port:u,protocol:o.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){j(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),j(Bt(d,r.config.emulator)&&Bt(p,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=d,r.emulatorConfig=p,r.settings.appVerificationDisabledForTesting=!0,_n(a)?(Vu(`${o}//${a}${l}`),Mu("Auth",!0)):gm()}function al(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function mm(n){const e=al(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const r=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const o=s[1];return{host:o,port:fc(r.substr(o.length+1))}}else{const[o,a]=r.split(":");return{host:o,port:fc(a)}}}function fc(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function gm(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}/**
|
|
827
827
|
* @license
|
|
828
828
|
* Copyright 2020 Google LLC
|
|
829
829
|
*
|
|
@@ -928,7 +928,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
928
928
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
929
929
|
* See the License for the specific language governing permissions and
|
|
930
930
|
* limitations under the License.
|
|
931
|
-
*/function Am(n){switch(n){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function bm(n){const e=jn(Bn(n)).link,t=e?jn(Bn(e)).deep_link_id:null,r=jn(Bn(n)).deep_link_id;return(r?jn(Bn(r)).link:null)||r||t||e||n}class uo{constructor(e){var t,r,s,o,a,u;const l=jn(Bn(e)),d=(t=l.apiKey)!==null&&t!==void 0?t:null,p=(r=l.oobCode)!==null&&r!==void 0?r:null,v=Am((s=l.mode)!==null&&s!==void 0?s:null);
|
|
931
|
+
*/function Am(n){switch(n){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function bm(n){const e=jn(Bn(n)).link,t=e?jn(Bn(e)).deep_link_id:null,r=jn(Bn(n)).deep_link_id;return(r?jn(Bn(r)).link:null)||r||t||e||n}class uo{constructor(e){var t,r,s,o,a,u;const l=jn(Bn(e)),d=(t=l.apiKey)!==null&&t!==void 0?t:null,p=(r=l.oobCode)!==null&&r!==void 0?r:null,v=Am((s=l.mode)!==null&&s!==void 0?s:null);j(d&&p&&v,"argument-error"),this.apiKey=d,this.operation=v,this.code=p,this.continueUrl=(o=l.continueUrl)!==null&&o!==void 0?o:null,this.languageCode=(a=l.lang)!==null&&a!==void 0?a:null,this.tenantId=(u=l.tenantId)!==null&&u!==void 0?u:null}static parseLink(e){const t=bm(e);try{return new uo(t)}catch{return null}}}/**
|
|
932
932
|
* @license
|
|
933
933
|
* Copyright 2020 Google LLC
|
|
934
934
|
*
|
|
@@ -943,7 +943,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
943
943
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
944
944
|
* See the License for the specific language governing permissions and
|
|
945
945
|
* limitations under the License.
|
|
946
|
-
*/class vn{constructor(){this.providerId=vn.PROVIDER_ID}static credential(e,t){return nr._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const r=uo.parseLink(t);return
|
|
946
|
+
*/class vn{constructor(){this.providerId=vn.PROVIDER_ID}static credential(e,t){return nr._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const r=uo.parseLink(t);return j(r,"argument-error"),nr._fromEmailAndCode(e,r.code,r.tenantId)}}vn.PROVIDER_ID="password";vn.EMAIL_PASSWORD_SIGN_IN_METHOD="password";vn.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/**
|
|
947
947
|
* @license
|
|
948
948
|
* Copyright 2020 Google LLC
|
|
949
949
|
*
|
|
@@ -1078,7 +1078,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1078
1078
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1079
1079
|
* See the License for the specific language governing permissions and
|
|
1080
1080
|
* limitations under the License.
|
|
1081
|
-
*/async function Sm(n,e,t=!1){const{auth:r}=n;if(ke(r.app))return Promise.reject($e(r));const s="reauthenticate";try{const o=await tr(n,cl(r,s,e,n),t);
|
|
1081
|
+
*/async function Sm(n,e,t=!1){const{auth:r}=n;if(ke(r.app))return Promise.reject($e(r));const s="reauthenticate";try{const o=await tr(n,cl(r,s,e,n),t);j(o.idToken,r,"internal-error");const a=oo(o.idToken);j(a,r,"internal-error");const{sub:u}=a;return j(n.uid===u,r,"user-mismatch"),zt._forOperation(n,s,o)}catch(o){throw o?.code==="auth/user-not-found"&&Ne(r,"user-mismatch"),o}}/**
|
|
1082
1082
|
* @license
|
|
1083
1083
|
* Copyright 2020 Google LLC
|
|
1084
1084
|
*
|
|
@@ -1138,7 +1138,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1138
1138
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1139
1139
|
* See the License for the specific language governing permissions and
|
|
1140
1140
|
* limitations under the License.
|
|
1141
|
-
*/async function Om(n){const e=Ue(n);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function Dm(n,e,t){const r=Ue(n);await Oi(r,{requestType:"PASSWORD_RESET",email:e,clientType:"CLIENT_TYPE_WEB"},"getOobCode",Em)}function Nm(n,e,t){return ke(n.app)?Promise.reject($e(n)):Cm(
|
|
1141
|
+
*/async function Om(n){const e=Ue(n);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function Dm(n,e,t){const r=Ue(n);await Oi(r,{requestType:"PASSWORD_RESET",email:e,clientType:"CLIENT_TYPE_WEB"},"getOobCode",Em)}function Nm(n,e,t){return ke(n.app)?Promise.reject($e(n)):Cm(Le(n),vn.credential(e,t)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&Om(n),r})}function Vm(n,e,t,r){return Le(n).onIdTokenChanged(e,t,r)}function Mm(n,e,t){return Le(n).beforeAuthStateChanged(e,t)}function xm(n,e,t,r){return Le(n).onAuthStateChanged(e,t,r)}function Lm(n){return Le(n).signOut()}const us="__sak";/**
|
|
1142
1142
|
* @license
|
|
1143
1143
|
* Copyright 2019 Google LLC
|
|
1144
1144
|
*
|
|
@@ -1303,7 +1303,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1303
1303
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1304
1304
|
* See the License for the specific language governing permissions and
|
|
1305
1305
|
* limitations under the License.
|
|
1306
|
-
*/function ho(n,e){return e?Ze(e):(
|
|
1306
|
+
*/function ho(n,e){return e?Ze(e):(j(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}/**
|
|
1307
1307
|
* @license
|
|
1308
1308
|
* Copyright 2019 Google LLC
|
|
1309
1309
|
*
|
|
@@ -1318,7 +1318,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1318
1318
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1319
1319
|
* See the License for the specific language governing permissions and
|
|
1320
1320
|
* limitations under the License.
|
|
1321
|
-
*/class fo extends co{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return sn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return sn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return sn(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function Zm(n){return ul(n.auth,new fo(n),n.bypassAuthState)}function eg(n){const{auth:e,user:t}=n;return
|
|
1321
|
+
*/class fo extends co{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return sn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return sn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return sn(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function Zm(n){return ul(n.auth,new fo(n),n.bypassAuthState)}function eg(n){const{auth:e,user:t}=n;return j(t,e,"internal-error"),Sm(t,new fo(n),n.bypassAuthState)}async function tg(n){const{auth:e,user:t}=n;return j(t,e,"internal-error"),Rm(t,new fo(n),n.bypassAuthState)}/**
|
|
1322
1322
|
* @license
|
|
1323
1323
|
* Copyright 2020 Google LLC
|
|
1324
1324
|
*
|
|
@@ -1348,7 +1348,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1348
1348
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1349
1349
|
* See the License for the specific language governing permissions and
|
|
1350
1350
|
* limitations under the License.
|
|
1351
|
-
*/const ng=new lr(2e3,1e4);async function rg(n,e,t){if(ke(n.app))return Promise.reject(
|
|
1351
|
+
*/const ng=new lr(2e3,1e4);async function rg(n,e,t){if(ke(n.app))return Promise.reject(xe(n,"operation-not-supported-in-this-environment"));const r=Ue(n);zu(n,e,ws);const s=ho(r,t);return new xt(r,"signInViaPopup",e,s).executeNotNull()}class xt extends yl{constructor(e,t,r,s,o){super(e,t,s,o),this.provider=r,this.authWindow=null,this.pollId=null,xt.currentPopupAction&&xt.currentPopupAction.cancel(),xt.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return j(e,this.auth,"internal-error"),e}async onExecution(){tt(this.filter.length===1,"Popup operations only handle one event");const e=lo();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(xe(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)===null||e===void 0?void 0:e.associatedEvent)||null}cancel(){this.reject(xe(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,xt.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,r;if(!((r=(t=this.authWindow)===null||t===void 0?void 0:t.window)===null||r===void 0)&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(xe(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,ng.get())};e()}}xt.currentPopupAction=null;/**
|
|
1352
1352
|
* @license
|
|
1353
1353
|
* Copyright 2020 Google LLC
|
|
1354
1354
|
*
|
|
@@ -1393,7 +1393,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1393
1393
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1394
1394
|
* See the License for the specific language governing permissions and
|
|
1395
1395
|
* limitations under the License.
|
|
1396
|
-
*/const dg=600*1e3;class fg{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!pg(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var r;if(e.error&&!wl(e)){const s=((r=e.error.code)===null||r===void 0?void 0:r.split("auth/")[1])||"internal-error";t.onError(
|
|
1396
|
+
*/const dg=600*1e3;class fg{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!pg(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var r;if(e.error&&!wl(e)){const s=((r=e.error.code)===null||r===void 0?void 0:r.split("auth/")[1])||"internal-error";t.onError(xe(this.auth,s))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=dg&&this.cachedEventUids.clear(),this.cachedEventUids.has(_c(e))}saveEventToCache(e){this.cachedEventUids.add(_c(e)),this.lastProcessedEventTime=Date.now()}}function _c(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function wl({type:n,error:e}){return n==="unknown"&&e?.code==="auth/no-auth-event"}function pg(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return wl(n);default:return!1}}/**
|
|
1397
1397
|
* @license
|
|
1398
1398
|
* Copyright 2020 Google LLC
|
|
1399
1399
|
*
|
|
@@ -1438,7 +1438,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1438
1438
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1439
1439
|
* See the License for the specific language governing permissions and
|
|
1440
1440
|
* limitations under the License.
|
|
1441
|
-
*/const Eg=new lr(3e4,6e4);function yc(){const n=qe().___jsl;if(n?.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function Tg(n){return new Promise((e,t)=>{var r,s,o;function a(){yc(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{yc(),t(
|
|
1441
|
+
*/const Eg=new lr(3e4,6e4);function yc(){const n=qe().___jsl;if(n?.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function Tg(n){return new Promise((e,t)=>{var r,s,o;function a(){yc(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{yc(),t(xe(n,"network-request-failed"))},timeout:Eg.get()})}if(!((s=(r=qe().gapi)===null||r===void 0?void 0:r.iframes)===null||s===void 0)&&s.Iframe)e(gapi.iframes.getContext());else if(!((o=qe().gapi)===null||o===void 0)&&o.load)a();else{const u=am("iframefcb");return qe()[u]=()=>{gapi.load?a():t(xe(n,"network-request-failed"))},il(`${om()}?onload=${u}`).catch(l=>t(l))}}).catch(e=>{throw Qr=null,e})}let Qr=null;function wg(n){return Qr=Qr||Tg(n),Qr}/**
|
|
1442
1442
|
* @license
|
|
1443
1443
|
* Copyright 2020 Google LLC.
|
|
1444
1444
|
*
|
|
@@ -1453,7 +1453,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1453
1453
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1454
1454
|
* See the License for the specific language governing permissions and
|
|
1455
1455
|
* limitations under the License.
|
|
1456
|
-
*/const Ig=new lr(5e3,15e3),Ag="__/auth/iframe",bg="emulator/auth/iframe",Rg={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Sg=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Cg(n){const e=n.config;
|
|
1456
|
+
*/const Ig=new lr(5e3,15e3),Ag="__/auth/iframe",bg="emulator/auth/iframe",Rg={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Sg=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Cg(n){const e=n.config;j(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?io(e,bg):`https://${n.config.authDomain}/${Ag}`,r={apiKey:e.apiKey,appName:n.name,v:yn},s=Sg.get(n.config.apiHost);s&&(r.eid=s);const o=n._getFrameworks();return o.length&&(r.fw=o.join(",")),`${t}?${ur(r).slice(1)}`}async function Pg(n){const e=await wg(n),t=qe().gapi;return j(t,n,"internal-error"),e.open({where:document.body,url:Cg(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Rg,dontclear:!0},r=>new Promise(async(s,o)=>{await r.restyle({setHideOnLeave:!1});const a=xe(n,"network-request-failed"),u=qe().setTimeout(()=>{o(a)},Ig.get());function l(){qe().clearTimeout(u),s(r)}r.ping(l).then(l,()=>{o(a)})}))}/**
|
|
1457
1457
|
* @license
|
|
1458
1458
|
* Copyright 2020 Google LLC.
|
|
1459
1459
|
*
|
|
@@ -1468,7 +1468,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1468
1468
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1469
1469
|
* See the License for the specific language governing permissions and
|
|
1470
1470
|
* limitations under the License.
|
|
1471
|
-
*/const kg={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Og=500,Dg=600,Ng="_blank",Vg="http://localhost";class vc{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Mg(n,e,t,r=Og,s=Dg){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let u="";const l=Object.assign(Object.assign({},kg),{width:r.toString(),height:s.toString(),top:o,left:a}),d=Ae().toLowerCase();t&&(u=Yu(d)?Ng:t),Ju(d)&&(e=e||Vg,l.scrollbars="yes");const p=Object.entries(l).reduce((E,[C,V])=>`${E}${C}=${V},`,"");if(Xp(d)&&u!=="_self")return
|
|
1471
|
+
*/const kg={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Og=500,Dg=600,Ng="_blank",Vg="http://localhost";class vc{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Mg(n,e,t,r=Og,s=Dg){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let u="";const l=Object.assign(Object.assign({},kg),{width:r.toString(),height:s.toString(),top:o,left:a}),d=Ae().toLowerCase();t&&(u=Yu(d)?Ng:t),Ju(d)&&(e=e||Vg,l.scrollbars="yes");const p=Object.entries(l).reduce((E,[C,V])=>`${E}${C}=${V},`,"");if(Xp(d)&&u!=="_self")return xg(e||"",u),new vc(null);const v=window.open(e||"",u,p);j(v,n,"popup-blocked");try{v.focus()}catch{}return new vc(v)}function xg(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}/**
|
|
1472
1472
|
* @license
|
|
1473
1473
|
* Copyright 2021 Google LLC
|
|
1474
1474
|
*
|
|
@@ -1483,7 +1483,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1483
1483
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1484
1484
|
* See the License for the specific language governing permissions and
|
|
1485
1485
|
* limitations under the License.
|
|
1486
|
-
*/const
|
|
1486
|
+
*/const Lg="__/auth/handler",Ug="emulator/auth/handler",Fg=encodeURIComponent("fac");async function Ec(n,e,t,r,s,o){j(n.config.authDomain,n,"auth-domain-config-required"),j(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:yn,eventId:s};if(e instanceof ws){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",gf(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[p,v]of Object.entries({}))a[p]=v}if(e instanceof dr){const p=e.getScopes().filter(v=>v!=="");p.length>0&&(a.scopes=p.join(","))}n.tenantId&&(a.tid=n.tenantId);const u=a;for(const p of Object.keys(u))u[p]===void 0&&delete u[p];const l=await n._getAppCheckToken(),d=l?`#${Fg}=${encodeURIComponent(l)}`:"";return`${jg(n)}?${ur(u).slice(1)}${d}`}function jg({config:n}){return n.emulator?io(n,Ug):`https://${n.authDomain}/${Lg}`}/**
|
|
1487
1487
|
* @license
|
|
1488
1488
|
* Copyright 2020 Google LLC
|
|
1489
1489
|
*
|
|
@@ -1498,7 +1498,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1498
1498
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1499
1499
|
* See the License for the specific language governing permissions and
|
|
1500
1500
|
* limitations under the License.
|
|
1501
|
-
*/const gi="webStorageSupport";class Bg{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=fl,this._completeRedirectFn=Tl,this._overrideRedirectResult=cg}async _openPopup(e,t,r,s){var o;tt((o=this.eventManagers[e._key()])===null||o===void 0?void 0:o.manager,"_initialize() not called before _openPopup()");const a=await Ec(e,t,r,Pi(),s);return Mg(e,a,lo())}async _openRedirect(e,t,r,s){await this._originValidation(e);const o=await Ec(e,t,r,Pi(),s);return qm(o),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:o}=this.eventManagers[t];return s?Promise.resolve(s):(tt(o,"If manager is not set, promise should be"),o)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await Pg(e),r=new fg(e);return t.register("authEvent",s=>(
|
|
1501
|
+
*/const gi="webStorageSupport";class Bg{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=fl,this._completeRedirectFn=Tl,this._overrideRedirectResult=cg}async _openPopup(e,t,r,s){var o;tt((o=this.eventManagers[e._key()])===null||o===void 0?void 0:o.manager,"_initialize() not called before _openPopup()");const a=await Ec(e,t,r,Pi(),s);return Mg(e,a,lo())}async _openRedirect(e,t,r,s){await this._originValidation(e);const o=await Ec(e,t,r,Pi(),s);return qm(o),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:o}=this.eventManagers[t];return s?Promise.resolve(s):(tt(o,"If manager is not set, promise should be"),o)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await Pg(e),r=new fg(e);return t.register("authEvent",s=>(j(s?.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(gi,{type:gi},s=>{var o;const a=(o=s?.[0])===null||o===void 0?void 0:o[gi];a!==void 0&&t(!!a),Ne(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=yg(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return rl()||Xu()||ao()}}const $g=Bg;var Tc="@firebase/auth",wc="1.10.8";/**
|
|
1502
1502
|
* @license
|
|
1503
1503
|
* Copyright 2020 Google LLC
|
|
1504
1504
|
*
|
|
@@ -1513,7 +1513,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1513
1513
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1514
1514
|
* See the License for the specific language governing permissions and
|
|
1515
1515
|
* limitations under the License.
|
|
1516
|
-
*/class qg{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(r=>{e(r?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){
|
|
1516
|
+
*/class qg{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(r=>{e(r?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){j(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/**
|
|
1517
1517
|
* @license
|
|
1518
1518
|
* Copyright 2020 Google LLC
|
|
1519
1519
|
*
|
|
@@ -1528,7 +1528,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1528
1528
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1529
1529
|
* See the License for the specific language governing permissions and
|
|
1530
1530
|
* limitations under the License.
|
|
1531
|
-
*/function zg(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function Hg(n){ln(new $t("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),o=e.getProvider("app-check-internal"),{apiKey:a,authDomain:u}=r.options;
|
|
1531
|
+
*/function zg(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function Hg(n){ln(new $t("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),o=e.getProvider("app-check-internal"),{apiKey:a,authDomain:u}=r.options;j(a&&!a.includes(":"),"invalid-api-key",{appName:r.name});const l={apiKey:a,authDomain:u,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:sl(n)},d=new rm(r,s,o,l);return fm(d,t),d},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),ln(new $t("auth-internal",e=>{const t=Ue(e.getProvider("auth").getImmediate());return(r=>new qg(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),vt(Tc,wc,zg(n)),vt(Tc,wc,"esm2017")}/**
|
|
1532
1532
|
* @license
|
|
1533
1533
|
* Copyright 2021 Google LLC
|
|
1534
1534
|
*
|
|
@@ -1543,7 +1543,7 @@ import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn
|
|
|
1543
1543
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1544
1544
|
* See the License for the specific language governing permissions and
|
|
1545
1545
|
* limitations under the License.
|
|
1546
|
-
*/const Wg=300,Gg=Nu("authIdTokenMaxAge")||Wg;let Ic=null;const Kg=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>Gg)return;const s=t?.token;Ic!==s&&(Ic=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function Qg(n=Fu()){const e=to(n,"auth");if(e.isInitialized())return e.getImmediate();const t=dm(n,{popupRedirectResolver:$g,persistence:[Ym,jm,fl]}),r=Nu("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const o=new URL(r,location.origin);if(location.origin===o.origin){const a=Kg(o.toString());Mm(t,a,()=>a(t.currentUser)),Vm(t,u=>a(u))}}const s=Ou("auth");return s&&pm(t,`http://${s}`),t}function Jg(){var n,e;return(e=(n=document.getElementsByTagName("head"))===null||n===void 0?void 0:n[0])!==null&&e!==void 0?e:document}sm({loadJS(n){return new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const o=
|
|
1546
|
+
*/const Wg=300,Gg=Nu("authIdTokenMaxAge")||Wg;let Ic=null;const Kg=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>Gg)return;const s=t?.token;Ic!==s&&(Ic=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function Qg(n=Fu()){const e=to(n,"auth");if(e.isInitialized())return e.getImmediate();const t=dm(n,{popupRedirectResolver:$g,persistence:[Ym,jm,fl]}),r=Nu("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const o=new URL(r,location.origin);if(location.origin===o.origin){const a=Kg(o.toString());Mm(t,a,()=>a(t.currentUser)),Vm(t,u=>a(u))}}const s=Ou("auth");return s&&pm(t,`http://${s}`),t}function Jg(){var n,e;return(e=(n=document.getElementsByTagName("head"))===null||n===void 0?void 0:n[0])!==null&&e!==void 0?e:document}sm({loadJS(n){return new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const o=xe("internal-error");o.customData=s,t(o)},r.type="text/javascript",r.charset="UTF-8",Jg().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});Hg("Browser");var Ac=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
|
|
1547
1547
|
Copyright The Closure Library Authors.
|
|
1548
1548
|
SPDX-License-Identifier: Apache-2.0
|
|
1549
1549
|
*/var Et,Il;(function(){var n;/** @license
|
|
@@ -1562,10 +1562,10 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1562
1562
|
`+D})}function Xh(i,c,h,f,I,R,D){i.info(function(){return"XMLHTTP RESP ("+f+") [ attempt "+I+"]: "+c+`
|
|
1563
1563
|
`+h+`
|
|
1564
1564
|
`+R+" "+D})}function Gt(i,c,h,f){i.info(function(){return"XMLHTTP TEXT ("+c+"): "+Zh(i,h)+(f?" "+f:"")})}function Yh(i,c){i.info(function(){return"TIMEOUT: "+c})}On.prototype.info=function(){};function Zh(i,c){if(!i.g)return c;if(!c)return null;try{var h=JSON.parse(c);if(h){for(i=0;i<h.length;i++)if(Array.isArray(h[i])){var f=h[i];if(!(2>f.length)){var I=f[1];if(Array.isArray(I)&&!(1>I.length)){var R=I[0];if(R!="noop"&&R!="stop"&&R!="close")for(var D=1;D<I.length;D++)I[D]=""}}}}return Gs(h)}catch{return c}}var br={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},ea={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Xs;function Rr(){}V(Rr,Ks),Rr.prototype.g=function(){return new XMLHttpRequest},Rr.prototype.i=function(){return{}},Xs=new Rr;function ct(i,c,h,f){this.j=i,this.i=c,this.l=h,this.R=f||1,this.U=new Sn(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new ta}function ta(){this.i=null,this.g="",this.h=!1}var na={},Ys={};function Zs(i,c,h){i.L=1,i.v=kr(Ke(c)),i.m=h,i.P=!0,ra(i,null)}function ra(i,c){i.F=Date.now(),Sr(i),i.A=Ke(i.v);var h=i.A,f=i.R;Array.isArray(f)||(f=[String(f)]),_a(h.i,"t",f),i.C=0,h=i.j.J,i.h=new ta,i.g=Ma(i.j,h?c:null,!i.m),0<i.O&&(i.M=new Gh(E(i.Y,i,i.g),i.O)),c=i.U,h=i.g,f=i.ca;var I="readystatechange";Array.isArray(I)||(I&&(Wo[0]=I.toString()),I=Wo);for(var R=0;R<I.length;R++){var D=jo(h,I[R],f||c.handleEvent,!1,c.h||c);if(!D)break;c.g[D.key]=D}c=i.H?m(i.H):{},i.m?(i.u||(i.u="POST"),c["Content-Type"]="application/x-www-form-urlencoded",i.g.ea(i.A,i.u,i.m,c)):(i.u="GET",i.g.ea(i.A,i.u,null,c)),Pn(),Jh(i.i,i.u,i.A,i.l,i.R,i.m)}ct.prototype.ca=function(i){i=i.target;const c=this.M;c&&Qe(i)==3?c.j():this.Y(i)},ct.prototype.Y=function(i){try{if(i==this.g)e:{const Ee=Qe(this.g);var c=this.g.Ba();const Jt=this.g.Z();if(!(3>Ee)&&(Ee!=3||this.g&&(this.h.h||this.g.oa()||Aa(this.g)))){this.J||Ee!=4||c==7||(c==8||0>=Jt?Pn(3):Pn(2)),ei(this);var h=this.g.Z();this.X=h;t:if(sa(this)){var f=Aa(this.g);i="";var I=f.length,R=Qe(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){Dt(this),Dn(this);var D="";break t}this.h.i=new u.TextDecoder}for(c=0;c<I;c++)this.h.h=!0,i+=this.h.i.decode(f[c],{stream:!(R&&c==I-1)});f.length=0,this.h.g+=i,this.C=0,D=this.h.g}else D=this.g.oa();if(this.o=h==200,Xh(this.i,this.u,this.A,this.l,this.R,Ee,h),this.o){if(this.T&&!this.K){t:{if(this.g){var Z,fe=this.g;if((Z=fe.g?fe.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!z(Z)){var X=Z;break t}}X=null}if(h=X)Gt(this.i,this.l,h,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,ti(this,h);else{this.o=!1,this.s=3,Re(12),Dt(this),Dn(this);break e}}if(this.P){h=!0;let Ve;for(;!this.J&&this.C<D.length;)if(Ve=ed(this,D),Ve==Ys){Ee==4&&(this.s=4,Re(14),h=!1),Gt(this.i,this.l,null,"[Incomplete Response]");break}else if(Ve==na){this.s=4,Re(15),Gt(this.i,this.l,D,"[Invalid Chunk]"),h=!1;break}else Gt(this.i,this.l,Ve,null),ti(this,Ve);if(sa(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Ee!=4||D.length!=0||this.h.h||(this.s=1,Re(16),h=!1),this.o=this.o&&h,!h)Gt(this.i,this.l,D,"[Invalid Chunked Response]"),Dt(this),Dn(this);else if(0<D.length&&!this.W){this.W=!0;var ve=this.j;ve.g==this&&ve.ba&&!ve.M&&(ve.j.info("Great, no buffering proxy detected. Bytes received: "+D.length),ai(ve),ve.M=!0,Re(11))}}else Gt(this.i,this.l,D,null),ti(this,D);Ee==4&&Dt(this),this.o&&!this.J&&(Ee==4?Oa(this.j,this):(this.o=!1,Sr(this)))}else _d(this.g),h==400&&0<D.indexOf("Unknown SID")?(this.s=3,Re(12)):(this.s=0,Re(13)),Dt(this),Dn(this)}}}catch{}finally{}};function sa(i){return i.g?i.u=="GET"&&i.L!=2&&i.j.Ca:!1}function ed(i,c){var h=i.C,f=c.indexOf(`
|
|
1565
|
-
`,h);return f==-1?Ys:(h=Number(c.substring(h,f)),isNaN(h)?na:(f+=1,f+h>c.length?Ys:(c=c.slice(f,f+h),i.C=f+h,c)))}ct.prototype.cancel=function(){this.J=!0,Dt(this)};function Sr(i){i.S=Date.now()+i.I,ia(i,i.I)}function ia(i,c){if(i.B!=null)throw Error("WatchDog timer not null");i.B=kn(E(i.ba,i),c)}function ei(i){i.B&&(u.clearTimeout(i.B),i.B=null)}ct.prototype.ba=function(){this.B=null;const i=Date.now();0<=i-this.S?(Yh(this.i,this.A),this.L!=2&&(Pn(),Re(17)),Dt(this),this.s=2,Dn(this)):ia(this,this.S-i)};function Dn(i){i.j.G==0||i.J||Oa(i.j,i)}function Dt(i){ei(i);var c=i.M;c&&typeof c.ma=="function"&&c.ma(),i.M=null,Go(i.U),i.g&&(c=i.g,i.g=null,c.abort(),c.ma())}function ti(i,c){try{var h=i.j;if(h.G!=0&&(h.g==i||ni(h.h,i))){if(!i.K&&ni(h.h,i)&&h.G==3){try{var f=h.Da.g.parse(c)}catch{f=null}if(Array.isArray(f)&&f.length==3){var I=f;if(I[0]==0){e:if(!h.u){if(h.g)if(h.g.F+3e3<i.F)Lr(h),Vr(h);else break e;oi(h),Re(18)}}else h.za=I[1],0<h.za-h.T&&37500>I[2]&&h.F&&h.v==0&&!h.C&&(h.C=kn(E(h.Za,h),6e3));if(1>=ca(h.h)&&h.ca){try{h.ca()}catch{}h.ca=void 0}}else Vt(h,11)}else if((i.K||h.g==i)&&Lr(h),!z(c))for(I=h.Da.g.parse(c),c=0;c<I.length;c++){let X=I[c];if(h.T=X[0],X=X[1],h.G==2)if(X[0]=="c"){h.K=X[1],h.ia=X[2];const ve=X[3];ve!=null&&(h.la=ve,h.j.info("VER="+h.la));const Ee=X[4];Ee!=null&&(h.Aa=Ee,h.j.info("SVER="+h.Aa));const Jt=X[5];Jt!=null&&typeof Jt=="number"&&0<Jt&&(f=1.5*Jt,h.L=f,h.j.info("backChannelRequestTimeoutMs_="+f)),f=h;const Ve=i.g;if(Ve){const Ur=Ve.g?Ve.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Ur){var R=f.h;R.g||Ur.indexOf("spdy")==-1&&Ur.indexOf("quic")==-1&&Ur.indexOf("h2")==-1||(R.j=R.l,R.g=new Set,R.h&&(ri(R,R.h),R.h=null))}if(f.D){const ci=Ve.g?Ve.g.getResponseHeader("X-HTTP-Session-Id"):null;ci&&(f.ya=ci,ee(f.I,f.D,ci))}}h.G=3,h.l&&h.l.ua(),h.ba&&(h.R=Date.now()-i.F,h.j.info("Handshake RTT: "+h.R+"ms")),f=h;var D=i;if(f.qa=Va(f,f.J?f.ia:null,f.W),D.K){ua(f.h,D);var Z=D,fe=f.L;fe&&(Z.I=fe),Z.B&&(ei(Z),Sr(Z)),f.g=D}else Pa(f);0<h.i.length&&Mr(h)}else X[0]!="stop"&&X[0]!="close"||Vt(h,7);else h.G==3&&(X[0]=="stop"||X[0]=="close"?X[0]=="stop"?Vt(h,7):ii(h):X[0]!="noop"&&h.l&&h.l.ta(X),h.v=0)}}Pn(4)}catch{}}var td=class{constructor(i,c){this.g=i,this.map=c}};function oa(i){this.l=i||10,u.PerformanceNavigationTiming?(i=u.performance.getEntriesByType("navigation"),i=0<i.length&&(i[0].nextHopProtocol=="hq"||i[0].nextHopProtocol=="h2")):i=!!(u.chrome&&u.chrome.loadTimes&&u.chrome.loadTimes()&&u.chrome.loadTimes().wasFetchedViaSpdy),this.j=i?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function aa(i){return i.h?!0:i.g?i.g.size>=i.j:!1}function ca(i){return i.h?1:i.g?i.g.size:0}function ni(i,c){return i.h?i.h==c:i.g?i.g.has(c):!1}function ri(i,c){i.g?i.g.add(c):i.h=c}function ua(i,c){i.h&&i.h==c?i.h=null:i.g&&i.g.has(c)&&i.g.delete(c)}oa.prototype.cancel=function(){if(this.i=la(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const i of this.g.values())i.cancel();this.g.clear()}};function la(i){if(i.h!=null)return i.i.concat(i.h.D);if(i.g!=null&&i.g.size!==0){let c=i.i;for(const h of i.g.values())c=c.concat(h.D);return c}return M(i.i)}function nd(i){if(i.V&&typeof i.V=="function")return i.V();if(typeof Map<"u"&&i instanceof Map||typeof Set<"u"&&i instanceof Set)return Array.from(i.values());if(typeof i=="string")return i.split("");if(l(i)){for(var c=[],h=i.length,f=0;f<h;f++)c.push(i[f]);return c}c=[],h=0;for(f in i)c[h++]=i[f];return c}function rd(i){if(i.na&&typeof i.na=="function")return i.na();if(!i.V||typeof i.V!="function"){if(typeof Map<"u"&&i instanceof Map)return Array.from(i.keys());if(!(typeof Set<"u"&&i instanceof Set)){if(l(i)||typeof i=="string"){var c=[];i=i.length;for(var h=0;h<i;h++)c.push(h);return c}c=[],h=0;for(const f in i)c[h++]=f;return c}}}function ha(i,c){if(i.forEach&&typeof i.forEach=="function")i.forEach(c,void 0);else if(l(i)||typeof i=="string")Array.prototype.forEach.call(i,c,void 0);else for(var h=rd(i),f=nd(i),I=f.length,R=0;R<I;R++)c.call(void 0,f[R],h&&h[R],i)}var da=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function sd(i,c){if(i){i=i.split("&");for(var h=0;h<i.length;h++){var f=i[h].indexOf("="),I=null;if(0<=f){var R=i[h].substring(0,f);I=i[h].substring(f+1)}else R=i[h];c(R,I?decodeURIComponent(I.replace(/\+/g," ")):"")}}}function Nt(i){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,i instanceof Nt){this.h=i.h,Cr(this,i.j),this.o=i.o,this.g=i.g,Pr(this,i.s),this.l=i.l;var c=i.i,h=new Mn;h.i=c.i,c.g&&(h.g=new Map(c.g),h.h=c.h),fa(this,h),this.m=i.m}else i&&(c=String(i).match(da))?(this.h=!1,Cr(this,c[1]||"",!0),this.o=Nn(c[2]||""),this.g=Nn(c[3]||"",!0),Pr(this,c[4]),this.l=Nn(c[5]||"",!0),fa(this,c[6]||"",!0),this.m=Nn(c[7]||"")):(this.h=!1,this.i=new Mn(null,this.h))}Nt.prototype.toString=function(){var i=[],c=this.j;c&&i.push(Vn(c,pa,!0),":");var h=this.g;return(h||c=="file")&&(i.push("//"),(c=this.o)&&i.push(Vn(c,pa,!0),"@"),i.push(encodeURIComponent(String(h)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),h=this.s,h!=null&&i.push(":",String(h))),(h=this.l)&&(this.g&&h.charAt(0)!="/"&&i.push("/"),i.push(Vn(h,h.charAt(0)=="/"?ad:od,!0))),(h=this.i.toString())&&i.push("?",h),(h=this.m)&&i.push("#",Vn(h,ud)),i.join("")};function Ke(i){return new Nt(i)}function Cr(i,c,h){i.j=h?Nn(c,!0):c,i.j&&(i.j=i.j.replace(/:$/,""))}function Pr(i,c){if(c){if(c=Number(c),isNaN(c)||0>c)throw Error("Bad port number "+c);i.s=c}else i.s=null}function fa(i,c,h){c instanceof Mn?(i.i=c,ld(i.i,i.h)):(h||(c=Vn(c,cd)),i.i=new Mn(c,i.h))}function ee(i,c,h){i.i.set(c,h)}function kr(i){return ee(i,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),i}function Nn(i,c){return i?c?decodeURI(i.replace(/%25/g,"%2525")):decodeURIComponent(i):""}function Vn(i,c,h){return typeof i=="string"?(i=encodeURI(i).replace(c,id),h&&(i=i.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),i):null}function id(i){return i=i.charCodeAt(0),"%"+(i>>4&15).toString(16)+(i&15).toString(16)}var pa=/[#\/\?@]/g,od=/[#\?:]/g,ad=/[#\?]/g,cd=/[#\?@]/g,ud=/#/g;function Mn(i,c){this.h=this.g=null,this.i=i||null,this.j=!!c}function ut(i){i.g||(i.g=new Map,i.h=0,i.i&&sd(i.i,function(c,h){i.add(decodeURIComponent(c.replace(/\+/g," ")),h)}))}n=Mn.prototype,n.add=function(i,c){ut(this),this.i=null,i=Kt(this,i);var h=this.g.get(i);return h||this.g.set(i,h=[]),h.push(c),this.h+=1,this};function ma(i,c){ut(i),c=Kt(i,c),i.g.has(c)&&(i.i=null,i.h-=i.g.get(c).length,i.g.delete(c))}function ga(i,c){return ut(i),c=Kt(i,c),i.g.has(c)}n.forEach=function(i,c){ut(this),this.g.forEach(function(h,f){h.forEach(function(I){i.call(c,I,f,this)},this)},this)},n.na=function(){ut(this);const i=Array.from(this.g.values()),c=Array.from(this.g.keys()),h=[];for(let f=0;f<c.length;f++){const I=i[f];for(let R=0;R<I.length;R++)h.push(c[f])}return h},n.V=function(i){ut(this);let c=[];if(typeof i=="string")ga(this,i)&&(c=c.concat(this.g.get(Kt(this,i))));else{i=Array.from(this.g.values());for(let h=0;h<i.length;h++)c=c.concat(i[h])}return c},n.set=function(i,c){return ut(this),this.i=null,i=Kt(this,i),ga(this,i)&&(this.h-=this.g.get(i).length),this.g.set(i,[c]),this.h+=1,this},n.get=function(i,c){return i?(i=this.V(i),0<i.length?String(i[0]):c):c};function _a(i,c,h){ma(i,c),0<h.length&&(i.i=null,i.g.set(Kt(i,c),M(h)),i.h+=h.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const i=[],c=Array.from(this.g.keys());for(var h=0;h<c.length;h++){var f=c[h];const R=encodeURIComponent(String(f)),D=this.V(f);for(f=0;f<D.length;f++){var I=R;D[f]!==""&&(I+="="+encodeURIComponent(String(D[f]))),i.push(I)}}return this.i=i.join("&")};function Kt(i,c){return c=String(c),i.j&&(c=c.toLowerCase()),c}function ld(i,c){c&&!i.j&&(ut(i),i.i=null,i.g.forEach(function(h,f){var I=f.toLowerCase();f!=I&&(ma(this,f),_a(this,I,h))},i)),i.j=c}function hd(i,c){const h=new On;if(u.Image){const f=new Image;f.onload=C(lt,h,"TestLoadImage: loaded",!0,c,f),f.onerror=C(lt,h,"TestLoadImage: error",!1,c,f),f.onabort=C(lt,h,"TestLoadImage: abort",!1,c,f),f.ontimeout=C(lt,h,"TestLoadImage: timeout",!1,c,f),u.setTimeout(function(){f.ontimeout&&f.ontimeout()},1e4),f.src=i}else c(!1)}function dd(i,c){const h=new On,f=new AbortController,I=setTimeout(()=>{f.abort(),lt(h,"TestPingServer: timeout",!1,c)},1e4);fetch(i,{signal:f.signal}).then(R=>{clearTimeout(I),R.ok?lt(h,"TestPingServer: ok",!0,c):lt(h,"TestPingServer: server error",!1,c)}).catch(()=>{clearTimeout(I),lt(h,"TestPingServer: error",!1,c)})}function lt(i,c,h,f,I){try{I&&(I.onload=null,I.onerror=null,I.onabort=null,I.ontimeout=null),f(h)}catch{}}function fd(){this.g=new Qh}function pd(i,c,h){const f=h||"";try{ha(i,function(I,R){let D=I;d(I)&&(D=Gs(I)),c.push(f+R+"="+encodeURIComponent(D))})}catch(I){throw c.push(f+"type="+encodeURIComponent("_badmap")),I}}function Or(i){this.l=i.Ub||null,this.j=i.eb||!1}V(Or,Ks),Or.prototype.g=function(){return new Dr(this.l,this.j)},Or.prototype.i=(function(i){return function(){return i}})({});function Dr(i,c){ye.call(this),this.D=i,this.o=c,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}V(Dr,ye),n=Dr.prototype,n.open=function(i,c){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=i,this.A=c,this.readyState=1,xn(this)},n.send=function(i){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const c={headers:this.u,method:this.B,credentials:this.m,cache:void 0};i&&(c.body=i),(this.D||u).fetch(new Request(this.A,c)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,Ln(this)),this.readyState=0},n.Sa=function(i){if(this.g&&(this.l=i,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=i.headers,this.readyState=2,xn(this)),this.g&&(this.readyState=3,xn(this),this.g)))if(this.responseType==="arraybuffer")i.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof u.ReadableStream<"u"&&"body"in i){if(this.j=i.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;ya(this)}else i.text().then(this.Ra.bind(this),this.ga.bind(this))};function ya(i){i.j.read().then(i.Pa.bind(i)).catch(i.ga.bind(i))}n.Pa=function(i){if(this.g){if(this.o&&i.value)this.response.push(i.value);else if(!this.o){var c=i.value?i.value:new Uint8Array(0);(c=this.v.decode(c,{stream:!i.done}))&&(this.response=this.responseText+=c)}i.done?Ln(this):xn(this),this.readyState==3&&ya(this)}},n.Ra=function(i){this.g&&(this.response=this.responseText=i,Ln(this))},n.Qa=function(i){this.g&&(this.response=i,Ln(this))},n.ga=function(){this.g&&Ln(this)};function Ln(i){i.readyState=4,i.l=null,i.j=null,i.v=null,xn(i)}n.setRequestHeader=function(i,c){this.u.append(i,c)},n.getResponseHeader=function(i){return this.h&&this.h.get(i.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const i=[],c=this.h.entries();for(var h=c.next();!h.done;)h=h.value,i.push(h[0]+": "+h[1]),h=c.next();return i.join(`\r
|
|
1566
|
-
`)};function
|
|
1565
|
+
`,h);return f==-1?Ys:(h=Number(c.substring(h,f)),isNaN(h)?na:(f+=1,f+h>c.length?Ys:(c=c.slice(f,f+h),i.C=f+h,c)))}ct.prototype.cancel=function(){this.J=!0,Dt(this)};function Sr(i){i.S=Date.now()+i.I,ia(i,i.I)}function ia(i,c){if(i.B!=null)throw Error("WatchDog timer not null");i.B=kn(E(i.ba,i),c)}function ei(i){i.B&&(u.clearTimeout(i.B),i.B=null)}ct.prototype.ba=function(){this.B=null;const i=Date.now();0<=i-this.S?(Yh(this.i,this.A),this.L!=2&&(Pn(),Re(17)),Dt(this),this.s=2,Dn(this)):ia(this,this.S-i)};function Dn(i){i.j.G==0||i.J||Oa(i.j,i)}function Dt(i){ei(i);var c=i.M;c&&typeof c.ma=="function"&&c.ma(),i.M=null,Go(i.U),i.g&&(c=i.g,i.g=null,c.abort(),c.ma())}function ti(i,c){try{var h=i.j;if(h.G!=0&&(h.g==i||ni(h.h,i))){if(!i.K&&ni(h.h,i)&&h.G==3){try{var f=h.Da.g.parse(c)}catch{f=null}if(Array.isArray(f)&&f.length==3){var I=f;if(I[0]==0){e:if(!h.u){if(h.g)if(h.g.F+3e3<i.F)xr(h),Vr(h);else break e;oi(h),Re(18)}}else h.za=I[1],0<h.za-h.T&&37500>I[2]&&h.F&&h.v==0&&!h.C&&(h.C=kn(E(h.Za,h),6e3));if(1>=ca(h.h)&&h.ca){try{h.ca()}catch{}h.ca=void 0}}else Vt(h,11)}else if((i.K||h.g==i)&&xr(h),!z(c))for(I=h.Da.g.parse(c),c=0;c<I.length;c++){let X=I[c];if(h.T=X[0],X=X[1],h.G==2)if(X[0]=="c"){h.K=X[1],h.ia=X[2];const ve=X[3];ve!=null&&(h.la=ve,h.j.info("VER="+h.la));const Ee=X[4];Ee!=null&&(h.Aa=Ee,h.j.info("SVER="+h.Aa));const Jt=X[5];Jt!=null&&typeof Jt=="number"&&0<Jt&&(f=1.5*Jt,h.L=f,h.j.info("backChannelRequestTimeoutMs_="+f)),f=h;const Ve=i.g;if(Ve){const Ur=Ve.g?Ve.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Ur){var R=f.h;R.g||Ur.indexOf("spdy")==-1&&Ur.indexOf("quic")==-1&&Ur.indexOf("h2")==-1||(R.j=R.l,R.g=new Set,R.h&&(ri(R,R.h),R.h=null))}if(f.D){const ci=Ve.g?Ve.g.getResponseHeader("X-HTTP-Session-Id"):null;ci&&(f.ya=ci,ee(f.I,f.D,ci))}}h.G=3,h.l&&h.l.ua(),h.ba&&(h.R=Date.now()-i.F,h.j.info("Handshake RTT: "+h.R+"ms")),f=h;var D=i;if(f.qa=Va(f,f.J?f.ia:null,f.W),D.K){ua(f.h,D);var Z=D,fe=f.L;fe&&(Z.I=fe),Z.B&&(ei(Z),Sr(Z)),f.g=D}else Pa(f);0<h.i.length&&Mr(h)}else X[0]!="stop"&&X[0]!="close"||Vt(h,7);else h.G==3&&(X[0]=="stop"||X[0]=="close"?X[0]=="stop"?Vt(h,7):ii(h):X[0]!="noop"&&h.l&&h.l.ta(X),h.v=0)}}Pn(4)}catch{}}var td=class{constructor(i,c){this.g=i,this.map=c}};function oa(i){this.l=i||10,u.PerformanceNavigationTiming?(i=u.performance.getEntriesByType("navigation"),i=0<i.length&&(i[0].nextHopProtocol=="hq"||i[0].nextHopProtocol=="h2")):i=!!(u.chrome&&u.chrome.loadTimes&&u.chrome.loadTimes()&&u.chrome.loadTimes().wasFetchedViaSpdy),this.j=i?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function aa(i){return i.h?!0:i.g?i.g.size>=i.j:!1}function ca(i){return i.h?1:i.g?i.g.size:0}function ni(i,c){return i.h?i.h==c:i.g?i.g.has(c):!1}function ri(i,c){i.g?i.g.add(c):i.h=c}function ua(i,c){i.h&&i.h==c?i.h=null:i.g&&i.g.has(c)&&i.g.delete(c)}oa.prototype.cancel=function(){if(this.i=la(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const i of this.g.values())i.cancel();this.g.clear()}};function la(i){if(i.h!=null)return i.i.concat(i.h.D);if(i.g!=null&&i.g.size!==0){let c=i.i;for(const h of i.g.values())c=c.concat(h.D);return c}return M(i.i)}function nd(i){if(i.V&&typeof i.V=="function")return i.V();if(typeof Map<"u"&&i instanceof Map||typeof Set<"u"&&i instanceof Set)return Array.from(i.values());if(typeof i=="string")return i.split("");if(l(i)){for(var c=[],h=i.length,f=0;f<h;f++)c.push(i[f]);return c}c=[],h=0;for(f in i)c[h++]=i[f];return c}function rd(i){if(i.na&&typeof i.na=="function")return i.na();if(!i.V||typeof i.V!="function"){if(typeof Map<"u"&&i instanceof Map)return Array.from(i.keys());if(!(typeof Set<"u"&&i instanceof Set)){if(l(i)||typeof i=="string"){var c=[];i=i.length;for(var h=0;h<i;h++)c.push(h);return c}c=[],h=0;for(const f in i)c[h++]=f;return c}}}function ha(i,c){if(i.forEach&&typeof i.forEach=="function")i.forEach(c,void 0);else if(l(i)||typeof i=="string")Array.prototype.forEach.call(i,c,void 0);else for(var h=rd(i),f=nd(i),I=f.length,R=0;R<I;R++)c.call(void 0,f[R],h&&h[R],i)}var da=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function sd(i,c){if(i){i=i.split("&");for(var h=0;h<i.length;h++){var f=i[h].indexOf("="),I=null;if(0<=f){var R=i[h].substring(0,f);I=i[h].substring(f+1)}else R=i[h];c(R,I?decodeURIComponent(I.replace(/\+/g," ")):"")}}}function Nt(i){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,i instanceof Nt){this.h=i.h,Cr(this,i.j),this.o=i.o,this.g=i.g,Pr(this,i.s),this.l=i.l;var c=i.i,h=new Mn;h.i=c.i,c.g&&(h.g=new Map(c.g),h.h=c.h),fa(this,h),this.m=i.m}else i&&(c=String(i).match(da))?(this.h=!1,Cr(this,c[1]||"",!0),this.o=Nn(c[2]||""),this.g=Nn(c[3]||"",!0),Pr(this,c[4]),this.l=Nn(c[5]||"",!0),fa(this,c[6]||"",!0),this.m=Nn(c[7]||"")):(this.h=!1,this.i=new Mn(null,this.h))}Nt.prototype.toString=function(){var i=[],c=this.j;c&&i.push(Vn(c,pa,!0),":");var h=this.g;return(h||c=="file")&&(i.push("//"),(c=this.o)&&i.push(Vn(c,pa,!0),"@"),i.push(encodeURIComponent(String(h)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),h=this.s,h!=null&&i.push(":",String(h))),(h=this.l)&&(this.g&&h.charAt(0)!="/"&&i.push("/"),i.push(Vn(h,h.charAt(0)=="/"?ad:od,!0))),(h=this.i.toString())&&i.push("?",h),(h=this.m)&&i.push("#",Vn(h,ud)),i.join("")};function Ke(i){return new Nt(i)}function Cr(i,c,h){i.j=h?Nn(c,!0):c,i.j&&(i.j=i.j.replace(/:$/,""))}function Pr(i,c){if(c){if(c=Number(c),isNaN(c)||0>c)throw Error("Bad port number "+c);i.s=c}else i.s=null}function fa(i,c,h){c instanceof Mn?(i.i=c,ld(i.i,i.h)):(h||(c=Vn(c,cd)),i.i=new Mn(c,i.h))}function ee(i,c,h){i.i.set(c,h)}function kr(i){return ee(i,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),i}function Nn(i,c){return i?c?decodeURI(i.replace(/%25/g,"%2525")):decodeURIComponent(i):""}function Vn(i,c,h){return typeof i=="string"?(i=encodeURI(i).replace(c,id),h&&(i=i.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),i):null}function id(i){return i=i.charCodeAt(0),"%"+(i>>4&15).toString(16)+(i&15).toString(16)}var pa=/[#\/\?@]/g,od=/[#\?:]/g,ad=/[#\?]/g,cd=/[#\?@]/g,ud=/#/g;function Mn(i,c){this.h=this.g=null,this.i=i||null,this.j=!!c}function ut(i){i.g||(i.g=new Map,i.h=0,i.i&&sd(i.i,function(c,h){i.add(decodeURIComponent(c.replace(/\+/g," ")),h)}))}n=Mn.prototype,n.add=function(i,c){ut(this),this.i=null,i=Kt(this,i);var h=this.g.get(i);return h||this.g.set(i,h=[]),h.push(c),this.h+=1,this};function ma(i,c){ut(i),c=Kt(i,c),i.g.has(c)&&(i.i=null,i.h-=i.g.get(c).length,i.g.delete(c))}function ga(i,c){return ut(i),c=Kt(i,c),i.g.has(c)}n.forEach=function(i,c){ut(this),this.g.forEach(function(h,f){h.forEach(function(I){i.call(c,I,f,this)},this)},this)},n.na=function(){ut(this);const i=Array.from(this.g.values()),c=Array.from(this.g.keys()),h=[];for(let f=0;f<c.length;f++){const I=i[f];for(let R=0;R<I.length;R++)h.push(c[f])}return h},n.V=function(i){ut(this);let c=[];if(typeof i=="string")ga(this,i)&&(c=c.concat(this.g.get(Kt(this,i))));else{i=Array.from(this.g.values());for(let h=0;h<i.length;h++)c=c.concat(i[h])}return c},n.set=function(i,c){return ut(this),this.i=null,i=Kt(this,i),ga(this,i)&&(this.h-=this.g.get(i).length),this.g.set(i,[c]),this.h+=1,this},n.get=function(i,c){return i?(i=this.V(i),0<i.length?String(i[0]):c):c};function _a(i,c,h){ma(i,c),0<h.length&&(i.i=null,i.g.set(Kt(i,c),M(h)),i.h+=h.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const i=[],c=Array.from(this.g.keys());for(var h=0;h<c.length;h++){var f=c[h];const R=encodeURIComponent(String(f)),D=this.V(f);for(f=0;f<D.length;f++){var I=R;D[f]!==""&&(I+="="+encodeURIComponent(String(D[f]))),i.push(I)}}return this.i=i.join("&")};function Kt(i,c){return c=String(c),i.j&&(c=c.toLowerCase()),c}function ld(i,c){c&&!i.j&&(ut(i),i.i=null,i.g.forEach(function(h,f){var I=f.toLowerCase();f!=I&&(ma(this,f),_a(this,I,h))},i)),i.j=c}function hd(i,c){const h=new On;if(u.Image){const f=new Image;f.onload=C(lt,h,"TestLoadImage: loaded",!0,c,f),f.onerror=C(lt,h,"TestLoadImage: error",!1,c,f),f.onabort=C(lt,h,"TestLoadImage: abort",!1,c,f),f.ontimeout=C(lt,h,"TestLoadImage: timeout",!1,c,f),u.setTimeout(function(){f.ontimeout&&f.ontimeout()},1e4),f.src=i}else c(!1)}function dd(i,c){const h=new On,f=new AbortController,I=setTimeout(()=>{f.abort(),lt(h,"TestPingServer: timeout",!1,c)},1e4);fetch(i,{signal:f.signal}).then(R=>{clearTimeout(I),R.ok?lt(h,"TestPingServer: ok",!0,c):lt(h,"TestPingServer: server error",!1,c)}).catch(()=>{clearTimeout(I),lt(h,"TestPingServer: error",!1,c)})}function lt(i,c,h,f,I){try{I&&(I.onload=null,I.onerror=null,I.onabort=null,I.ontimeout=null),f(h)}catch{}}function fd(){this.g=new Qh}function pd(i,c,h){const f=h||"";try{ha(i,function(I,R){let D=I;d(I)&&(D=Gs(I)),c.push(f+R+"="+encodeURIComponent(D))})}catch(I){throw c.push(f+"type="+encodeURIComponent("_badmap")),I}}function Or(i){this.l=i.Ub||null,this.j=i.eb||!1}V(Or,Ks),Or.prototype.g=function(){return new Dr(this.l,this.j)},Or.prototype.i=(function(i){return function(){return i}})({});function Dr(i,c){ye.call(this),this.D=i,this.o=c,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}V(Dr,ye),n=Dr.prototype,n.open=function(i,c){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=i,this.A=c,this.readyState=1,Ln(this)},n.send=function(i){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const c={headers:this.u,method:this.B,credentials:this.m,cache:void 0};i&&(c.body=i),(this.D||u).fetch(new Request(this.A,c)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,xn(this)),this.readyState=0},n.Sa=function(i){if(this.g&&(this.l=i,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=i.headers,this.readyState=2,Ln(this)),this.g&&(this.readyState=3,Ln(this),this.g)))if(this.responseType==="arraybuffer")i.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof u.ReadableStream<"u"&&"body"in i){if(this.j=i.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;ya(this)}else i.text().then(this.Ra.bind(this),this.ga.bind(this))};function ya(i){i.j.read().then(i.Pa.bind(i)).catch(i.ga.bind(i))}n.Pa=function(i){if(this.g){if(this.o&&i.value)this.response.push(i.value);else if(!this.o){var c=i.value?i.value:new Uint8Array(0);(c=this.v.decode(c,{stream:!i.done}))&&(this.response=this.responseText+=c)}i.done?xn(this):Ln(this),this.readyState==3&&ya(this)}},n.Ra=function(i){this.g&&(this.response=this.responseText=i,xn(this))},n.Qa=function(i){this.g&&(this.response=i,xn(this))},n.ga=function(){this.g&&xn(this)};function xn(i){i.readyState=4,i.l=null,i.j=null,i.v=null,Ln(i)}n.setRequestHeader=function(i,c){this.u.append(i,c)},n.getResponseHeader=function(i){return this.h&&this.h.get(i.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const i=[],c=this.h.entries();for(var h=c.next();!h.done;)h=h.value,i.push(h[0]+": "+h[1]),h=c.next();return i.join(`\r
|
|
1566
|
+
`)};function Ln(i){i.onreadystatechange&&i.onreadystatechange.call(i)}Object.defineProperty(Dr.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(i){this.m=i?"include":"same-origin"}});function va(i){let c="";return P(i,function(h,f){c+=f,c+=":",c+=h,c+=`\r
|
|
1567
1567
|
`}),c}function si(i,c,h){e:{for(f in h){var f=!1;break e}f=!0}f||(h=va(h),typeof i=="string"?h!=null&&encodeURIComponent(String(h)):ee(i,c,h))}function re(i){ye.call(this),this.headers=new Map,this.o=i||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}V(re,ye);var md=/^https?$/i,gd=["POST","PUT"];n=re.prototype,n.Ha=function(i){this.J=i},n.ea=function(i,c,h,f){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+i);c=c?c.toUpperCase():"GET",this.D=i,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Xs.g(),this.v=this.o?Ko(this.o):Ko(Xs),this.g.onreadystatechange=E(this.Ea,this);try{this.B=!0,this.g.open(c,String(i),!0),this.B=!1}catch(R){Ea(this,R);return}if(i=h||"",h=new Map(this.headers),f)if(Object.getPrototypeOf(f)===Object.prototype)for(var I in f)h.set(I,f[I]);else if(typeof f.keys=="function"&&typeof f.get=="function")for(const R of f.keys())h.set(R,f.get(R));else throw Error("Unknown input type for opt_headers: "+String(f));f=Array.from(h.keys()).find(R=>R.toLowerCase()=="content-type"),I=u.FormData&&i instanceof u.FormData,!(0<=Array.prototype.indexOf.call(gd,c,void 0))||f||I||h.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[R,D]of h)this.g.setRequestHeader(R,D);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Ia(this),this.u=!0,this.g.send(i),this.u=!1}catch(R){Ea(this,R)}};function Ea(i,c){i.h=!1,i.g&&(i.j=!0,i.g.abort(),i.j=!1),i.l=c,i.m=5,Ta(i),Nr(i)}function Ta(i){i.A||(i.A=!0,be(i,"complete"),be(i,"error"))}n.abort=function(i){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=i||7,be(this,"complete"),be(this,"abort"),Nr(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Nr(this,!0)),re.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?wa(this):this.bb())},n.bb=function(){wa(this)};function wa(i){if(i.h&&typeof a<"u"&&(!i.v[1]||Qe(i)!=4||i.Z()!=2)){if(i.u&&Qe(i)==4)zo(i.Ea,0,i);else if(be(i,"readystatechange"),Qe(i)==4){i.h=!1;try{const D=i.Z();e:switch(D){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var c=!0;break e;default:c=!1}var h;if(!(h=c)){var f;if(f=D===0){var I=String(i.D).match(da)[1]||null;!I&&u.self&&u.self.location&&(I=u.self.location.protocol.slice(0,-1)),f=!md.test(I?I.toLowerCase():"")}h=f}if(h)be(i,"complete"),be(i,"success");else{i.m=6;try{var R=2<Qe(i)?i.g.statusText:""}catch{R=""}i.l=R+" ["+i.Z()+"]",Ta(i)}}finally{Nr(i)}}}}function Nr(i,c){if(i.g){Ia(i);const h=i.g,f=i.v[0]?()=>{}:null;i.g=null,i.v=null,c||be(i,"ready");try{h.onreadystatechange=f}catch{}}}function Ia(i){i.I&&(u.clearTimeout(i.I),i.I=null)}n.isActive=function(){return!!this.g};function Qe(i){return i.g?i.g.readyState:0}n.Z=function(){try{return 2<Qe(this)?this.g.status:-1}catch{return-1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.Oa=function(i){if(this.g){var c=this.g.responseText;return i&&c.indexOf(i)==0&&(c=c.substring(i.length)),Kh(c)}};function Aa(i){try{if(!i.g)return null;if("response"in i.g)return i.g.response;switch(i.H){case"":case"text":return i.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in i.g)return i.g.mozResponseArrayBuffer}return null}catch{return null}}function _d(i){const c={};i=(i.g&&2<=Qe(i)&&i.g.getAllResponseHeaders()||"").split(`\r
|
|
1568
|
-
`);for(let f=0;f<i.length;f++){if(z(i[f]))continue;var h=w(i[f]);const I=h[0];if(h=h[1],typeof h!="string")continue;h=h.trim();const R=c[I]||[];c[I]=R,R.push(h)}_(c,function(f){return f.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Un(i,c,h){return h&&h.internalChannelParams&&h.internalChannelParams[i]||c}function ba(i){this.Aa=0,this.i=[],this.j=new On,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Un("failFast",!1,i),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Un("baseRetryDelayMs",5e3,i),this.cb=Un("retryDelaySeedMs",1e4,i),this.Wa=Un("forwardChannelMaxRetries",2,i),this.wa=Un("forwardChannelRequestTimeoutMs",2e4,i),this.pa=i&&i.xmlHttpFactory||void 0,this.Xa=i&&i.Tb||void 0,this.Ca=i&&i.useFetchStreams||!1,this.L=void 0,this.J=i&&i.supportsCrossDomainXhr||!1,this.K="",this.h=new oa(i&&i.concurrentRequestLimit),this.Da=new fd,this.P=i&&i.fastHandshake||!1,this.O=i&&i.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=i&&i.Rb||!1,i&&i.xa&&this.j.xa(),i&&i.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&i&&i.detectBufferingProxy||!1,this.ja=void 0,i&&i.longPollingTimeout&&0<i.longPollingTimeout&&(this.ja=i.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=ba.prototype,n.la=8,n.G=1,n.connect=function(i,c,h,f){Re(0),this.W=i,this.H=c||{},h&&f!==void 0&&(this.H.OSID=h,this.H.OAID=f),this.F=this.X,this.I=Va(this,null,this.W),Mr(this)};function ii(i){if(Ra(i),i.G==3){var c=i.U++,h=Ke(i.I);if(ee(h,"SID",i.K),ee(h,"RID",c),ee(h,"TYPE","terminate"),Fn(i,h),c=new ct(i,i.j,c),c.L=2,c.v=kr(Ke(h)),h=!1,u.navigator&&u.navigator.sendBeacon)try{h=u.navigator.sendBeacon(c.v.toString(),"")}catch{}!h&&u.Image&&(new Image().src=c.v,h=!0),h||(c.g=Ma(c.j,null),c.g.ea(c.v)),c.F=Date.now(),Sr(c)}Na(i)}function Vr(i){i.g&&(ai(i),i.g.cancel(),i.g=null)}function Ra(i){Vr(i),i.u&&(u.clearTimeout(i.u),i.u=null),
|
|
1568
|
+
`);for(let f=0;f<i.length;f++){if(z(i[f]))continue;var h=w(i[f]);const I=h[0];if(h=h[1],typeof h!="string")continue;h=h.trim();const R=c[I]||[];c[I]=R,R.push(h)}_(c,function(f){return f.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Un(i,c,h){return h&&h.internalChannelParams&&h.internalChannelParams[i]||c}function ba(i){this.Aa=0,this.i=[],this.j=new On,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Un("failFast",!1,i),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Un("baseRetryDelayMs",5e3,i),this.cb=Un("retryDelaySeedMs",1e4,i),this.Wa=Un("forwardChannelMaxRetries",2,i),this.wa=Un("forwardChannelRequestTimeoutMs",2e4,i),this.pa=i&&i.xmlHttpFactory||void 0,this.Xa=i&&i.Tb||void 0,this.Ca=i&&i.useFetchStreams||!1,this.L=void 0,this.J=i&&i.supportsCrossDomainXhr||!1,this.K="",this.h=new oa(i&&i.concurrentRequestLimit),this.Da=new fd,this.P=i&&i.fastHandshake||!1,this.O=i&&i.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=i&&i.Rb||!1,i&&i.xa&&this.j.xa(),i&&i.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&i&&i.detectBufferingProxy||!1,this.ja=void 0,i&&i.longPollingTimeout&&0<i.longPollingTimeout&&(this.ja=i.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=ba.prototype,n.la=8,n.G=1,n.connect=function(i,c,h,f){Re(0),this.W=i,this.H=c||{},h&&f!==void 0&&(this.H.OSID=h,this.H.OAID=f),this.F=this.X,this.I=Va(this,null,this.W),Mr(this)};function ii(i){if(Ra(i),i.G==3){var c=i.U++,h=Ke(i.I);if(ee(h,"SID",i.K),ee(h,"RID",c),ee(h,"TYPE","terminate"),Fn(i,h),c=new ct(i,i.j,c),c.L=2,c.v=kr(Ke(h)),h=!1,u.navigator&&u.navigator.sendBeacon)try{h=u.navigator.sendBeacon(c.v.toString(),"")}catch{}!h&&u.Image&&(new Image().src=c.v,h=!0),h||(c.g=Ma(c.j,null),c.g.ea(c.v)),c.F=Date.now(),Sr(c)}Na(i)}function Vr(i){i.g&&(ai(i),i.g.cancel(),i.g=null)}function Ra(i){Vr(i),i.u&&(u.clearTimeout(i.u),i.u=null),xr(i),i.h.cancel(),i.s&&(typeof i.s=="number"&&u.clearTimeout(i.s),i.s=null)}function Mr(i){if(!aa(i.h)&&!i.s){i.s=!0;var c=i.Ga;An||Fo(),bn||(An(),bn=!0),Fs.add(c,i),i.B=0}}function yd(i,c){return ca(i.h)>=i.h.j-(i.s?1:0)?!1:i.s?(i.i=c.D.concat(i.i),!0):i.G==1||i.G==2||i.B>=(i.Va?0:i.Wa)?!1:(i.s=kn(E(i.Ga,i,c),Da(i,i.B)),i.B++,!0)}n.Ga=function(i){if(this.s)if(this.s=null,this.G==1){if(!i){this.U=Math.floor(1e5*Math.random()),i=this.U++;const I=new ct(this,this.j,i);let R=this.o;if(this.S&&(R?(R=m(R),T(R,this.S)):R=this.S),this.m!==null||this.O||(I.H=R,R=null),this.P)e:{for(var c=0,h=0;h<this.i.length;h++){t:{var f=this.i[h];if("__data__"in f.map&&(f=f.map.__data__,typeof f=="string")){f=f.length;break t}f=void 0}if(f===void 0)break;if(c+=f,4096<c){c=h;break e}if(c===4096||h===this.i.length-1){c=h+1;break e}}c=1e3}else c=1e3;c=Ca(this,I,c),h=Ke(this.I),ee(h,"RID",i),ee(h,"CVER",22),this.D&&ee(h,"X-HTTP-Session-Id",this.D),Fn(this,h),R&&(this.O?c="headers="+encodeURIComponent(String(va(R)))+"&"+c:this.m&&si(h,this.m,R)),ri(this.h,I),this.Ua&&ee(h,"TYPE","init"),this.P?(ee(h,"$req",c),ee(h,"SID","null"),I.T=!0,Zs(I,h,null)):Zs(I,h,c),this.G=2}}else this.G==3&&(i?Sa(this,i):this.i.length==0||aa(this.h)||Sa(this))};function Sa(i,c){var h;c?h=c.l:h=i.U++;const f=Ke(i.I);ee(f,"SID",i.K),ee(f,"RID",h),ee(f,"AID",i.T),Fn(i,f),i.m&&i.o&&si(f,i.m,i.o),h=new ct(i,i.j,h,i.B+1),i.m===null&&(h.H=i.o),c&&(i.i=c.D.concat(i.i)),c=Ca(i,h,1e3),h.I=Math.round(.5*i.wa)+Math.round(.5*i.wa*Math.random()),ri(i.h,h),Zs(h,f,c)}function Fn(i,c){i.H&&P(i.H,function(h,f){ee(c,f,h)}),i.l&&ha({},function(h,f){ee(c,f,h)})}function Ca(i,c,h){h=Math.min(i.i.length,h);var f=i.l?E(i.l.Na,i.l,i):null;e:{var I=i.i;let R=-1;for(;;){const D=["count="+h];R==-1?0<h?(R=I[0].g,D.push("ofs="+R)):R=0:D.push("ofs="+R);let Z=!0;for(let fe=0;fe<h;fe++){let X=I[fe].g;const ve=I[fe].map;if(X-=R,0>X)R=Math.max(0,I[fe].g-100),Z=!1;else try{pd(ve,D,"req"+X+"_")}catch{f&&f(ve)}}if(Z){f=D.join("&");break e}}}return i=i.i.splice(0,h),c.D=i,f}function Pa(i){if(!i.g&&!i.u){i.Y=1;var c=i.Fa;An||Fo(),bn||(An(),bn=!0),Fs.add(c,i),i.v=0}}function oi(i){return i.g||i.u||3<=i.v?!1:(i.Y++,i.u=kn(E(i.Fa,i),Da(i,i.v)),i.v++,!0)}n.Fa=function(){if(this.u=null,ka(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var i=2*this.R;this.j.info("BP detection timer enabled: "+i),this.A=kn(E(this.ab,this),i)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Re(10),Vr(this),ka(this))};function ai(i){i.A!=null&&(u.clearTimeout(i.A),i.A=null)}function ka(i){i.g=new ct(i,i.j,"rpc",i.Y),i.m===null&&(i.g.H=i.o),i.g.O=0;var c=Ke(i.qa);ee(c,"RID","rpc"),ee(c,"SID",i.K),ee(c,"AID",i.T),ee(c,"CI",i.F?"0":"1"),!i.F&&i.ja&&ee(c,"TO",i.ja),ee(c,"TYPE","xmlhttp"),Fn(i,c),i.m&&i.o&&si(c,i.m,i.o),i.L&&(i.g.I=i.L);var h=i.g;i=i.ia,h.L=1,h.v=kr(Ke(c)),h.m=null,h.P=!0,ra(h,i)}n.Za=function(){this.C!=null&&(this.C=null,Vr(this),oi(this),Re(19))};function xr(i){i.C!=null&&(u.clearTimeout(i.C),i.C=null)}function Oa(i,c){var h=null;if(i.g==c){xr(i),ai(i),i.g=null;var f=2}else if(ni(i.h,c))h=c.D,ua(i.h,c),f=1;else return;if(i.G!=0){if(c.o)if(f==1){h=c.m?c.m.length:0,c=Date.now()-c.F;var I=i.B;f=Ar(),be(f,new Zo(f,h)),Mr(i)}else Pa(i);else if(I=c.s,I==3||I==0&&0<c.X||!(f==1&&yd(i,c)||f==2&&oi(i)))switch(h&&0<h.length&&(c=i.h,c.i=c.i.concat(h)),I){case 1:Vt(i,5);break;case 4:Vt(i,10);break;case 3:Vt(i,6);break;default:Vt(i,2)}}}function Da(i,c){let h=i.Ta+Math.floor(Math.random()*i.cb);return i.isActive()||(h*=2),h*c}function Vt(i,c){if(i.j.info("Error code "+c),c==2){var h=E(i.fb,i),f=i.Xa;const I=!f;f=new Nt(f||"//www.google.com/images/cleardot.gif"),u.location&&u.location.protocol=="http"||Cr(f,"https"),kr(f),I?hd(f.toString(),h):dd(f.toString(),h)}else Re(2);i.G=0,i.l&&i.l.sa(c),Na(i),Ra(i)}n.fb=function(i){i?(this.j.info("Successfully pinged google.com"),Re(2)):(this.j.info("Failed to ping google.com"),Re(1))};function Na(i){if(i.G=0,i.ka=[],i.l){const c=la(i.h);(c.length!=0||i.i.length!=0)&&(k(i.ka,c),k(i.ka,i.i),i.h.i.length=0,M(i.i),i.i.length=0),i.l.ra()}}function Va(i,c,h){var f=h instanceof Nt?Ke(h):new Nt(h);if(f.g!="")c&&(f.g=c+"."+f.g),Pr(f,f.s);else{var I=u.location;f=I.protocol,c=c?c+"."+I.hostname:I.hostname,I=+I.port;var R=new Nt(null);f&&Cr(R,f),c&&(R.g=c),I&&Pr(R,I),h&&(R.l=h),f=R}return h=i.D,c=i.ya,h&&c&&ee(f,h,c),ee(f,"VER",i.la),Fn(i,f),f}function Ma(i,c,h){if(c&&!i.J)throw Error("Can't create secondary domain capable XhrIo object.");return c=i.Ca&&!i.pa?new re(new Or({eb:h})):new re(i.pa),c.Ha(i.J),c}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function xa(){}n=xa.prototype,n.ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){};function Lr(){}Lr.prototype.g=function(i,c){return new Oe(i,c)};function Oe(i,c){ye.call(this),this.g=new ba(c),this.l=i,this.h=c&&c.messageUrlParams||null,i=c&&c.messageHeaders||null,c&&c.clientProtocolHeaderRequired&&(i?i["X-Client-Protocol"]="webchannel":i={"X-Client-Protocol":"webchannel"}),this.g.o=i,i=c&&c.initMessageHeaders||null,c&&c.messageContentType&&(i?i["X-WebChannel-Content-Type"]=c.messageContentType:i={"X-WebChannel-Content-Type":c.messageContentType}),c&&c.va&&(i?i["X-WebChannel-Client-Profile"]=c.va:i={"X-WebChannel-Client-Profile":c.va}),this.g.S=i,(i=c&&c.Sb)&&!z(i)&&(this.g.m=i),this.v=c&&c.supportsCrossDomainXhr||!1,this.u=c&&c.sendRawJson||!1,(c=c&&c.httpSessionIdParam)&&!z(c)&&(this.g.D=c,i=this.h,i!==null&&c in i&&(i=this.h,c in i&&delete i[c])),this.j=new Qt(this)}V(Oe,ye),Oe.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Oe.prototype.close=function(){ii(this.g)},Oe.prototype.o=function(i){var c=this.g;if(typeof i=="string"){var h={};h.__data__=i,i=h}else this.u&&(h={},h.__data__=Gs(i),i=h);c.i.push(new td(c.Ya++,i)),c.G==3&&Mr(c)},Oe.prototype.N=function(){this.g.l=null,delete this.j,ii(this.g),delete this.g,Oe.aa.N.call(this)};function La(i){Qs.call(this),i.__headers__&&(this.headers=i.__headers__,this.statusCode=i.__status__,delete i.__headers__,delete i.__status__);var c=i.__sm__;if(c){e:{for(const h in c){i=h;break e}i=void 0}(this.i=i)&&(i=this.i,c=c!==null&&i in c?c[i]:void 0),this.data=c}else this.data=i}V(La,Qs);function Ua(){Js.call(this),this.status=1}V(Ua,Js);function Qt(i){this.g=i}V(Qt,xa),Qt.prototype.ua=function(){be(this.g,"a")},Qt.prototype.ta=function(i){be(this.g,new La(i))},Qt.prototype.sa=function(i){be(this.g,new Ua)},Qt.prototype.ra=function(){be(this.g,"b")},Lr.prototype.createWebChannel=Lr.prototype.g,Oe.prototype.send=Oe.prototype.o,Oe.prototype.open=Oe.prototype.m,Oe.prototype.close=Oe.prototype.close,Cl=function(){return new Lr},Sl=function(){return Ar()},Rl=Ot,Ni={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},br.NO_ERROR=0,br.TIMEOUT=8,br.HTTP_ERROR=6,Jr=br,ea.COMPLETE="complete",bl=ea,Qo.EventType=Cn,Cn.OPEN="a",Cn.CLOSE="b",Cn.ERROR="c",Cn.MESSAGE="d",ye.prototype.listen=ye.prototype.K,$n=Qo,re.prototype.listenOnce=re.prototype.L,re.prototype.getLastError=re.prototype.Ka,re.prototype.getLastErrorCode=re.prototype.Ba,re.prototype.getStatus=re.prototype.Z,re.prototype.getResponseJson=re.prototype.Oa,re.prototype.getResponseText=re.prototype.oa,re.prototype.send=re.prototype.ea,re.prototype.setWithCredentials=re.prototype.Ha,Al=re}).apply(typeof jr<"u"?jr:typeof self<"u"?self:typeof window<"u"?window:{});const bc="@firebase/firestore",Rc="4.8.0";/**
|
|
1569
1569
|
* @license
|
|
1570
1570
|
* Copyright 2017 Google LLC
|
|
1571
1571
|
*
|
|
@@ -1610,7 +1610,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1610
1610
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1611
1611
|
* See the License for the specific language governing permissions and
|
|
1612
1612
|
* limitations under the License.
|
|
1613
|
-
*/const Ht=new Zi("@firebase/firestore");function Yt(){return Ht.logLevel}function
|
|
1613
|
+
*/const Ht=new Zi("@firebase/firestore");function Yt(){return Ht.logLevel}function x(n,...e){if(Ht.logLevel<=G.DEBUG){const t=e.map(po);Ht.debug(`Firestore (${En}): ${n}`,...t)}}function nt(n,...e){if(Ht.logLevel<=G.ERROR){const t=e.map(po);Ht.error(`Firestore (${En}): ${n}`,...t)}}function It(n,...e){if(Ht.logLevel<=G.WARN){const t=e.map(po);Ht.warn(`Firestore (${En}): ${n}`,...t)}}function po(n){if(typeof n=="string")return n;try{/**
|
|
1614
1614
|
* @license
|
|
1615
1615
|
* Copyright 2020 Google LLC
|
|
1616
1616
|
*
|
|
@@ -1655,7 +1655,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1655
1655
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1656
1656
|
* See the License for the specific language governing permissions and
|
|
1657
1657
|
* limitations under the License.
|
|
1658
|
-
*/const N={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class
|
|
1658
|
+
*/const N={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class L extends st{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
|
|
1659
1659
|
* @license
|
|
1660
1660
|
* Copyright 2017 Google LLC
|
|
1661
1661
|
*
|
|
@@ -1685,7 +1685,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1685
1685
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1686
1686
|
* See the License for the specific language governing permissions and
|
|
1687
1687
|
* limitations under the License.
|
|
1688
|
-
*/class kl{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Xg{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(we.UNAUTHENTICATED)))}shutdown(){}}class Yg{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class Zg{constructor(e){this.t=e,this.currentUser=we.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){ne(this.o===void 0,42304);let r=this.i;const s=l=>this.i!==r?(r=this.i,t(l)):Promise.resolve();let o=new on;this.o=()=>{this.i++,this.currentUser=this.u(),o.resolve(),o=new on,e.enqueueRetryable((()=>s(this.currentUser)))};const a=()=>{const l=o;e.enqueueRetryable((async()=>{await l.promise,await s(this.currentUser)}))},u=l=>{
|
|
1688
|
+
*/class kl{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Xg{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(we.UNAUTHENTICATED)))}shutdown(){}}class Yg{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class Zg{constructor(e){this.t=e,this.currentUser=we.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){ne(this.o===void 0,42304);let r=this.i;const s=l=>this.i!==r?(r=this.i,t(l)):Promise.resolve();let o=new on;this.o=()=>{this.i++,this.currentUser=this.u(),o.resolve(),o=new on,e.enqueueRetryable((()=>s(this.currentUser)))};const a=()=>{const l=o;e.enqueueRetryable((async()=>{await l.promise,await s(this.currentUser)}))},u=l=>{x("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=l,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((l=>u(l))),setTimeout((()=>{if(!this.auth){const l=this.t.getImmediate({optional:!0});l?u(l):(x("FirebaseAuthCredentialsProvider","Auth not yet detected"),o.resolve(),o=new on)}}),0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((r=>this.i!==e?(x("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(ne(typeof r.accessToken=="string",31837,{l:r}),new kl(r.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return ne(e===null||typeof e=="string",2055,{h:e}),new we(e)}}class e_{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=we.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);const e=this.R();return e&&this.A.set("Authorization",e),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class t_{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new e_(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(we.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class Sc{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class n_{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,ke(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){ne(this.o===void 0,3512);const r=o=>{o.error!=null&&x("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${o.error.message}`);const a=o.token!==this.m;return this.m=o.token,x("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(o.token):Promise.resolve()};this.o=o=>{e.enqueueRetryable((()=>r(o)))};const s=o=>{x("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=o,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((o=>s(o))),setTimeout((()=>{if(!this.appCheck){const o=this.V.getImmediate({optional:!0});o?s(o):x("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new Sc(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((t=>t?(ne(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new Sc(t.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
|
|
1689
1689
|
* @license
|
|
1690
1690
|
* Copyright 2020 Google LLC
|
|
1691
1691
|
*
|
|
@@ -1745,7 +1745,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1745
1745
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1746
1746
|
* See the License for the specific language governing permissions and
|
|
1747
1747
|
* limitations under the License.
|
|
1748
|
-
*/const Pc="__name__";class Fe{constructor(e,t,r){t===void 0?t=0:t>e.length&&H(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&H(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return Fe.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Fe?e.forEach((r=>{t.push(r)})):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const o=Fe.compareSegments(e.get(s),t.get(s));if(o!==0)return o}return W(e.length,t.length)}static compareSegments(e,t){const r=Fe.isNumericId(e),s=Fe.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?Fe.extractNumericId(e).compare(Fe.extractNumericId(t)):Vi(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Et.fromString(e.substring(4,e.length-2))}}class te extends Fe{construct(e,t,r){return new te(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new
|
|
1748
|
+
*/const Pc="__name__";class Fe{constructor(e,t,r){t===void 0?t=0:t>e.length&&H(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&H(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return Fe.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Fe?e.forEach((r=>{t.push(r)})):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const o=Fe.compareSegments(e.get(s),t.get(s));if(o!==0)return o}return W(e.length,t.length)}static compareSegments(e,t){const r=Fe.isNumericId(e),s=Fe.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?Fe.extractNumericId(e).compare(Fe.extractNumericId(t)):Vi(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Et.fromString(e.substring(4,e.length-2))}}class te extends Fe{construct(e,t,r){return new te(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new L(N.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter((s=>s.length>0)))}return new te(t)}static emptyPath(){return new te([])}}const i_=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class Se extends Fe{construct(e,t,r){return new Se(e,t,r)}static isValidIdentifier(e){return i_.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),Se.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Pc}static keyField(){return new Se([Pc])}static fromServerFormat(e){const t=[];let r="",s=0;const o=()=>{if(r.length===0)throw new L(N.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""};let a=!1;for(;s<e.length;){const u=e[s];if(u==="\\"){if(s+1===e.length)throw new L(N.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const l=e[s+1];if(l!=="\\"&&l!=="."&&l!=="`")throw new L(N.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=l,s+=2}else u==="`"?(a=!a,s++):u!=="."||a?(r+=u,s++):(o(),s++)}if(o(),a)throw new L(N.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new Se(t)}static emptyPath(){return new Se([])}}/**
|
|
1749
1749
|
* @license
|
|
1750
1750
|
* Copyright 2017 Google LLC
|
|
1751
1751
|
*
|
|
@@ -1760,7 +1760,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1760
1760
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1761
1761
|
* See the License for the specific language governing permissions and
|
|
1762
1762
|
* limitations under the License.
|
|
1763
|
-
*/class
|
|
1763
|
+
*/class F{constructor(e){this.path=e}static fromPath(e){return new F(te.fromString(e))}static fromName(e){return new F(te.fromString(e).popFirst(5))}static empty(){return new F(te.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&te.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return te.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new F(new te(e.slice()))}}/**
|
|
1764
1764
|
* @license
|
|
1765
1765
|
* Copyright 2017 Google LLC
|
|
1766
1766
|
*
|
|
@@ -1775,7 +1775,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1775
1775
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1776
1776
|
* See the License for the specific language governing permissions and
|
|
1777
1777
|
* limitations under the License.
|
|
1778
|
-
*/function o_(n,e,t){if(!t)throw new
|
|
1778
|
+
*/function o_(n,e,t){if(!t)throw new L(N.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function a_(n,e,t,r){if(e===!0&&r===!0)throw new L(N.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function kc(n){if(!F.isDocumentKey(n))throw new L(N.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function c_(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function u_(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=(function(r){return r.constructor?r.constructor.name:null})(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":H(12329,{type:typeof n})}function Xr(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new L(N.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=u_(n);throw new L(N.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}/**
|
|
1779
1779
|
* @license
|
|
1780
1780
|
* Copyright 2025 Google LLC
|
|
1781
1781
|
*
|
|
@@ -1790,7 +1790,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1790
1790
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1791
1791
|
* See the License for the specific language governing permissions and
|
|
1792
1792
|
* limitations under the License.
|
|
1793
|
-
*/function ce(n,e){const t={typeString:n};return e&&(t.value=e),t}function pr(n,e){if(!c_(n))throw new
|
|
1793
|
+
*/function ce(n,e){const t={typeString:n};return e&&(t.value=e),t}function pr(n,e){if(!c_(n))throw new L(N.INVALID_ARGUMENT,"JSON must be an object");let t;for(const r in e)if(e[r]){const s=e[r].typeString,o="value"in e[r]?{value:e[r].value}:void 0;if(!(r in n)){t=`JSON missing required field: '${r}'`;break}const a=n[r];if(s&&typeof a!==s){t=`JSON field '${r}' must be a ${s}.`;break}if(o!==void 0&&a!==o.value){t=`Expected '${r}' field to equal '${o.value}'`;break}}if(t)throw new L(N.INVALID_ARGUMENT,t);return!0}/**
|
|
1794
1794
|
* @license
|
|
1795
1795
|
* Copyright 2017 Google LLC
|
|
1796
1796
|
*
|
|
@@ -1805,7 +1805,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1805
1805
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1806
1806
|
* See the License for the specific language governing permissions and
|
|
1807
1807
|
* limitations under the License.
|
|
1808
|
-
*/const Oc=-62135596800,Dc=1e6;class ae{static now(){return ae.fromMillis(Date.now())}static fromDate(e){return ae.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*Dc);return new ae(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new
|
|
1808
|
+
*/const Oc=-62135596800,Dc=1e6;class ae{static now(){return ae.fromMillis(Date.now())}static fromDate(e){return ae.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*Dc);return new ae(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new L(N.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new L(N.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<Oc)throw new L(N.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new L(N.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/Dc}_compareTo(e){return this.seconds===e.seconds?W(this.nanoseconds,e.nanoseconds):W(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:ae._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(pr(e,ae._jsonSchema))return new ae(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-Oc;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}ae._jsonSchemaVersion="firestore/timestamp/1.0",ae._jsonSchema={type:ce("string",ae._jsonSchemaVersion),seconds:ce("number"),nanoseconds:ce("number")};/**
|
|
1809
1809
|
* @license
|
|
1810
1810
|
* Copyright 2017 Google LLC
|
|
1811
1811
|
*
|
|
@@ -1835,7 +1835,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1835
1835
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1836
1836
|
* See the License for the specific language governing permissions and
|
|
1837
1837
|
* limitations under the License.
|
|
1838
|
-
*/const rr=-1;function l_(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=$.fromTimestamp(r===1e9?new ae(t+1,0):new ae(t,r));return new At(s,
|
|
1838
|
+
*/const rr=-1;function l_(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=$.fromTimestamp(r===1e9?new ae(t+1,0):new ae(t,r));return new At(s,F.empty(),e)}function h_(n){return new At(n.readTime,n.key,rr)}class At{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new At($.min(),F.empty(),rr)}static max(){return new At($.max(),F.empty(),rr)}}function d_(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=F.comparator(n.documentKey,e.documentKey),t!==0?t:W(n.largestBatchId,e.largestBatchId))}/**
|
|
1839
1839
|
* @license
|
|
1840
1840
|
* Copyright 2020 Google LLC
|
|
1841
1841
|
*
|
|
@@ -1865,7 +1865,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
1865
1865
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1866
1866
|
* See the License for the specific language governing permissions and
|
|
1867
1867
|
* limitations under the License.
|
|
1868
|
-
*/async function bs(n){if(n.code!==N.FAILED_PRECONDITION||n.message!==f_)throw n;
|
|
1868
|
+
*/async function bs(n){if(n.code!==N.FAILED_PRECONDITION||n.message!==f_)throw n;x("LocalStore","Unexpectedly lost primary lease")}/**
|
|
1869
1869
|
* @license
|
|
1870
1870
|
* Copyright 2017 Google LLC
|
|
1871
1871
|
*
|
|
@@ -2030,7 +2030,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
2030
2030
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2031
2031
|
* See the License for the specific language governing permissions and
|
|
2032
2032
|
* limitations under the License.
|
|
2033
|
-
*/const Vl="server_timestamp",Ml="__type__",
|
|
2033
|
+
*/const Vl="server_timestamp",Ml="__type__",xl="__previous_value__",Ll="__local_write_time__";function go(n){var e,t;return((t=(((e=n?.mapValue)===null||e===void 0?void 0:e.fields)||{})[Ml])===null||t===void 0?void 0:t.stringValue)===Vl}function Cs(n){const e=n.mapValue.fields[xl];return go(e)?Cs(e):e}function sr(n){const e=bt(n.mapValue.fields[Ll].timestampValue);return new ae(e.seconds,e.nanos)}/**
|
|
2034
2034
|
* @license
|
|
2035
2035
|
* Copyright 2017 Google LLC
|
|
2036
2036
|
*
|
|
@@ -2060,7 +2060,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
2060
2060
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2061
2061
|
* See the License for the specific language governing permissions and
|
|
2062
2062
|
* limitations under the License.
|
|
2063
|
-
*/const w_="__type__",I_="__max__",$r={mapValue:{}},A_="__vector__",
|
|
2063
|
+
*/const w_="__type__",I_="__max__",$r={mapValue:{}},A_="__vector__",xi="value";function St(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?go(n)?4:R_(n)?9007199254740991:b_(n)?10:11:H(28295,{value:n})}function He(n,e){if(n===e)return!0;const t=St(n);if(t!==St(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return sr(n).isEqual(sr(e));case 3:return(function(s,o){if(typeof s.timestampValue=="string"&&typeof o.timestampValue=="string"&&s.timestampValue.length===o.timestampValue.length)return s.timestampValue===o.timestampValue;const a=bt(s.timestampValue),u=bt(o.timestampValue);return a.seconds===u.seconds&&a.nanos===u.nanos})(n,e);case 5:return n.stringValue===e.stringValue;case 6:return(function(s,o){return Rt(s.bytesValue).isEqual(Rt(o.bytesValue))})(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return(function(s,o){return se(s.geoPointValue.latitude)===se(o.geoPointValue.latitude)&&se(s.geoPointValue.longitude)===se(o.geoPointValue.longitude)})(n,e);case 2:return(function(s,o){if("integerValue"in s&&"integerValue"in o)return se(s.integerValue)===se(o.integerValue);if("doubleValue"in s&&"doubleValue"in o){const a=se(s.doubleValue),u=se(o.doubleValue);return a===u?Mi(a)===Mi(u):isNaN(a)&&isNaN(u)}return!1})(n,e);case 9:return hn(n.arrayValue.values||[],e.arrayValue.values||[],He);case 10:case 11:return(function(s,o){const a=s.mapValue.fields||{},u=o.mapValue.fields||{};if(Vc(a)!==Vc(u))return!1;for(const l in a)if(a.hasOwnProperty(l)&&(u[l]===void 0||!He(a[l],u[l])))return!1;return!0})(n,e);default:return H(52216,{left:n})}}function or(n,e){return(n.values||[]).find((t=>He(t,e)))!==void 0}function dn(n,e){if(n===e)return 0;const t=St(n),r=St(e);if(t!==r)return W(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return W(n.booleanValue,e.booleanValue);case 2:return(function(o,a){const u=se(o.integerValue||o.doubleValue),l=se(a.integerValue||a.doubleValue);return u<l?-1:u>l?1:u===l?0:isNaN(u)?isNaN(l)?0:-1:1})(n,e);case 3:return xc(n.timestampValue,e.timestampValue);case 4:return xc(sr(n),sr(e));case 5:return Vi(n.stringValue,e.stringValue);case 6:return(function(o,a){const u=Rt(o),l=Rt(a);return u.compareTo(l)})(n.bytesValue,e.bytesValue);case 7:return(function(o,a){const u=o.split("/"),l=a.split("/");for(let d=0;d<u.length&&d<l.length;d++){const p=W(u[d],l[d]);if(p!==0)return p}return W(u.length,l.length)})(n.referenceValue,e.referenceValue);case 8:return(function(o,a){const u=W(se(o.latitude),se(a.latitude));return u!==0?u:W(se(o.longitude),se(a.longitude))})(n.geoPointValue,e.geoPointValue);case 9:return Lc(n.arrayValue,e.arrayValue);case 10:return(function(o,a){var u,l,d,p;const v=o.fields||{},E=a.fields||{},C=(u=v[xi])===null||u===void 0?void 0:u.arrayValue,V=(l=E[xi])===null||l===void 0?void 0:l.arrayValue,M=W(((d=C?.values)===null||d===void 0?void 0:d.length)||0,((p=V?.values)===null||p===void 0?void 0:p.length)||0);return M!==0?M:Lc(C,V)})(n.mapValue,e.mapValue);case 11:return(function(o,a){if(o===$r.mapValue&&a===$r.mapValue)return 0;if(o===$r.mapValue)return 1;if(a===$r.mapValue)return-1;const u=o.fields||{},l=Object.keys(u),d=a.fields||{},p=Object.keys(d);l.sort(),p.sort();for(let v=0;v<l.length&&v<p.length;++v){const E=Vi(l[v],p[v]);if(E!==0)return E;const C=dn(u[l[v]],d[p[v]]);if(C!==0)return C}return W(l.length,p.length)})(n.mapValue,e.mapValue);default:throw H(23264,{le:t})}}function xc(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return W(n,e);const t=bt(n),r=bt(e),s=W(t.seconds,r.seconds);return s!==0?s:W(t.nanos,r.nanos)}function Lc(n,e){const t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){const o=dn(t[s],r[s]);if(o)return o}return W(t.length,r.length)}function fn(n){return Li(n)}function Li(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?(function(t){const r=bt(t);return`time(${r.seconds},${r.nanos})`})(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?(function(t){return Rt(t).toBase64()})(n.bytesValue):"referenceValue"in n?(function(t){return F.fromName(t).toString()})(n.referenceValue):"geoPointValue"in n?(function(t){return`geo(${t.latitude},${t.longitude})`})(n.geoPointValue):"arrayValue"in n?(function(t){let r="[",s=!0;for(const o of t.values||[])s?s=!1:r+=",",r+=Li(o);return r+"]"})(n.arrayValue):"mapValue"in n?(function(t){const r=Object.keys(t.fields||{}).sort();let s="{",o=!0;for(const a of r)o?o=!1:s+=",",s+=`${a}:${Li(t.fields[a])}`;return s+"}"})(n.mapValue):H(61005,{value:n})}function Yr(n){switch(St(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=Cs(n);return e?16+Yr(e):16;case 5:return 2*n.stringValue.length;case 6:return Rt(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return(function(r){return(r.values||[]).reduce(((s,o)=>s+Yr(o)),0)})(n.arrayValue);case 10:case 11:return(function(r){let s=0;return mr(r.fields,((o,a)=>{s+=o.length+Yr(a)})),s})(n.mapValue);default:throw H(13486,{value:n})}}function Ui(n){return!!n&&"integerValue"in n}function _o(n){return!!n&&"arrayValue"in n}function Uc(n){return!!n&&"nullValue"in n}function Fc(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function _i(n){return!!n&&"mapValue"in n}function b_(n){var e,t;return((t=(((e=n?.mapValue)===null||e===void 0?void 0:e.fields)||{})[w_])===null||t===void 0?void 0:t.stringValue)===A_}function Kn(n){if(n.geoPointValue)return{geoPointValue:Object.assign({},n.geoPointValue)};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:Object.assign({},n.timestampValue)};if(n.mapValue){const e={mapValue:{fields:{}}};return mr(n.mapValue.fields,((t,r)=>e.mapValue.fields[t]=Kn(r))),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=Kn(n.arrayValue.values[t]);return e}return Object.assign({},n)}function R_(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===I_}/**
|
|
2064
2064
|
* @license
|
|
2065
2065
|
* Copyright 2017 Google LLC
|
|
2066
2066
|
*
|
|
@@ -2105,7 +2105,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
2105
2105
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2106
2106
|
* See the License for the specific language governing permissions and
|
|
2107
2107
|
* limitations under the License.
|
|
2108
|
-
*/class ds{constructor(e,t){this.position=e,this.inclusive=t}}function jc(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const o=e[s],a=n.position[s];if(o.field.isKeyField()?r=
|
|
2108
|
+
*/class ds{constructor(e,t){this.position=e,this.inclusive=t}}function jc(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const o=e[s],a=n.position[s];if(o.field.isKeyField()?r=F.comparator(F.fromName(a.referenceValue),t.key):r=dn(a,t.data.field(o.field)),o.dir==="desc"&&(r*=-1),r!==0)break}return r}function Bc(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!He(n.position[t],e.position[t]))return!1;return!0}/**
|
|
2109
2109
|
* @license
|
|
2110
2110
|
* Copyright 2022 Google LLC
|
|
2111
2111
|
*
|
|
@@ -2135,7 +2135,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
2135
2135
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2136
2136
|
* See the License for the specific language governing permissions and
|
|
2137
2137
|
* limitations under the License.
|
|
2138
|
-
*/class Ul{}class ue extends Ul{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new P_(e,t,r):t==="array-contains"?new D_(e,r):t==="in"?new N_(e,r):t==="not-in"?new V_(e,r):t==="array-contains-any"?new M_(e,r):new ue(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new k_(e,r):new O_(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(dn(t,this.value)):t!==null&&St(this.value)===St(t)&&this.matchesComparison(dn(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return H(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class We extends Ul{constructor(e,t){super(),this.filters=e,this.op=t,this.he=null}static create(e,t){return new We(e,t)}matches(e){return Fl(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.he!==null||(this.he=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.he}getFilters(){return Object.assign([],this.filters)}}function Fl(n){return n.op==="and"}function jl(n){return C_(n)&&Fl(n)}function C_(n){for(const e of n.filters)if(e instanceof We)return!1;return!0}function Fi(n){if(n instanceof ue)return n.field.canonicalString()+n.op.toString()+fn(n.value);if(jl(n))return n.filters.map((e=>Fi(e))).join(",");{const e=n.filters.map((t=>Fi(t))).join(",");return`${n.op}(${e})`}}function Bl(n,e){return n instanceof ue?(function(r,s){return s instanceof ue&&r.op===s.op&&r.field.isEqual(s.field)&&He(r.value,s.value)})(n,e):n instanceof We?(function(r,s){return s instanceof We&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce(((o,a,u)=>o&&Bl(a,s.filters[u])),!0):!1})(n,e):void H(19439)}function $l(n){return n instanceof ue?(function(t){return`${t.field.canonicalString()} ${t.op} ${fn(t.value)}`})(n):n instanceof We?(function(t){return t.op.toString()+" {"+t.getFilters().map($l).join(" ,")+"}"})(n):"Filter"}class P_ extends ue{constructor(e,t,r){super(e,t,r),this.key=
|
|
2138
|
+
*/class Ul{}class ue extends Ul{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new P_(e,t,r):t==="array-contains"?new D_(e,r):t==="in"?new N_(e,r):t==="not-in"?new V_(e,r):t==="array-contains-any"?new M_(e,r):new ue(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new k_(e,r):new O_(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(dn(t,this.value)):t!==null&&St(this.value)===St(t)&&this.matchesComparison(dn(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return H(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class We extends Ul{constructor(e,t){super(),this.filters=e,this.op=t,this.he=null}static create(e,t){return new We(e,t)}matches(e){return Fl(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.he!==null||(this.he=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.he}getFilters(){return Object.assign([],this.filters)}}function Fl(n){return n.op==="and"}function jl(n){return C_(n)&&Fl(n)}function C_(n){for(const e of n.filters)if(e instanceof We)return!1;return!0}function Fi(n){if(n instanceof ue)return n.field.canonicalString()+n.op.toString()+fn(n.value);if(jl(n))return n.filters.map((e=>Fi(e))).join(",");{const e=n.filters.map((t=>Fi(t))).join(",");return`${n.op}(${e})`}}function Bl(n,e){return n instanceof ue?(function(r,s){return s instanceof ue&&r.op===s.op&&r.field.isEqual(s.field)&&He(r.value,s.value)})(n,e):n instanceof We?(function(r,s){return s instanceof We&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce(((o,a,u)=>o&&Bl(a,s.filters[u])),!0):!1})(n,e):void H(19439)}function $l(n){return n instanceof ue?(function(t){return`${t.field.canonicalString()} ${t.op} ${fn(t.value)}`})(n):n instanceof We?(function(t){return t.op.toString()+" {"+t.getFilters().map($l).join(" ,")+"}"})(n):"Filter"}class P_ extends ue{constructor(e,t,r){super(e,t,r),this.key=F.fromName(r.referenceValue)}matches(e){const t=F.comparator(e.key,this.key);return this.matchesComparison(t)}}class k_ extends ue{constructor(e,t){super(e,"in",t),this.keys=ql("in",t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class O_ extends ue{constructor(e,t){super(e,"not-in",t),this.keys=ql("not-in",t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function ql(n,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map((r=>F.fromName(r.referenceValue)))}class D_ extends ue{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return _o(t)&&or(t.arrayValue,this.value)}}class N_ extends ue{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&or(this.value.arrayValue,t)}}class V_ extends ue{constructor(e,t){super(e,"not-in",t)}matches(e){if(or(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!or(this.value.arrayValue,t)}}class M_ extends ue{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!_o(t)||!t.arrayValue.values)&&t.arrayValue.values.some((r=>or(this.value.arrayValue,r)))}}/**
|
|
2139
2139
|
* @license
|
|
2140
2140
|
* Copyright 2019 Google LLC
|
|
2141
2141
|
*
|
|
@@ -2150,7 +2150,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
2150
2150
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2151
2151
|
* See the License for the specific language governing permissions and
|
|
2152
2152
|
* limitations under the License.
|
|
2153
|
-
*/class
|
|
2153
|
+
*/class x_{constructor(e,t=null,r=[],s=[],o=null,a=null,u=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=o,this.startAt=a,this.endAt=u,this.Pe=null}}function $c(n,e=null,t=[],r=[],s=null,o=null,a=null){return new x_(n,e,t,r,s,o,a)}function yo(n){const e=Q(n);if(e.Pe===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((r=>Fi(r))).join(","),t+="|ob:",t+=e.orderBy.map((r=>(function(o){return o.field.canonicalString()+o.dir})(r))).join(","),Ss(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((r=>fn(r))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((r=>fn(r))).join(",")),e.Pe=t}return e.Pe}function vo(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!S_(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!Bl(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!Bc(n.startAt,e.startAt)&&Bc(n.endAt,e.endAt)}function ji(n){return F.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}/**
|
|
2154
2154
|
* @license
|
|
2155
2155
|
* Copyright 2017 Google LLC
|
|
2156
2156
|
*
|
|
@@ -2165,7 +2165,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
2165
2165
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2166
2166
|
* See the License for the specific language governing permissions and
|
|
2167
2167
|
* limitations under the License.
|
|
2168
|
-
*/class Ps{constructor(e,t=null,r=[],s=[],o=null,a="F",u=null,l=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=o,this.limitType=a,this.startAt=u,this.endAt=l,this.Te=null,this.Ie=null,this.de=null,this.startAt,this.endAt}}function
|
|
2168
|
+
*/class Ps{constructor(e,t=null,r=[],s=[],o=null,a="F",u=null,l=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=o,this.limitType=a,this.startAt=u,this.endAt=l,this.Te=null,this.Ie=null,this.de=null,this.startAt,this.endAt}}function L_(n,e,t,r,s,o,a,u){return new Ps(n,e,t,r,s,o,a,u)}function Eo(n){return new Ps(n)}function qc(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function U_(n){return n.collectionGroup!==null}function Qn(n){const e=Q(n);if(e.Te===null){e.Te=[];const t=new Set;for(const o of e.explicitOrderBy)e.Te.push(o),t.add(o.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let u=new le(Se.comparator);return a.filters.forEach((l=>{l.getFlattenedFilters().forEach((d=>{d.isInequality()&&(u=u.add(d.field))}))})),u})(e).forEach((o=>{t.has(o.canonicalString())||o.isKeyField()||e.Te.push(new fs(o,r))})),t.has(Se.keyField().canonicalString())||e.Te.push(new fs(Se.keyField(),r))}return e.Te}function ze(n){const e=Q(n);return e.Ie||(e.Ie=F_(e,Qn(n))),e.Ie}function F_(n,e){if(n.limitType==="F")return $c(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map((s=>{const o=s.dir==="desc"?"asc":"desc";return new fs(s.field,o)}));const t=n.endAt?new ds(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new ds(n.startAt.position,n.startAt.inclusive):null;return $c(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function Bi(n,e,t){return new Ps(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function ks(n,e){return vo(ze(n),ze(e))&&n.limitType===e.limitType}function zl(n){return`${yo(ze(n))}|lt:${n.limitType}`}function Zt(n){return`Query(target=${(function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map((s=>$l(s))).join(", ")}]`),Ss(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map((s=>(function(a){return`${a.field.canonicalString()} (${a.dir})`})(s))).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map((s=>fn(s))).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map((s=>fn(s))).join(",")),`Target(${r})`})(ze(n))}; limitType=${n.limitType})`}function Os(n,e){return e.isFoundDocument()&&(function(r,s){const o=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(o):F.isDocumentKey(r.path)?r.path.isEqual(o):r.path.isImmediateParentOf(o)})(n,e)&&(function(r,s){for(const o of Qn(r))if(!o.field.isKeyField()&&s.data.field(o.field)===null)return!1;return!0})(n,e)&&(function(r,s){for(const o of r.filters)if(!o.matches(s))return!1;return!0})(n,e)&&(function(r,s){return!(r.startAt&&!(function(a,u,l){const d=jc(a,u,l);return a.inclusive?d<=0:d<0})(r.startAt,Qn(r),s)||r.endAt&&!(function(a,u,l){const d=jc(a,u,l);return a.inclusive?d>=0:d>0})(r.endAt,Qn(r),s))})(n,e)}function j_(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function Hl(n){return(e,t)=>{let r=!1;for(const s of Qn(n)){const o=B_(s,e,t);if(o!==0)return o;r=r||s.field.isKeyField()}return 0}}function B_(n,e,t){const r=n.field.isKeyField()?F.comparator(e.key,t.key):(function(o,a,u){const l=a.data.field(o),d=u.data.field(o);return l!==null&&d!==null?dn(l,d):H(42886)})(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return H(19790,{direction:n.dir})}}/**
|
|
2169
2169
|
* @license
|
|
2170
2170
|
* Copyright 2017 Google LLC
|
|
2171
2171
|
*
|
|
@@ -2195,7 +2195,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
2195
2195
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2196
2196
|
* See the License for the specific language governing permissions and
|
|
2197
2197
|
* limitations under the License.
|
|
2198
|
-
*/const $_=new ie(
|
|
2198
|
+
*/const $_=new ie(F.comparator);function Ct(){return $_}const Wl=new ie(F.comparator);function qn(...n){let e=Wl;for(const t of n)e=e.insert(t.key,t);return e}function q_(n){let e=Wl;return n.forEach(((t,r)=>e=e.insert(t,r.overlayedDocument))),e}function Lt(){return Jn()}function Gl(){return Jn()}function Jn(){return new Wt((n=>n.toString()),((n,e)=>n.isEqual(e)))}const z_=new le(F.comparator);function J(...n){let e=z_;for(const t of n)e=e.add(t);return e}const H_=new le(W);function W_(){return H_}/**
|
|
2199
2199
|
* @license
|
|
2200
2200
|
* Copyright 2020 Google LLC
|
|
2201
2201
|
*
|
|
@@ -2225,7 +2225,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
2225
2225
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2226
2226
|
* See the License for the specific language governing permissions and
|
|
2227
2227
|
* limitations under the License.
|
|
2228
|
-
*/class Ds{constructor(){this._=void 0}}function Q_(n,e,t){return n instanceof $i?(function(s,o){const a={fields:{[Ml]:{stringValue:Vl},[
|
|
2228
|
+
*/class Ds{constructor(){this._=void 0}}function Q_(n,e,t){return n instanceof $i?(function(s,o){const a={fields:{[Ml]:{stringValue:Vl},[Ll]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return o&&go(o)&&(o=Cs(o)),o&&(a.fields[xl]=o),{mapValue:a}})(t,e):n instanceof ps?Kl(n,e):n instanceof ms?Ql(n,e):(function(s,o){const a=X_(s,o),u=zc(a)+zc(s.Ee);return Ui(a)&&Ui(s.Ee)?K_(u):G_(s.serializer,u)})(n,e)}function J_(n,e,t){return n instanceof ps?Kl(n,e):n instanceof ms?Ql(n,e):t}function X_(n,e){return n instanceof qi?(function(r){return Ui(r)||(function(o){return!!o&&"doubleValue"in o})(r)})(e)?e:{integerValue:0}:null}class $i extends Ds{}class ps extends Ds{constructor(e){super(),this.elements=e}}function Kl(n,e){const t=Jl(e);for(const r of n.elements)t.some((s=>He(s,r)))||t.push(r);return{arrayValue:{values:t}}}class ms extends Ds{constructor(e){super(),this.elements=e}}function Ql(n,e){let t=Jl(e);for(const r of n.elements)t=t.filter((s=>!He(s,r)));return{arrayValue:{values:t}}}class qi extends Ds{constructor(e,t){super(),this.serializer=e,this.Ee=t}}function zc(n){return se(n.integerValue||n.doubleValue)}function Jl(n){return _o(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function Y_(n,e){return n.field.isEqual(e.field)&&(function(r,s){return r instanceof ps&&s instanceof ps||r instanceof ms&&s instanceof ms?hn(r.elements,s.elements,He):r instanceof qi&&s instanceof qi?He(r.Ee,s.Ee):r instanceof $i&&s instanceof $i})(n.transform,e.transform)}class Ft{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Ft}static exists(e){return new Ft(void 0,e)}static updateTime(e){return new Ft(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Zr(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class To{}function Xl(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new ey(n.key,Ft.none()):new wo(n.key,n.data,Ft.none());{const t=n.data,r=je.empty();let s=new le(Se.comparator);for(let o of e.fields)if(!s.has(o)){let a=t.field(o);a===null&&o.length>1&&(o=o.popLast(),a=t.field(o)),a===null?r.delete(o):r.set(o,a),s=s.add(o)}return new Ns(n.key,r,new mt(s.toArray()),Ft.none())}}function Z_(n,e,t){n instanceof wo?(function(s,o,a){const u=s.value.clone(),l=Wc(s.fieldTransforms,o,a.transformResults);u.setAll(l),o.convertToFoundDocument(a.version,u).setHasCommittedMutations()})(n,e,t):n instanceof Ns?(function(s,o,a){if(!Zr(s.precondition,o))return void o.convertToUnknownDocument(a.version);const u=Wc(s.fieldTransforms,o,a.transformResults),l=o.data;l.setAll(Yl(s)),l.setAll(u),o.convertToFoundDocument(a.version,l).setHasCommittedMutations()})(n,e,t):(function(s,o,a){o.convertToNoDocument(a.version).setHasCommittedMutations()})(0,e,t)}function Xn(n,e,t,r){return n instanceof wo?(function(o,a,u,l){if(!Zr(o.precondition,a))return u;const d=o.value.clone(),p=Gc(o.fieldTransforms,l,a);return d.setAll(p),a.convertToFoundDocument(a.version,d).setHasLocalMutations(),null})(n,e,t,r):n instanceof Ns?(function(o,a,u,l){if(!Zr(o.precondition,a))return u;const d=Gc(o.fieldTransforms,l,a),p=a.data;return p.setAll(Yl(o)),p.setAll(d),a.convertToFoundDocument(a.version,p).setHasLocalMutations(),u===null?null:u.unionWith(o.fieldMask.fields).unionWith(o.fieldTransforms.map((v=>v.field)))})(n,e,t,r):(function(o,a,u){return Zr(o.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):u})(n,e,t)}function Hc(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!(function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&hn(r,s,((o,a)=>Y_(o,a)))})(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class wo extends To{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class Ns extends To{constructor(e,t,r,s,o=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=s,this.fieldTransforms=o,this.type=1}getFieldMask(){return this.fieldMask}}function Yl(n){const e=new Map;return n.fieldMask.fields.forEach((t=>{if(!t.isEmpty()){const r=n.data.field(t);e.set(t,r)}})),e}function Wc(n,e,t){const r=new Map;ne(n.length===t.length,32656,{Ae:t.length,Re:n.length});for(let s=0;s<t.length;s++){const o=n[s],a=o.transform,u=e.data.field(o.field);r.set(o.field,J_(a,u,t[s]))}return r}function Gc(n,e,t){const r=new Map;for(const s of n){const o=s.transform,a=t.data.field(s.field);r.set(s.field,Q_(o,a,e))}return r}class ey extends To{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}/**
|
|
2229
2229
|
* @license
|
|
2230
2230
|
* Copyright 2017 Google LLC
|
|
2231
2231
|
*
|
|
@@ -2333,7 +2333,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
2333
2333
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2334
2334
|
* See the License for the specific language governing permissions and
|
|
2335
2335
|
* limitations under the License.
|
|
2336
|
-
*/class es{constructor(e,t,r,s){this.Se=e,this.removedTargetIds=t,this.key=r,this.be=s}}class eh{constructor(e,t){this.targetId=e,this.De=t}}class th{constructor(e,t,r=ge.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class Jc{constructor(){this.ve=0,this.Ce=Xc(),this.Fe=ge.EMPTY_BYTE_STRING,this.Me=!1,this.xe=!0}get current(){return this.Me}get resumeToken(){return this.Fe}get Oe(){return this.ve!==0}get Ne(){return this.xe}Be(e){e.approximateByteSize()>0&&(this.xe=!0,this.Fe=e)}Le(){let e=J(),t=J(),r=J();return this.Ce.forEach(((s,o)=>{switch(o){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:H(38017,{changeType:o})}})),new gr(this.Fe,this.Me,e,t,r)}ke(){this.xe=!1,this.Ce=Xc()}qe(e,t){this.xe=!0,this.Ce=this.Ce.insert(e,t)}Qe(e){this.xe=!0,this.Ce=this.Ce.remove(e)}$e(){this.ve+=1}Ue(){this.ve-=1,ne(this.ve>=0,3241,{ve:this.ve})}Ke(){this.xe=!0,this.Me=!0}}class iy{constructor(e){this.We=e,this.Ge=new Map,this.ze=Ct(),this.je=qr(),this.Je=qr(),this.He=new ie(W)}Ye(e){for(const t of e.Se)e.be&&e.be.isFoundDocument()?this.Ze(t,e.be):this.Xe(t,e.key,e.be);for(const t of e.removedTargetIds)this.Xe(t,e.key,e.be)}et(e){this.forEachTarget(e,(t=>{const r=this.tt(t);switch(e.state){case 0:this.nt(t)&&r.Be(e.resumeToken);break;case 1:r.Ue(),r.Oe||r.ke(),r.Be(e.resumeToken);break;case 2:r.Ue(),r.Oe||this.removeTarget(t);break;case 3:this.nt(t)&&(r.Ke(),r.Be(e.resumeToken));break;case 4:this.nt(t)&&(this.rt(t),r.Be(e.resumeToken));break;default:H(56790,{state:e.state})}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Ge.forEach(((r,s)=>{this.nt(s)&&t(s)}))}it(e){const t=e.targetId,r=e.De.count,s=this.st(t);if(s){const o=s.target;if(ji(o))if(r===0){const a=new U(o.path);this.Xe(t,a,Ie.newNoDocument(a,$.min()))}else ne(r===1,20013,{expectedCount:r});else{const a=this.ot(t);if(a!==r){const u=this._t(e),l=u?this.ut(u,e,a):1;if(l!==0){this.rt(t);const d=l===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.He=this.He.insert(t,d)}}}}}_t(e){const t=e.De.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:o=0}=t;let a,u;try{a=Rt(r).toUint8Array()}catch(l){if(l instanceof Nl)return It("Decoding the base64 bloom filter in existence filter failed ("+l.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw l}try{u=new Io(a,s,o)}catch(l){return It(l instanceof zn?"BloomFilter error: ":"Applying bloom filter failed: ",l),null}return u.fe===0?null:u}ut(e,t,r){return t.De.count===r-this.ht(e,t.targetId)?0:2}ht(e,t){const r=this.We.getRemoteKeysForTarget(t);let s=0;return r.forEach((o=>{const a=this.We.lt(),u=`projects/${a.projectId}/databases/${a.database}/documents/${o.path.canonicalString()}`;e.mightContain(u)||(this.Xe(t,o,null),s++)})),s}Pt(e){const t=new Map;this.Ge.forEach(((o,a)=>{const u=this.st(a);if(u){if(o.current&&ji(u.target)){const l=new U(u.target.path);this.Tt(l).has(a)||this.It(a,l)||this.Xe(a,l,Ie.newNoDocument(l,e))}o.Ne&&(t.set(a,o.Le()),o.ke())}}));let r=J();this.Je.forEach(((o,a)=>{let u=!0;a.forEachWhile((l=>{const d=this.st(l);return!d||d.purpose==="TargetPurposeLimboResolution"||(u=!1,!1)})),u&&(r=r.add(o))})),this.ze.forEach(((o,a)=>a.setReadTime(e)));const s=new Vs(e,t,this.He,this.ze,r);return this.ze=Ct(),this.je=qr(),this.Je=qr(),this.He=new ie(W),s}Ze(e,t){if(!this.nt(e))return;const r=this.It(e,t.key)?2:0;this.tt(e).qe(t.key,r),this.ze=this.ze.insert(t.key,t),this.je=this.je.insert(t.key,this.Tt(t.key).add(e)),this.Je=this.Je.insert(t.key,this.dt(t.key).add(e))}Xe(e,t,r){if(!this.nt(e))return;const s=this.tt(e);this.It(e,t)?s.qe(t,1):s.Qe(t),this.Je=this.Je.insert(t,this.dt(t).delete(e)),this.Je=this.Je.insert(t,this.dt(t).add(e)),r&&(this.ze=this.ze.insert(t,r))}removeTarget(e){this.Ge.delete(e)}ot(e){const t=this.tt(e).Le();return this.We.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.tt(e).$e()}tt(e){let t=this.Ge.get(e);return t||(t=new Jc,this.Ge.set(e,t)),t}dt(e){let t=this.Je.get(e);return t||(t=new le(W),this.Je=this.Je.insert(e,t)),t}Tt(e){let t=this.je.get(e);return t||(t=new le(W),this.je=this.je.insert(e,t)),t}nt(e){const t=this.st(e)!==null;return t||L("WatchChangeAggregator","Detected inactive target",e),t}st(e){const t=this.Ge.get(e);return t&&t.Oe?null:this.We.Et(e)}rt(e){this.Ge.set(e,new Jc),this.We.getRemoteKeysForTarget(e).forEach((t=>{this.Xe(e,t,null)}))}It(e,t){return this.We.getRemoteKeysForTarget(e).has(t)}}function qr(){return new ie(U.comparator)}function Xc(){return new ie(U.comparator)}const oy={asc:"ASCENDING",desc:"DESCENDING"},ay={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},cy={and:"AND",or:"OR"};class uy{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function zi(n,e){return n.useProto3Json||Ss(e)?e:{value:e}}function ly(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function hy(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function an(n){return ne(!!n,49232),$.fromTimestamp((function(t){const r=bt(t);return new ae(r.seconds,r.nanos)})(n))}function dy(n,e){return Hi(n,e).canonicalString()}function Hi(n,e){const t=(function(s){return new te(["projects",s.projectId,"databases",s.database])})(n).child("documents");return e===void 0?t:t.child(e)}function nh(n){const e=te.fromString(n);return ne(ah(e),10190,{key:e.toString()}),e}function yi(n,e){const t=nh(e);if(t.get(1)!==n.databaseId.projectId)throw new x(N.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new x(N.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new U(sh(t))}function rh(n,e){return dy(n.databaseId,e)}function fy(n){const e=nh(n);return e.length===4?te.emptyPath():sh(e)}function Yc(n){return new te(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function sh(n){return ne(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function py(n,e){let t;if("targetChange"in e){e.targetChange;const r=(function(d){return d==="NO_CHANGE"?0:d==="ADD"?1:d==="REMOVE"?2:d==="CURRENT"?3:d==="RESET"?4:H(39313,{state:d})})(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],o=(function(d,p){return d.useProto3Json?(ne(p===void 0||typeof p=="string",58123),ge.fromBase64String(p||"")):(ne(p===void 0||p instanceof Buffer||p instanceof Uint8Array,16193),ge.fromUint8Array(p||new Uint8Array))})(n,e.targetChange.resumeToken),a=e.targetChange.cause,u=a&&(function(d){const p=d.code===void 0?N.UNKNOWN:Zl(d.code);return new x(p,d.message||"")})(a);t=new th(r,s,o,u||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=yi(n,r.document.name),o=an(r.document.updateTime),a=r.document.createTime?an(r.document.createTime):$.min(),u=new je({mapValue:{fields:r.document.fields}}),l=Ie.newFoundDocument(s,o,a,u),d=r.targetIds||[],p=r.removedTargetIds||[];t=new es(d,p,l.key,l)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=yi(n,r.document),o=r.readTime?an(r.readTime):$.min(),a=Ie.newNoDocument(s,o),u=r.removedTargetIds||[];t=new es([],u,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=yi(n,r.document),o=r.removedTargetIds||[];t=new es([],o,s,null)}else{if(!("filter"in e))return H(11601,{At:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:o}=r,a=new ry(s,o),u=r.targetId;t=new eh(u,a)}}return t}function my(n,e){return{documents:[rh(n,e.path)]}}function gy(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=rh(n,s);const o=(function(d){if(d.length!==0)return oh(We.create(d,"and"))})(e.filters);o&&(t.structuredQuery.where=o);const a=(function(d){if(d.length!==0)return d.map((p=>(function(E){return{field:en(E.field),direction:vy(E.dir)}})(p)))})(e.orderBy);a&&(t.structuredQuery.orderBy=a);const u=zi(n,e.limit);return u!==null&&(t.structuredQuery.limit=u),e.startAt&&(t.structuredQuery.startAt=(function(d){return{before:d.inclusive,values:d.position}})(e.startAt)),e.endAt&&(t.structuredQuery.endAt=(function(d){return{before:!d.inclusive,values:d.position}})(e.endAt)),{Vt:t,parent:s}}function _y(n){let e=fy(n.parent);const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){ne(r===1,65062);const p=t.from[0];p.allDescendants?s=p.collectionId:e=e.child(p.collectionId)}let o=[];t.where&&(o=(function(v){const E=ih(v);return E instanceof We&&jl(E)?E.getFilters():[E]})(t.where));let a=[];t.orderBy&&(a=(function(v){return v.map((E=>(function(V){return new fs(tn(V.field),(function(k){switch(k){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(V.direction))})(E)))})(t.orderBy));let u=null;t.limit&&(u=(function(v){let E;return E=typeof v=="object"?v.value:v,Ss(E)?null:E})(t.limit));let l=null;t.startAt&&(l=(function(v){const E=!!v.before,C=v.values||[];return new ds(C,E)})(t.startAt));let d=null;return t.endAt&&(d=(function(v){const E=!v.before,C=v.values||[];return new ds(C,E)})(t.endAt)),x_(e,s,a,o,u,"F",l,d)}function yy(n,e){const t=(function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return H(28987,{purpose:s})}})(e.purpose);return t==null?null:{"goog-listen-tags":t}}function ih(n){return n.unaryFilter!==void 0?(function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=tn(t.unaryFilter.field);return ue.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=tn(t.unaryFilter.field);return ue.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const o=tn(t.unaryFilter.field);return ue.create(o,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=tn(t.unaryFilter.field);return ue.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return H(61313);default:return H(60726)}})(n):n.fieldFilter!==void 0?(function(t){return ue.create(tn(t.fieldFilter.field),(function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return H(58110);default:return H(50506)}})(t.fieldFilter.op),t.fieldFilter.value)})(n):n.compositeFilter!==void 0?(function(t){return We.create(t.compositeFilter.filters.map((r=>ih(r))),(function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return H(1026)}})(t.compositeFilter.op))})(n):H(30097,{filter:n})}function vy(n){return oy[n]}function Ey(n){return ay[n]}function Ty(n){return cy[n]}function en(n){return{fieldPath:n.canonicalString()}}function tn(n){return Se.fromServerFormat(n.fieldPath)}function oh(n){return n instanceof ue?(function(t){if(t.op==="=="){if(Fc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NAN"}};if(Uc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Fc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NOT_NAN"}};if(Uc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:en(t.field),op:Ey(t.op),value:t.value}}})(n):n instanceof We?(function(t){const r=t.getFilters().map((s=>oh(s)));return r.length===1?r[0]:{compositeFilter:{op:Ty(t.op),filters:r}}})(n):H(54877,{filter:n})}function ah(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}/**
|
|
2336
|
+
*/class es{constructor(e,t,r,s){this.Se=e,this.removedTargetIds=t,this.key=r,this.be=s}}class eh{constructor(e,t){this.targetId=e,this.De=t}}class th{constructor(e,t,r=ge.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class Jc{constructor(){this.ve=0,this.Ce=Xc(),this.Fe=ge.EMPTY_BYTE_STRING,this.Me=!1,this.xe=!0}get current(){return this.Me}get resumeToken(){return this.Fe}get Oe(){return this.ve!==0}get Ne(){return this.xe}Be(e){e.approximateByteSize()>0&&(this.xe=!0,this.Fe=e)}Le(){let e=J(),t=J(),r=J();return this.Ce.forEach(((s,o)=>{switch(o){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:H(38017,{changeType:o})}})),new gr(this.Fe,this.Me,e,t,r)}ke(){this.xe=!1,this.Ce=Xc()}qe(e,t){this.xe=!0,this.Ce=this.Ce.insert(e,t)}Qe(e){this.xe=!0,this.Ce=this.Ce.remove(e)}$e(){this.ve+=1}Ue(){this.ve-=1,ne(this.ve>=0,3241,{ve:this.ve})}Ke(){this.xe=!0,this.Me=!0}}class iy{constructor(e){this.We=e,this.Ge=new Map,this.ze=Ct(),this.je=qr(),this.Je=qr(),this.He=new ie(W)}Ye(e){for(const t of e.Se)e.be&&e.be.isFoundDocument()?this.Ze(t,e.be):this.Xe(t,e.key,e.be);for(const t of e.removedTargetIds)this.Xe(t,e.key,e.be)}et(e){this.forEachTarget(e,(t=>{const r=this.tt(t);switch(e.state){case 0:this.nt(t)&&r.Be(e.resumeToken);break;case 1:r.Ue(),r.Oe||r.ke(),r.Be(e.resumeToken);break;case 2:r.Ue(),r.Oe||this.removeTarget(t);break;case 3:this.nt(t)&&(r.Ke(),r.Be(e.resumeToken));break;case 4:this.nt(t)&&(this.rt(t),r.Be(e.resumeToken));break;default:H(56790,{state:e.state})}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Ge.forEach(((r,s)=>{this.nt(s)&&t(s)}))}it(e){const t=e.targetId,r=e.De.count,s=this.st(t);if(s){const o=s.target;if(ji(o))if(r===0){const a=new F(o.path);this.Xe(t,a,Ie.newNoDocument(a,$.min()))}else ne(r===1,20013,{expectedCount:r});else{const a=this.ot(t);if(a!==r){const u=this._t(e),l=u?this.ut(u,e,a):1;if(l!==0){this.rt(t);const d=l===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.He=this.He.insert(t,d)}}}}}_t(e){const t=e.De.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:o=0}=t;let a,u;try{a=Rt(r).toUint8Array()}catch(l){if(l instanceof Nl)return It("Decoding the base64 bloom filter in existence filter failed ("+l.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw l}try{u=new Io(a,s,o)}catch(l){return It(l instanceof zn?"BloomFilter error: ":"Applying bloom filter failed: ",l),null}return u.fe===0?null:u}ut(e,t,r){return t.De.count===r-this.ht(e,t.targetId)?0:2}ht(e,t){const r=this.We.getRemoteKeysForTarget(t);let s=0;return r.forEach((o=>{const a=this.We.lt(),u=`projects/${a.projectId}/databases/${a.database}/documents/${o.path.canonicalString()}`;e.mightContain(u)||(this.Xe(t,o,null),s++)})),s}Pt(e){const t=new Map;this.Ge.forEach(((o,a)=>{const u=this.st(a);if(u){if(o.current&&ji(u.target)){const l=new F(u.target.path);this.Tt(l).has(a)||this.It(a,l)||this.Xe(a,l,Ie.newNoDocument(l,e))}o.Ne&&(t.set(a,o.Le()),o.ke())}}));let r=J();this.Je.forEach(((o,a)=>{let u=!0;a.forEachWhile((l=>{const d=this.st(l);return!d||d.purpose==="TargetPurposeLimboResolution"||(u=!1,!1)})),u&&(r=r.add(o))})),this.ze.forEach(((o,a)=>a.setReadTime(e)));const s=new Vs(e,t,this.He,this.ze,r);return this.ze=Ct(),this.je=qr(),this.Je=qr(),this.He=new ie(W),s}Ze(e,t){if(!this.nt(e))return;const r=this.It(e,t.key)?2:0;this.tt(e).qe(t.key,r),this.ze=this.ze.insert(t.key,t),this.je=this.je.insert(t.key,this.Tt(t.key).add(e)),this.Je=this.Je.insert(t.key,this.dt(t.key).add(e))}Xe(e,t,r){if(!this.nt(e))return;const s=this.tt(e);this.It(e,t)?s.qe(t,1):s.Qe(t),this.Je=this.Je.insert(t,this.dt(t).delete(e)),this.Je=this.Je.insert(t,this.dt(t).add(e)),r&&(this.ze=this.ze.insert(t,r))}removeTarget(e){this.Ge.delete(e)}ot(e){const t=this.tt(e).Le();return this.We.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.tt(e).$e()}tt(e){let t=this.Ge.get(e);return t||(t=new Jc,this.Ge.set(e,t)),t}dt(e){let t=this.Je.get(e);return t||(t=new le(W),this.Je=this.Je.insert(e,t)),t}Tt(e){let t=this.je.get(e);return t||(t=new le(W),this.je=this.je.insert(e,t)),t}nt(e){const t=this.st(e)!==null;return t||x("WatchChangeAggregator","Detected inactive target",e),t}st(e){const t=this.Ge.get(e);return t&&t.Oe?null:this.We.Et(e)}rt(e){this.Ge.set(e,new Jc),this.We.getRemoteKeysForTarget(e).forEach((t=>{this.Xe(e,t,null)}))}It(e,t){return this.We.getRemoteKeysForTarget(e).has(t)}}function qr(){return new ie(F.comparator)}function Xc(){return new ie(F.comparator)}const oy={asc:"ASCENDING",desc:"DESCENDING"},ay={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},cy={and:"AND",or:"OR"};class uy{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function zi(n,e){return n.useProto3Json||Ss(e)?e:{value:e}}function ly(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function hy(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function an(n){return ne(!!n,49232),$.fromTimestamp((function(t){const r=bt(t);return new ae(r.seconds,r.nanos)})(n))}function dy(n,e){return Hi(n,e).canonicalString()}function Hi(n,e){const t=(function(s){return new te(["projects",s.projectId,"databases",s.database])})(n).child("documents");return e===void 0?t:t.child(e)}function nh(n){const e=te.fromString(n);return ne(ah(e),10190,{key:e.toString()}),e}function yi(n,e){const t=nh(e);if(t.get(1)!==n.databaseId.projectId)throw new L(N.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new L(N.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new F(sh(t))}function rh(n,e){return dy(n.databaseId,e)}function fy(n){const e=nh(n);return e.length===4?te.emptyPath():sh(e)}function Yc(n){return new te(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function sh(n){return ne(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function py(n,e){let t;if("targetChange"in e){e.targetChange;const r=(function(d){return d==="NO_CHANGE"?0:d==="ADD"?1:d==="REMOVE"?2:d==="CURRENT"?3:d==="RESET"?4:H(39313,{state:d})})(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],o=(function(d,p){return d.useProto3Json?(ne(p===void 0||typeof p=="string",58123),ge.fromBase64String(p||"")):(ne(p===void 0||p instanceof Buffer||p instanceof Uint8Array,16193),ge.fromUint8Array(p||new Uint8Array))})(n,e.targetChange.resumeToken),a=e.targetChange.cause,u=a&&(function(d){const p=d.code===void 0?N.UNKNOWN:Zl(d.code);return new L(p,d.message||"")})(a);t=new th(r,s,o,u||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=yi(n,r.document.name),o=an(r.document.updateTime),a=r.document.createTime?an(r.document.createTime):$.min(),u=new je({mapValue:{fields:r.document.fields}}),l=Ie.newFoundDocument(s,o,a,u),d=r.targetIds||[],p=r.removedTargetIds||[];t=new es(d,p,l.key,l)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=yi(n,r.document),o=r.readTime?an(r.readTime):$.min(),a=Ie.newNoDocument(s,o),u=r.removedTargetIds||[];t=new es([],u,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=yi(n,r.document),o=r.removedTargetIds||[];t=new es([],o,s,null)}else{if(!("filter"in e))return H(11601,{At:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:o}=r,a=new ry(s,o),u=r.targetId;t=new eh(u,a)}}return t}function my(n,e){return{documents:[rh(n,e.path)]}}function gy(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=rh(n,s);const o=(function(d){if(d.length!==0)return oh(We.create(d,"and"))})(e.filters);o&&(t.structuredQuery.where=o);const a=(function(d){if(d.length!==0)return d.map((p=>(function(E){return{field:en(E.field),direction:vy(E.dir)}})(p)))})(e.orderBy);a&&(t.structuredQuery.orderBy=a);const u=zi(n,e.limit);return u!==null&&(t.structuredQuery.limit=u),e.startAt&&(t.structuredQuery.startAt=(function(d){return{before:d.inclusive,values:d.position}})(e.startAt)),e.endAt&&(t.structuredQuery.endAt=(function(d){return{before:!d.inclusive,values:d.position}})(e.endAt)),{Vt:t,parent:s}}function _y(n){let e=fy(n.parent);const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){ne(r===1,65062);const p=t.from[0];p.allDescendants?s=p.collectionId:e=e.child(p.collectionId)}let o=[];t.where&&(o=(function(v){const E=ih(v);return E instanceof We&&jl(E)?E.getFilters():[E]})(t.where));let a=[];t.orderBy&&(a=(function(v){return v.map((E=>(function(V){return new fs(tn(V.field),(function(k){switch(k){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(V.direction))})(E)))})(t.orderBy));let u=null;t.limit&&(u=(function(v){let E;return E=typeof v=="object"?v.value:v,Ss(E)?null:E})(t.limit));let l=null;t.startAt&&(l=(function(v){const E=!!v.before,C=v.values||[];return new ds(C,E)})(t.startAt));let d=null;return t.endAt&&(d=(function(v){const E=!v.before,C=v.values||[];return new ds(C,E)})(t.endAt)),L_(e,s,a,o,u,"F",l,d)}function yy(n,e){const t=(function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return H(28987,{purpose:s})}})(e.purpose);return t==null?null:{"goog-listen-tags":t}}function ih(n){return n.unaryFilter!==void 0?(function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=tn(t.unaryFilter.field);return ue.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=tn(t.unaryFilter.field);return ue.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const o=tn(t.unaryFilter.field);return ue.create(o,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=tn(t.unaryFilter.field);return ue.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return H(61313);default:return H(60726)}})(n):n.fieldFilter!==void 0?(function(t){return ue.create(tn(t.fieldFilter.field),(function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return H(58110);default:return H(50506)}})(t.fieldFilter.op),t.fieldFilter.value)})(n):n.compositeFilter!==void 0?(function(t){return We.create(t.compositeFilter.filters.map((r=>ih(r))),(function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return H(1026)}})(t.compositeFilter.op))})(n):H(30097,{filter:n})}function vy(n){return oy[n]}function Ey(n){return ay[n]}function Ty(n){return cy[n]}function en(n){return{fieldPath:n.canonicalString()}}function tn(n){return Se.fromServerFormat(n.fieldPath)}function oh(n){return n instanceof ue?(function(t){if(t.op==="=="){if(Fc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NAN"}};if(Uc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Fc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NOT_NAN"}};if(Uc(t.value))return{unaryFilter:{field:en(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:en(t.field),op:Ey(t.op),value:t.value}}})(n):n instanceof We?(function(t){const r=t.getFilters().map((s=>oh(s)));return r.length===1?r[0]:{compositeFilter:{op:Ty(t.op),filters:r}}})(n):H(54877,{filter:n})}function ah(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}/**
|
|
2337
2337
|
* @license
|
|
2338
2338
|
* Copyright 2017 Google LLC
|
|
2339
2339
|
*
|
|
@@ -2438,7 +2438,7 @@ SPDX-License-Identifier: Apache-2.0
|
|
|
2438
2438
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2439
2439
|
* See the License for the specific language governing permissions and
|
|
2440
2440
|
* limitations under the License.
|
|
2441
|
-
*/const eu="LruGarbageCollector",Ry=1048576;function tu([n,e],[t,r]){const s=W(n,t);return s===0?W(e,r):s}class Sy{constructor(e){this.Tr=e,this.buffer=new le(tu),this.Ir=0}dr(){return++this.Ir}Er(e){const t=[e,this.dr()];if(this.buffer.size<this.Tr)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();tu(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class Cy{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Ar=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Rr(6e4)}stop(){this.Ar&&(this.Ar.cancel(),this.Ar=null)}get started(){return this.Ar!==null}Rr(e){
|
|
2441
|
+
*/const eu="LruGarbageCollector",Ry=1048576;function tu([n,e],[t,r]){const s=W(n,t);return s===0?W(e,r):s}class Sy{constructor(e){this.Tr=e,this.buffer=new le(tu),this.Ir=0}dr(){return++this.Ir}Er(e){const t=[e,this.dr()];if(this.buffer.size<this.Tr)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();tu(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class Cy{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Ar=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Rr(6e4)}stop(){this.Ar&&(this.Ar.cancel(),this.Ar=null)}get started(){return this.Ar!==null}Rr(e){x(eu,`Garbage collection scheduled in ${e}ms`),this.Ar=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.Ar=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Tn(t)?x(eu,"Ignoring IndexedDB error during garbage collection: ",t):await bs(t)}await this.Rr(3e5)}))}}class Py{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.mr(e).next((r=>Math.floor(t/100*r)))}nthSequenceNumber(e,t){if(t===0)return S.resolve(Rs.ue);const r=new Sy(t);return this.Vr.forEachTarget(e,(s=>r.Er(s.sequenceNumber))).next((()=>this.Vr.gr(e,(s=>r.Er(s))))).next((()=>r.maxValue))}removeTargets(e,t,r){return this.Vr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(x("LruGarbageCollector","Garbage collection skipped; disabled"),S.resolve(Zc)):this.getCacheSize(e).next((r=>r<this.params.cacheSizeCollectionThreshold?(x("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Zc):this.pr(e,t)))}getCacheSize(e){return this.Vr.getCacheSize(e)}pr(e,t){let r,s,o,a,u,l,d;const p=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((v=>(v>this.params.maximumSequenceNumbersToCollect?(x("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${v}`),s=this.params.maximumSequenceNumbersToCollect):s=v,a=Date.now(),this.nthSequenceNumber(e,s)))).next((v=>(r=v,u=Date.now(),this.removeTargets(e,r,t)))).next((v=>(o=v,l=Date.now(),this.removeOrphanedDocuments(e,r)))).next((v=>(d=Date.now(),Yt()<=G.DEBUG&&x("LruGarbageCollector",`LRU Garbage Collection
|
|
2442
2442
|
Counted targets in ${a-p}ms
|
|
2443
2443
|
Determined least recently used ${s} in `+(u-a)+`ms
|
|
2444
2444
|
Removed ${o} targets in `+(l-u)+`ms
|
|
@@ -2503,7 +2503,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2503
2503
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2504
2504
|
* See the License for the specific language governing permissions and
|
|
2505
2505
|
* limitations under the License.
|
|
2506
|
-
*/class Ny{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next((s=>(r=s,this.remoteDocumentCache.getEntry(e,t)))).next((s=>(r!==null&&Xn(r.mutation,s,mt.empty(),ae.now()),s)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.getLocalViewOfDocuments(e,r,J()).next((()=>r))))}getLocalViewOfDocuments(e,t,r=J()){const s=
|
|
2506
|
+
*/class Ny{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next((s=>(r=s,this.remoteDocumentCache.getEntry(e,t)))).next((s=>(r!==null&&Xn(r.mutation,s,mt.empty(),ae.now()),s)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.getLocalViewOfDocuments(e,r,J()).next((()=>r))))}getLocalViewOfDocuments(e,t,r=J()){const s=Lt();return this.populateOverlays(e,s,t).next((()=>this.computeViews(e,t,s,r).next((o=>{let a=qn();return o.forEach(((u,l)=>{a=a.insert(u,l.overlayedDocument)})),a}))))}getOverlayedDocuments(e,t){const r=Lt();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,J())))}populateOverlays(e,t,r){const s=[];return r.forEach((o=>{t.has(o)||s.push(o)})),this.documentOverlayCache.getOverlays(e,s).next((o=>{o.forEach(((a,u)=>{t.set(a,u)}))}))}computeViews(e,t,r,s){let o=Ct();const a=Jn(),u=(function(){return Jn()})();return t.forEach(((l,d)=>{const p=r.get(d.key);s.has(d.key)&&(p===void 0||p.mutation instanceof Ns)?o=o.insert(d.key,d):p!==void 0?(a.set(d.key,p.mutation.getFieldMask()),Xn(p.mutation,d,p.mutation.getFieldMask(),ae.now())):a.set(d.key,mt.empty())})),this.recalculateAndSaveOverlays(e,o).next((l=>(l.forEach(((d,p)=>a.set(d,p))),t.forEach(((d,p)=>{var v;return u.set(d,new Dy(p,(v=a.get(d))!==null&&v!==void 0?v:null))})),u)))}recalculateAndSaveOverlays(e,t){const r=Jn();let s=new ie(((a,u)=>a-u)),o=J();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((a=>{for(const u of a)u.keys().forEach((l=>{const d=t.get(l);if(d===null)return;let p=r.get(l)||mt.empty();p=u.applyToLocalView(d,p),r.set(l,p);const v=(s.get(u.batchId)||J()).add(l);s=s.insert(u.batchId,v)}))})).next((()=>{const a=[],u=s.getReverseIterator();for(;u.hasNext();){const l=u.getNext(),d=l.key,p=l.value,v=Gl();p.forEach((E=>{if(!o.has(E)){const C=Xl(t.get(E),r.get(E));C!==null&&v.set(E,C),o=o.add(E)}})),a.push(this.documentOverlayCache.saveOverlays(e,d,v))}return S.waitFor(a)})).next((()=>r))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.recalculateAndSaveOverlays(e,r)))}getDocumentsMatchingQuery(e,t,r,s){return(function(a){return F.isDocumentKey(a.path)&&a.collectionGroup===null&&a.filters.length===0})(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):U_(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next((o=>{const a=s-o.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-o.size):S.resolve(Lt());let u=rr,l=o;return a.next((d=>S.forEach(d,((p,v)=>(u<v.largestBatchId&&(u=v.largestBatchId),o.get(p)?S.resolve():this.remoteDocumentCache.getEntry(e,p).next((E=>{l=l.insert(p,E)}))))).next((()=>this.populateOverlays(e,d,o))).next((()=>this.computeViews(e,l,d,J()))).next((p=>({batchId:u,changes:q_(p)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new F(t)).next((r=>{let s=qn();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s}))}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const o=t.collectionGroup;let a=qn();return this.indexManager.getCollectionParents(e,o).next((u=>S.forEach(u,(l=>{const d=(function(v,E){return new Ps(E,null,v.explicitOrderBy.slice(),v.filters.slice(),v.limit,v.limitType,v.startAt,v.endAt)})(t,l.child(o));return this.getDocumentsMatchingCollectionQuery(e,d,r,s).next((p=>{p.forEach(((v,E)=>{a=a.insert(v,E)}))}))})).next((()=>a))))}getDocumentsMatchingCollectionQuery(e,t,r,s){let o;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next((a=>(o=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,o,s)))).next((a=>{o.forEach(((l,d)=>{const p=d.getKey();a.get(p)===null&&(a=a.insert(p,Ie.newInvalidDocument(p)))}));let u=qn();return a.forEach(((l,d)=>{const p=o.get(l);p!==void 0&&Xn(p.mutation,d,mt.empty(),ae.now()),Os(t,d)&&(u=u.insert(l,d))})),u}))}}/**
|
|
2507
2507
|
* @license
|
|
2508
2508
|
* Copyright 2020 Google LLC
|
|
2509
2509
|
*
|
|
@@ -2533,7 +2533,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2533
2533
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2534
2534
|
* See the License for the specific language governing permissions and
|
|
2535
2535
|
* limitations under the License.
|
|
2536
|
-
*/class My{constructor(){this.overlays=new ie(
|
|
2536
|
+
*/class My{constructor(){this.overlays=new ie(F.comparator),this.kr=new Map}getOverlay(e,t){return S.resolve(this.overlays.get(t))}getOverlays(e,t){const r=Lt();return S.forEach(t,(s=>this.getOverlay(e,s).next((o=>{o!==null&&r.set(s,o)})))).next((()=>r))}saveOverlays(e,t,r){return r.forEach(((s,o)=>{this.wt(e,t,o)})),S.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.kr.get(r);return s!==void 0&&(s.forEach((o=>this.overlays=this.overlays.remove(o))),this.kr.delete(r)),S.resolve()}getOverlaysForCollection(e,t,r){const s=Lt(),o=t.length+1,a=new F(t.child("")),u=this.overlays.getIteratorFrom(a);for(;u.hasNext();){const l=u.getNext().value,d=l.getKey();if(!t.isPrefixOf(d.path))break;d.path.length===o&&l.largestBatchId>r&&s.set(l.getKey(),l)}return S.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let o=new ie(((d,p)=>d-p));const a=this.overlays.getIterator();for(;a.hasNext();){const d=a.getNext().value;if(d.getKey().getCollectionGroup()===t&&d.largestBatchId>r){let p=o.get(d.largestBatchId);p===null&&(p=Lt(),o=o.insert(d.largestBatchId,p)),p.set(d.getKey(),d)}}const u=Lt(),l=o.getIterator();for(;l.hasNext()&&(l.getNext().value.forEach(((d,p)=>u.set(d,p))),!(u.size()>=s)););return S.resolve(u)}wt(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.kr.get(s.largestBatchId).delete(r.key);this.kr.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new ny(t,r));let o=this.kr.get(t);o===void 0&&(o=J(),this.kr.set(t,o)),this.kr.set(t,o.add(r.key))}}/**
|
|
2537
2537
|
* @license
|
|
2538
2538
|
* Copyright 2024 Google LLC
|
|
2539
2539
|
*
|
|
@@ -2548,7 +2548,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2548
2548
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2549
2549
|
* See the License for the specific language governing permissions and
|
|
2550
2550
|
* limitations under the License.
|
|
2551
|
-
*/class
|
|
2551
|
+
*/class xy{constructor(){this.sessionToken=ge.EMPTY_BYTE_STRING}getSessionToken(e){return S.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,S.resolve()}}/**
|
|
2552
2552
|
* @license
|
|
2553
2553
|
* Copyright 2017 Google LLC
|
|
2554
2554
|
*
|
|
@@ -2563,7 +2563,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2563
2563
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2564
2564
|
* See the License for the specific language governing permissions and
|
|
2565
2565
|
* limitations under the License.
|
|
2566
|
-
*/class Ao{constructor(){this.qr=new le(de.Qr),this.$r=new le(de.Ur)}isEmpty(){return this.qr.isEmpty()}addReference(e,t){const r=new de(e,t);this.qr=this.qr.add(r),this.$r=this.$r.add(r)}Kr(e,t){e.forEach((r=>this.addReference(r,t)))}removeReference(e,t){this.Wr(new de(e,t))}Gr(e,t){e.forEach((r=>this.removeReference(r,t)))}zr(e){const t=new
|
|
2566
|
+
*/class Ao{constructor(){this.qr=new le(de.Qr),this.$r=new le(de.Ur)}isEmpty(){return this.qr.isEmpty()}addReference(e,t){const r=new de(e,t);this.qr=this.qr.add(r),this.$r=this.$r.add(r)}Kr(e,t){e.forEach((r=>this.addReference(r,t)))}removeReference(e,t){this.Wr(new de(e,t))}Gr(e,t){e.forEach((r=>this.removeReference(r,t)))}zr(e){const t=new F(new te([])),r=new de(t,e),s=new de(t,e+1),o=[];return this.$r.forEachInRange([r,s],(a=>{this.Wr(a),o.push(a.key)})),o}jr(){this.qr.forEach((e=>this.Wr(e)))}Wr(e){this.qr=this.qr.delete(e),this.$r=this.$r.delete(e)}Jr(e){const t=new F(new te([])),r=new de(t,e),s=new de(t,e+1);let o=J();return this.$r.forEachInRange([r,s],(a=>{o=o.add(a.key)})),o}containsKey(e){const t=new de(e,0),r=this.qr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class de{constructor(e,t){this.key=e,this.Hr=t}static Qr(e,t){return F.comparator(e.key,t.key)||W(e.Hr,t.Hr)}static Ur(e,t){return W(e.Hr,t.Hr)||F.comparator(e.key,t.key)}}/**
|
|
2567
2567
|
* @license
|
|
2568
2568
|
* Copyright 2017 Google LLC
|
|
2569
2569
|
*
|
|
@@ -2578,7 +2578,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2578
2578
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2579
2579
|
* See the License for the specific language governing permissions and
|
|
2580
2580
|
* limitations under the License.
|
|
2581
|
-
*/class
|
|
2581
|
+
*/class Ly{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.er=1,this.Yr=new le(de.Qr)}checkEmpty(e){return S.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const o=this.er;this.er++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new ty(o,t,r,s);this.mutationQueue.push(a);for(const u of s)this.Yr=this.Yr.add(new de(u.key,o)),this.indexManager.addToCollectionParentIndex(e,u.key.path.popLast());return S.resolve(a)}lookupMutationBatch(e,t){return S.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.Xr(r),o=s<0?0:s;return S.resolve(this.mutationQueue.length>o?this.mutationQueue[o]:null)}getHighestUnacknowledgedBatchId(){return S.resolve(this.mutationQueue.length===0?g_:this.er-1)}getAllMutationBatches(e){return S.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new de(t,0),s=new de(t,Number.POSITIVE_INFINITY),o=[];return this.Yr.forEachInRange([r,s],(a=>{const u=this.Zr(a.Hr);o.push(u)})),S.resolve(o)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new le(W);return t.forEach((s=>{const o=new de(s,0),a=new de(s,Number.POSITIVE_INFINITY);this.Yr.forEachInRange([o,a],(u=>{r=r.add(u.Hr)}))})),S.resolve(this.ei(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let o=r;F.isDocumentKey(o)||(o=o.child(""));const a=new de(new F(o),0);let u=new le(W);return this.Yr.forEachWhile((l=>{const d=l.key.path;return!!r.isPrefixOf(d)&&(d.length===s&&(u=u.add(l.Hr)),!0)}),a),S.resolve(this.ei(u))}ei(e){const t=[];return e.forEach((r=>{const s=this.Zr(r);s!==null&&t.push(s)})),t}removeMutationBatch(e,t){ne(this.ti(t.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Yr;return S.forEach(t.mutations,(s=>{const o=new de(s.key,t.batchId);return r=r.delete(o),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)})).next((()=>{this.Yr=r}))}rr(e){}containsKey(e,t){const r=new de(t,0),s=this.Yr.firstAfterOrEqual(r);return S.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,S.resolve()}ti(e,t){return this.Xr(e)}Xr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Zr(e){const t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/**
|
|
2582
2582
|
* @license
|
|
2583
2583
|
* Copyright 2017 Google LLC
|
|
2584
2584
|
*
|
|
@@ -2593,7 +2593,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2593
2593
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2594
2594
|
* See the License for the specific language governing permissions and
|
|
2595
2595
|
* limitations under the License.
|
|
2596
|
-
*/class Uy{constructor(e){this.ni=e,this.docs=(function(){return new ie(
|
|
2596
|
+
*/class Uy{constructor(e){this.ni=e,this.docs=(function(){return new ie(F.comparator)})(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const r=t.key,s=this.docs.get(r),o=s?s.size:0,a=this.ni(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:a}),this.size+=a-o,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const r=this.docs.get(t);return S.resolve(r?r.document.mutableCopy():Ie.newInvalidDocument(t))}getEntries(e,t){let r=Ct();return t.forEach((s=>{const o=this.docs.get(s);r=r.insert(s,o?o.document.mutableCopy():Ie.newInvalidDocument(s))})),S.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let o=Ct();const a=t.path,u=new F(a.child("__id-9223372036854775808__")),l=this.docs.getIteratorFrom(u);for(;l.hasNext();){const{key:d,value:{document:p}}=l.getNext();if(!a.isPrefixOf(d.path))break;d.path.length>a.length+1||d_(h_(p),r)<=0||(s.has(p.key)||Os(t,p))&&(o=o.insert(p.key,p.mutableCopy()))}return S.resolve(o)}getAllFromCollectionGroup(e,t,r,s){H(9500)}ri(e,t){return S.forEach(this.docs,(r=>t(r)))}newChangeBuffer(e){return new Fy(this)}getSize(e){return S.resolve(this.size)}}class Fy extends Oy{constructor(e){super(),this.Or=e}applyChanges(e){const t=[];return this.changes.forEach(((r,s)=>{s.isValidDocument()?t.push(this.Or.addEntry(e,s)):this.Or.removeEntry(r)})),S.waitFor(t)}getFromCache(e,t){return this.Or.getEntry(e,t)}getAllFromCache(e,t){return this.Or.getEntries(e,t)}}/**
|
|
2597
2597
|
* @license
|
|
2598
2598
|
* Copyright 2017 Google LLC
|
|
2599
2599
|
*
|
|
@@ -2623,7 +2623,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2623
2623
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2624
2624
|
* See the License for the specific language governing permissions and
|
|
2625
2625
|
* limitations under the License.
|
|
2626
|
-
*/class uh{constructor(e,t){this.ai={},this.overlays={},this.ui=new Rs(0),this.ci=!1,this.ci=!0,this.li=new
|
|
2626
|
+
*/class uh{constructor(e,t){this.ai={},this.overlays={},this.ui=new Rs(0),this.ci=!1,this.ci=!0,this.li=new xy,this.referenceDelegate=e(this),this.hi=new jy(this),this.indexManager=new Ay,this.remoteDocumentCache=(function(s){return new Uy(s)})((r=>this.referenceDelegate.Pi(r))),this.serializer=new wy(t),this.Ti=new Vy(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ci=!1,Promise.resolve()}get started(){return this.ci}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new My,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.ai[e.toKey()];return r||(r=new Ly(t,this.referenceDelegate),this.ai[e.toKey()]=r),r}getGlobalsCache(){return this.li}getTargetCache(){return this.hi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ti}runTransaction(e,t,r){x("MemoryPersistence","Starting transaction:",e);const s=new By(this.ui.next());return this.referenceDelegate.Ii(),r(s).next((o=>this.referenceDelegate.di(s).next((()=>o)))).toPromise().then((o=>(s.raiseOnCommittedEvent(),o)))}Ei(e,t){return S.or(Object.values(this.ai).map((r=>()=>r.containsKey(e,t))))}}class By extends p_{constructor(e){super(),this.currentSequenceNumber=e}}class bo{constructor(e){this.persistence=e,this.Ai=new Ao,this.Ri=null}static Vi(e){return new bo(e)}get mi(){if(this.Ri)return this.Ri;throw H(60996)}addReference(e,t,r){return this.Ai.addReference(r,t),this.mi.delete(r.toString()),S.resolve()}removeReference(e,t,r){return this.Ai.removeReference(r,t),this.mi.add(r.toString()),S.resolve()}markPotentiallyOrphaned(e,t){return this.mi.add(t.toString()),S.resolve()}removeTarget(e,t){this.Ai.zr(t.targetId).forEach((s=>this.mi.add(s.toString())));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next((s=>{s.forEach((o=>this.mi.add(o.toString())))})).next((()=>r.removeTargetData(e,t)))}Ii(){this.Ri=new Set}di(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return S.forEach(this.mi,(r=>{const s=F.fromPath(r);return this.fi(e,s).next((o=>{o||t.removeEntry(s,$.min())}))})).next((()=>(this.Ri=null,t.apply(e))))}updateLimboDocument(e,t){return this.fi(e,t).next((r=>{r?this.mi.delete(t.toString()):this.mi.add(t.toString())}))}Pi(e){return 0}fi(e,t){return S.or([()=>S.resolve(this.Ai.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class gs{constructor(e,t){this.persistence=e,this.gi=new Wt((r=>__(r.path)),((r,s)=>r.isEqual(s))),this.garbageCollector=ky(this,t)}static Vi(e,t){return new gs(e,t)}Ii(){}di(e){return S.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}mr(e){const t=this.yr(e);return this.persistence.getTargetCache().getTargetCount(e).next((r=>t.next((s=>r+s))))}yr(e){let t=0;return this.gr(e,(r=>{t++})).next((()=>t))}gr(e,t){return S.forEach(this.gi,((r,s)=>this.Sr(e,r,s).next((o=>o?S.resolve():t(s)))))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0;const s=this.persistence.getRemoteDocumentCache(),o=s.newChangeBuffer();return s.ri(e,(a=>this.Sr(e,a,t).next((u=>{u||(r++,o.removeEntry(a,$.min()))})))).next((()=>o.apply(e))).next((()=>r))}markPotentiallyOrphaned(e,t){return this.gi.set(t,e.currentSequenceNumber),S.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.gi.set(r,e.currentSequenceNumber),S.resolve()}removeReference(e,t,r){return this.gi.set(r,e.currentSequenceNumber),S.resolve()}updateLimboDocument(e,t){return this.gi.set(t,e.currentSequenceNumber),S.resolve()}Pi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Yr(e.data.value)),t}Sr(e,t,r){return S.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.gi.get(t);return S.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}/**
|
|
2627
2627
|
* @license
|
|
2628
2628
|
* Copyright 2017 Google LLC
|
|
2629
2629
|
*
|
|
@@ -2668,7 +2668,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2668
2668
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2669
2669
|
* See the License for the specific language governing permissions and
|
|
2670
2670
|
* limitations under the License.
|
|
2671
|
-
*/class qy{constructor(){this.As=!1,this.Rs=!1,this.Vs=100,this.fs=(function(){return lf()?8:m_(Ae())>0?6:4})()}initialize(e,t){this.gs=e,this.indexManager=t,this.As=!0}getDocumentsMatchingQuery(e,t,r,s){const o={result:null};return this.ps(e,t).next((a=>{o.result=a})).next((()=>{if(!o.result)return this.ys(e,t,s,r).next((a=>{o.result=a}))})).next((()=>{if(o.result)return;const a=new $y;return this.ws(e,t,a).next((u=>{if(o.result=u,this.Rs)return this.Ss(e,t,a,u.size)}))})).next((()=>o.result))}Ss(e,t,r,s){return r.documentReadCount<this.Vs?(Yt()<=G.DEBUG&&
|
|
2671
|
+
*/class qy{constructor(){this.As=!1,this.Rs=!1,this.Vs=100,this.fs=(function(){return lf()?8:m_(Ae())>0?6:4})()}initialize(e,t){this.gs=e,this.indexManager=t,this.As=!0}getDocumentsMatchingQuery(e,t,r,s){const o={result:null};return this.ps(e,t).next((a=>{o.result=a})).next((()=>{if(!o.result)return this.ys(e,t,s,r).next((a=>{o.result=a}))})).next((()=>{if(o.result)return;const a=new $y;return this.ws(e,t,a).next((u=>{if(o.result=u,this.Rs)return this.Ss(e,t,a,u.size)}))})).next((()=>o.result))}Ss(e,t,r,s){return r.documentReadCount<this.Vs?(Yt()<=G.DEBUG&&x("QueryEngine","SDK will not create cache indexes for query:",Zt(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),S.resolve()):(Yt()<=G.DEBUG&&x("QueryEngine","Query:",Zt(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.fs*s?(Yt()<=G.DEBUG&&x("QueryEngine","The SDK decides to create cache indexes for query:",Zt(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,ze(t))):S.resolve())}ps(e,t){if(qc(t))return S.resolve(null);let r=ze(t);return this.indexManager.getIndexType(e,r).next((s=>s===0?null:(t.limit!==null&&s===1&&(t=Bi(t,null,"F"),r=ze(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next((o=>{const a=J(...o);return this.gs.getDocuments(e,a).next((u=>this.indexManager.getMinOffset(e,r).next((l=>{const d=this.bs(t,u);return this.Ds(t,d,a,l.readTime)?this.ps(e,Bi(t,null,"F")):this.vs(e,d,t,l)}))))})))))}ys(e,t,r,s){return qc(t)||s.isEqual($.min())?S.resolve(null):this.gs.getDocuments(e,r).next((o=>{const a=this.bs(t,o);return this.Ds(t,a,r,s)?S.resolve(null):(Yt()<=G.DEBUG&&x("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Zt(t)),this.vs(e,a,t,l_(s,rr)).next((u=>u)))}))}bs(e,t){let r=new le(Hl(e));return t.forEach(((s,o)=>{Os(e,o)&&(r=r.add(o))})),r}Ds(e,t,r,s){if(e.limit===null)return!1;if(r.size!==t.size)return!0;const o=e.limitType==="F"?t.last():t.first();return!!o&&(o.hasPendingWrites||o.version.compareTo(s)>0)}ws(e,t,r){return Yt()<=G.DEBUG&&x("QueryEngine","Using full collection scan to execute query:",Zt(t)),this.gs.getDocumentsMatchingQuery(e,t,At.min(),r)}vs(e,t,r,s){return this.gs.getDocumentsMatchingQuery(e,r,s).next((o=>(t.forEach((a=>{o=o.insert(a.key,a)})),o)))}}/**
|
|
2672
2672
|
* @license
|
|
2673
2673
|
* Copyright 2020 Google LLC
|
|
2674
2674
|
*
|
|
@@ -2683,7 +2683,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2683
2683
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2684
2684
|
* See the License for the specific language governing permissions and
|
|
2685
2685
|
* limitations under the License.
|
|
2686
|
-
*/const So="LocalStore",zy=3e8;class Hy{constructor(e,t,r,s){this.persistence=e,this.Cs=t,this.serializer=s,this.Fs=new ie(W),this.Ms=new Wt((o=>yo(o)),vo),this.xs=new Map,this.Os=e.getRemoteDocumentCache(),this.hi=e.getTargetCache(),this.Ti=e.getBundleCache(),this.Ns(r)}Ns(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Ny(this.Os,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Os.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.Fs)))}}function Wy(n,e,t,r){return new Hy(n,e,t,r)}async function lh(n,e){const t=Q(n);return await t.persistence.runTransaction("Handle user change","readonly",(r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next((o=>(s=o,t.Ns(e),t.mutationQueue.getAllMutationBatches(r)))).next((o=>{const a=[],u=[];let l=J();for(const d of s){a.push(d.batchId);for(const p of d.mutations)l=l.add(p.key)}for(const d of o){u.push(d.batchId);for(const p of d.mutations)l=l.add(p.key)}return t.localDocuments.getDocuments(r,l).next((d=>({Bs:d,removedBatchIds:a,addedBatchIds:u})))}))}))}function hh(n){const e=Q(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.hi.getLastRemoteSnapshotVersion(t)))}function Gy(n,e){const t=Q(n),r=e.snapshotVersion;let s=t.Fs;return t.persistence.runTransaction("Apply remote event","readwrite-primary",(o=>{const a=t.Os.newChangeBuffer({trackRemovals:!0});s=t.Fs;const u=[];e.targetChanges.forEach(((p,v)=>{const E=s.get(v);if(!E)return;u.push(t.hi.removeMatchingKeys(o,p.removedDocuments,v).next((()=>t.hi.addMatchingKeys(o,p.addedDocuments,v))));let C=E.withSequenceNumber(o.currentSequenceNumber);e.targetMismatches.get(v)!==null?C=C.withResumeToken(ge.EMPTY_BYTE_STRING,$.min()).withLastLimboFreeSnapshotVersion($.min()):p.resumeToken.approximateByteSize()>0&&(C=C.withResumeToken(p.resumeToken,r)),s=s.insert(v,C),(function(M,k,q){return M.resumeToken.approximateByteSize()===0||k.snapshotVersion.toMicroseconds()-M.snapshotVersion.toMicroseconds()>=zy?!0:q.addedDocuments.size+q.modifiedDocuments.size+q.removedDocuments.size>0})(E,C,p)&&u.push(t.hi.updateTargetData(o,C))}));let l=Ct(),d=J();if(e.documentUpdates.forEach((p=>{e.resolvedLimboDocuments.has(p)&&u.push(t.persistence.referenceDelegate.updateLimboDocument(o,p))})),u.push(Ky(o,a,e.documentUpdates).next((p=>{l=p.Ls,d=p.ks}))),!r.isEqual($.min())){const p=t.hi.getLastRemoteSnapshotVersion(o).next((v=>t.hi.setTargetsMetadata(o,o.currentSequenceNumber,r)));u.push(p)}return S.waitFor(u).next((()=>a.apply(o))).next((()=>t.localDocuments.getLocalViewOfDocuments(o,l,d))).next((()=>l))})).then((o=>(t.Fs=s,o)))}function Ky(n,e,t){let r=J(),s=J();return t.forEach((o=>r=r.add(o))),e.getEntries(n,r).next((o=>{let a=Ct();return t.forEach(((u,l)=>{const d=o.get(u);l.isFoundDocument()!==d.isFoundDocument()&&(s=s.add(u)),l.isNoDocument()&&l.version.isEqual($.min())?(e.removeEntry(u,l.readTime),a=a.insert(u,l)):!d.isValidDocument()||l.version.compareTo(d.version)>0||l.version.compareTo(d.version)===0&&d.hasPendingWrites?(e.addEntry(l),a=a.insert(u,l)):
|
|
2686
|
+
*/const So="LocalStore",zy=3e8;class Hy{constructor(e,t,r,s){this.persistence=e,this.Cs=t,this.serializer=s,this.Fs=new ie(W),this.Ms=new Wt((o=>yo(o)),vo),this.xs=new Map,this.Os=e.getRemoteDocumentCache(),this.hi=e.getTargetCache(),this.Ti=e.getBundleCache(),this.Ns(r)}Ns(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Ny(this.Os,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Os.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.Fs)))}}function Wy(n,e,t,r){return new Hy(n,e,t,r)}async function lh(n,e){const t=Q(n);return await t.persistence.runTransaction("Handle user change","readonly",(r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next((o=>(s=o,t.Ns(e),t.mutationQueue.getAllMutationBatches(r)))).next((o=>{const a=[],u=[];let l=J();for(const d of s){a.push(d.batchId);for(const p of d.mutations)l=l.add(p.key)}for(const d of o){u.push(d.batchId);for(const p of d.mutations)l=l.add(p.key)}return t.localDocuments.getDocuments(r,l).next((d=>({Bs:d,removedBatchIds:a,addedBatchIds:u})))}))}))}function hh(n){const e=Q(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.hi.getLastRemoteSnapshotVersion(t)))}function Gy(n,e){const t=Q(n),r=e.snapshotVersion;let s=t.Fs;return t.persistence.runTransaction("Apply remote event","readwrite-primary",(o=>{const a=t.Os.newChangeBuffer({trackRemovals:!0});s=t.Fs;const u=[];e.targetChanges.forEach(((p,v)=>{const E=s.get(v);if(!E)return;u.push(t.hi.removeMatchingKeys(o,p.removedDocuments,v).next((()=>t.hi.addMatchingKeys(o,p.addedDocuments,v))));let C=E.withSequenceNumber(o.currentSequenceNumber);e.targetMismatches.get(v)!==null?C=C.withResumeToken(ge.EMPTY_BYTE_STRING,$.min()).withLastLimboFreeSnapshotVersion($.min()):p.resumeToken.approximateByteSize()>0&&(C=C.withResumeToken(p.resumeToken,r)),s=s.insert(v,C),(function(M,k,q){return M.resumeToken.approximateByteSize()===0||k.snapshotVersion.toMicroseconds()-M.snapshotVersion.toMicroseconds()>=zy?!0:q.addedDocuments.size+q.modifiedDocuments.size+q.removedDocuments.size>0})(E,C,p)&&u.push(t.hi.updateTargetData(o,C))}));let l=Ct(),d=J();if(e.documentUpdates.forEach((p=>{e.resolvedLimboDocuments.has(p)&&u.push(t.persistence.referenceDelegate.updateLimboDocument(o,p))})),u.push(Ky(o,a,e.documentUpdates).next((p=>{l=p.Ls,d=p.ks}))),!r.isEqual($.min())){const p=t.hi.getLastRemoteSnapshotVersion(o).next((v=>t.hi.setTargetsMetadata(o,o.currentSequenceNumber,r)));u.push(p)}return S.waitFor(u).next((()=>a.apply(o))).next((()=>t.localDocuments.getLocalViewOfDocuments(o,l,d))).next((()=>l))})).then((o=>(t.Fs=s,o)))}function Ky(n,e,t){let r=J(),s=J();return t.forEach((o=>r=r.add(o))),e.getEntries(n,r).next((o=>{let a=Ct();return t.forEach(((u,l)=>{const d=o.get(u);l.isFoundDocument()!==d.isFoundDocument()&&(s=s.add(u)),l.isNoDocument()&&l.version.isEqual($.min())?(e.removeEntry(u,l.readTime),a=a.insert(u,l)):!d.isValidDocument()||l.version.compareTo(d.version)>0||l.version.compareTo(d.version)===0&&d.hasPendingWrites?(e.addEntry(l),a=a.insert(u,l)):x(So,"Ignoring outdated watch update for ",u,". Current version:",d.version," Watch version:",l.version)})),{Ls:a,ks:s}}))}function Qy(n,e){const t=Q(n);return t.persistence.runTransaction("Allocate target","readwrite",(r=>{let s;return t.hi.getTargetData(r,e).next((o=>o?(s=o,S.resolve(s)):t.hi.allocateTargetId(r).next((a=>(s=new gt(e,a,"TargetPurposeListen",r.currentSequenceNumber),t.hi.addTargetData(r,s).next((()=>s)))))))})).then((r=>{const s=t.Fs.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.Fs=t.Fs.insert(r.targetId,r),t.Ms.set(e,r.targetId)),r}))}async function Wi(n,e,t){const r=Q(n),s=r.Fs.get(e),o=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",o,(a=>r.persistence.referenceDelegate.removeTarget(a,s)))}catch(a){if(!Tn(a))throw a;x(So,`Failed to update sequence numbers for target ${e}: ${a}`)}r.Fs=r.Fs.remove(e),r.Ms.delete(s.target)}function nu(n,e,t){const r=Q(n);let s=$.min(),o=J();return r.persistence.runTransaction("Execute query","readwrite",(a=>(function(l,d,p){const v=Q(l),E=v.Ms.get(p);return E!==void 0?S.resolve(v.Fs.get(E)):v.hi.getTargetData(d,p)})(r,a,ze(e)).next((u=>{if(u)return s=u.lastLimboFreeSnapshotVersion,r.hi.getMatchingKeysForTargetId(a,u.targetId).next((l=>{o=l}))})).next((()=>r.Cs.getDocumentsMatchingQuery(a,e,t?s:$.min(),t?o:J()))).next((u=>(Jy(r,j_(e),u),{documents:u,qs:o})))))}function Jy(n,e,t){let r=n.xs.get(e)||$.min();t.forEach(((s,o)=>{o.readTime.compareTo(r)>0&&(r=o.readTime)})),n.xs.set(e,r)}class ru{constructor(){this.activeTargetIds=W_()}Gs(e){this.activeTargetIds=this.activeTargetIds.add(e)}zs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class Xy{constructor(){this.Fo=new ru,this.Mo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.Fo.Gs(e),this.Mo[e]||"not-current"}updateQueryState(e,t,r){this.Mo[e]=t}removeLocalQueryTarget(e){this.Fo.zs(e)}isLocalQueryTarget(e){return this.Fo.activeTargetIds.has(e)}clearQueryState(e){delete this.Mo[e]}getAllActiveQueryTargets(){return this.Fo.activeTargetIds}isActiveQueryTarget(e){return this.Fo.activeTargetIds.has(e)}start(){return this.Fo=new ru,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/**
|
|
2687
2687
|
* @license
|
|
2688
2688
|
* Copyright 2019 Google LLC
|
|
2689
2689
|
*
|
|
@@ -2713,7 +2713,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2713
2713
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2714
2714
|
* See the License for the specific language governing permissions and
|
|
2715
2715
|
* limitations under the License.
|
|
2716
|
-
*/const su="ConnectivityMonitor";class iu{constructor(){this.Oo=()=>this.No(),this.Bo=()=>this.Lo(),this.ko=[],this.qo()}xo(e){this.ko.push(e)}shutdown(){window.removeEventListener("online",this.Oo),window.removeEventListener("offline",this.Bo)}qo(){window.addEventListener("online",this.Oo),window.addEventListener("offline",this.Bo)}No(){
|
|
2716
|
+
*/const su="ConnectivityMonitor";class iu{constructor(){this.Oo=()=>this.No(),this.Bo=()=>this.Lo(),this.ko=[],this.qo()}xo(e){this.ko.push(e)}shutdown(){window.removeEventListener("online",this.Oo),window.removeEventListener("offline",this.Bo)}qo(){window.addEventListener("online",this.Oo),window.addEventListener("offline",this.Bo)}No(){x(su,"Network connectivity changed: AVAILABLE");for(const e of this.ko)e(0)}Lo(){x(su,"Network connectivity changed: UNAVAILABLE");for(const e of this.ko)e(1)}static C(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
|
|
2717
2717
|
* @license
|
|
2718
2718
|
* Copyright 2023 Google LLC
|
|
2719
2719
|
*
|
|
@@ -2743,7 +2743,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2743
2743
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2744
2744
|
* See the License for the specific language governing permissions and
|
|
2745
2745
|
* limitations under the License.
|
|
2746
|
-
*/const vi="RestConnection",Zy={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class ev{get Qo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.$o=t+"://"+e.host,this.Uo=`projects/${r}/databases/${s}`,this.Ko=this.databaseId.database===hs?`project_id=${r}`:`project_id=${r}&database_id=${s}`}Wo(e,t,r,s,o){const a=Gi(),u=this.Go(e,t.toUriEncodedString());
|
|
2746
|
+
*/const vi="RestConnection",Zy={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class ev{get Qo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.$o=t+"://"+e.host,this.Uo=`projects/${r}/databases/${s}`,this.Ko=this.databaseId.database===hs?`project_id=${r}`:`project_id=${r}&database_id=${s}`}Wo(e,t,r,s,o){const a=Gi(),u=this.Go(e,t.toUriEncodedString());x(vi,`Sending RPC '${e}' ${a}:`,u,r);const l={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.Ko};this.zo(l,s,o);const{host:d}=new URL(u),p=_n(d);return this.jo(e,u,l,r,p).then((v=>(x(vi,`Received RPC '${e}' ${a}: `,v),v)),(v=>{throw It(vi,`RPC '${e}' ${a} failed with error: `,v,"url: ",u,"request:",r),v}))}Jo(e,t,r,s,o,a){return this.Wo(e,t,r,s,o)}zo(e,t,r){e["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+En})(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((s,o)=>e[o]=s)),r&&r.headers.forEach(((s,o)=>e[o]=s))}Go(e,t){const r=Zy[e];return`${this.$o}/v1/${t}:${r}`}terminate(){}}/**
|
|
2747
2747
|
* @license
|
|
2748
2748
|
* Copyright 2017 Google LLC
|
|
2749
2749
|
*
|
|
@@ -2773,7 +2773,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2773
2773
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2774
2774
|
* See the License for the specific language governing permissions and
|
|
2775
2775
|
* limitations under the License.
|
|
2776
|
-
*/const Te="WebChannelConnection";class nv extends ev{constructor(e){super(e),this.u_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}jo(e,t,r,s,o){const a=Gi();return new Promise(((u,l)=>{const d=new Al;d.setWithCredentials(!0),d.listenOnce(bl.COMPLETE,(()=>{try{switch(d.getLastErrorCode()){case Jr.NO_ERROR:const v=d.getResponseJson();
|
|
2776
|
+
*/const Te="WebChannelConnection";class nv extends ev{constructor(e){super(e),this.u_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}jo(e,t,r,s,o){const a=Gi();return new Promise(((u,l)=>{const d=new Al;d.setWithCredentials(!0),d.listenOnce(bl.COMPLETE,(()=>{try{switch(d.getLastErrorCode()){case Jr.NO_ERROR:const v=d.getResponseJson();x(Te,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(v)),u(v);break;case Jr.TIMEOUT:x(Te,`RPC '${e}' ${a} timed out`),l(new L(N.DEADLINE_EXCEEDED,"Request time out"));break;case Jr.HTTP_ERROR:const E=d.getStatus();if(x(Te,`RPC '${e}' ${a} failed with status:`,E,"response text:",d.getResponseText()),E>0){let C=d.getResponseJson();Array.isArray(C)&&(C=C[0]);const V=C?.error;if(V&&V.status&&V.message){const M=(function(q){const z=q.toLowerCase().replace(/_/g,"-");return Object.values(N).indexOf(z)>=0?z:N.UNKNOWN})(V.status);l(new L(M,V.message))}else l(new L(N.UNKNOWN,"Server responded with status "+d.getStatus()))}else l(new L(N.UNAVAILABLE,"Connection failed."));break;default:H(9055,{c_:e,streamId:a,l_:d.getLastErrorCode(),h_:d.getLastError()})}}finally{x(Te,`RPC '${e}' ${a} completed.`)}}));const p=JSON.stringify(s);x(Te,`RPC '${e}' ${a} sending request:`,s),d.send(t,"POST",p,r,15)}))}P_(e,t,r){const s=Gi(),o=[this.$o,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=Cl(),u=Sl(),l={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},d=this.longPollingOptions.timeoutSeconds;d!==void 0&&(l.longPollingTimeout=Math.round(1e3*d)),this.useFetchStreams&&(l.useFetchStreams=!0),this.zo(l.initMessageHeaders,t,r),l.encodeInitMessageHeaders=!0;const p=o.join("");x(Te,`Creating RPC '${e}' stream ${s}: ${p}`,l);const v=a.createWebChannel(p,l);this.T_(v);let E=!1,C=!1;const V=new tv({Ho:k=>{C?x(Te,`Not sending because RPC '${e}' stream ${s} is closed:`,k):(E||(x(Te,`Opening RPC '${e}' stream ${s} transport.`),v.open(),E=!0),x(Te,`RPC '${e}' stream ${s} sending:`,k),v.send(k))},Yo:()=>v.close()}),M=(k,q,z)=>{k.listen(q,(B=>{try{z(B)}catch(Y){setTimeout((()=>{throw Y}),0)}}))};return M(v,$n.EventType.OPEN,(()=>{C||(x(Te,`RPC '${e}' stream ${s} transport opened.`),V.s_())})),M(v,$n.EventType.CLOSE,(()=>{C||(C=!0,x(Te,`RPC '${e}' stream ${s} transport closed`),V.__(),this.I_(v))})),M(v,$n.EventType.ERROR,(k=>{C||(C=!0,It(Te,`RPC '${e}' stream ${s} transport errored. Name:`,k.name,"Message:",k.message),V.__(new L(N.UNAVAILABLE,"The operation could not be completed")))})),M(v,$n.EventType.MESSAGE,(k=>{var q;if(!C){const z=k.data[0];ne(!!z,16349);const B=z,Y=B?.error||((q=B[0])===null||q===void 0?void 0:q.error);if(Y){x(Te,`RPC '${e}' stream ${s} received error:`,Y);const he=Y.status;let P=(function(g){const T=oe[g];if(T!==void 0)return Zl(T)})(he),_=Y.message;P===void 0&&(P=N.INTERNAL,_="Unknown error status: "+he+" with message "+Y.message),C=!0,V.__(new L(P,_)),v.close()}else x(Te,`RPC '${e}' stream ${s} received:`,z),V.a_(z)}})),M(u,Rl.STAT_EVENT,(k=>{k.stat===Ni.PROXY?x(Te,`RPC '${e}' stream ${s} detected buffering proxy`):k.stat===Ni.NOPROXY&&x(Te,`RPC '${e}' stream ${s} detected no buffering proxy`)})),setTimeout((()=>{V.o_()}),0),V}terminate(){this.u_.forEach((e=>e.close())),this.u_=[]}T_(e){this.u_.push(e)}I_(e){this.u_=this.u_.filter((t=>t===e))}}function Ei(){return typeof document<"u"?document:null}/**
|
|
2777
2777
|
* @license
|
|
2778
2778
|
* Copyright 2020 Google LLC
|
|
2779
2779
|
*
|
|
@@ -2803,7 +2803,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2803
2803
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2804
2804
|
* See the License for the specific language governing permissions and
|
|
2805
2805
|
* limitations under the License.
|
|
2806
|
-
*/class fh{constructor(e,t,r=1e3,s=1.5,o=6e4){this.Fi=e,this.timerId=t,this.d_=r,this.E_=s,this.A_=o,this.R_=0,this.V_=null,this.m_=Date.now(),this.reset()}reset(){this.R_=0}f_(){this.R_=this.A_}g_(e){this.cancel();const t=Math.floor(this.R_+this.p_()),r=Math.max(0,Date.now()-this.m_),s=Math.max(0,t-r);s>0&&
|
|
2806
|
+
*/class fh{constructor(e,t,r=1e3,s=1.5,o=6e4){this.Fi=e,this.timerId=t,this.d_=r,this.E_=s,this.A_=o,this.R_=0,this.V_=null,this.m_=Date.now(),this.reset()}reset(){this.R_=0}f_(){this.R_=this.A_}g_(e){this.cancel();const t=Math.floor(this.R_+this.p_()),r=Math.max(0,Date.now()-this.m_),s=Math.max(0,t-r);s>0&&x("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.R_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.V_=this.Fi.enqueueAfterDelay(this.timerId,s,(()=>(this.m_=Date.now(),e()))),this.R_*=this.E_,this.R_<this.d_&&(this.R_=this.d_),this.R_>this.A_&&(this.R_=this.A_)}y_(){this.V_!==null&&(this.V_.skipDelay(),this.V_=null)}cancel(){this.V_!==null&&(this.V_.cancel(),this.V_=null)}p_(){return(Math.random()-.5)*this.R_}}/**
|
|
2807
2807
|
* @license
|
|
2808
2808
|
* Copyright 2017 Google LLC
|
|
2809
2809
|
*
|
|
@@ -2818,7 +2818,7 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2818
2818
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2819
2819
|
* See the License for the specific language governing permissions and
|
|
2820
2820
|
* limitations under the License.
|
|
2821
|
-
*/const ou="PersistentStream";class rv{constructor(e,t,r,s,o,a,u,l){this.Fi=e,this.w_=r,this.S_=s,this.connection=o,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=u,this.listener=l,this.state=0,this.b_=0,this.D_=null,this.v_=null,this.stream=null,this.C_=0,this.F_=new fh(e,t)}M_(){return this.state===1||this.state===5||this.x_()}x_(){return this.state===2||this.state===3}start(){this.C_=0,this.state!==4?this.auth():this.O_()}async stop(){this.M_()&&await this.close(0)}N_(){this.state=0,this.F_.reset()}B_(){this.x_()&&this.D_===null&&(this.D_=this.Fi.enqueueAfterDelay(this.w_,6e4,(()=>this.L_())))}k_(e){this.q_(),this.stream.send(e)}async L_(){if(this.x_())return this.close(0)}q_(){this.D_&&(this.D_.cancel(),this.D_=null)}Q_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.Q_(),this.F_.cancel(),this.b_++,e!==4?this.F_.reset():t&&t.code===N.RESOURCE_EXHAUSTED?(nt(t.toString()),nt("Using maximum backoff delay to prevent overloading the backend."),this.F_.f_()):t&&t.code===N.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.U_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.n_(t)}U_(){}auth(){this.state=1;const e=this.K_(this.b_),t=this.b_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([r,s])=>{this.b_===t&&this.W_(r,s)}),(r=>{e((()=>{const s=new
|
|
2821
|
+
*/const ou="PersistentStream";class rv{constructor(e,t,r,s,o,a,u,l){this.Fi=e,this.w_=r,this.S_=s,this.connection=o,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=u,this.listener=l,this.state=0,this.b_=0,this.D_=null,this.v_=null,this.stream=null,this.C_=0,this.F_=new fh(e,t)}M_(){return this.state===1||this.state===5||this.x_()}x_(){return this.state===2||this.state===3}start(){this.C_=0,this.state!==4?this.auth():this.O_()}async stop(){this.M_()&&await this.close(0)}N_(){this.state=0,this.F_.reset()}B_(){this.x_()&&this.D_===null&&(this.D_=this.Fi.enqueueAfterDelay(this.w_,6e4,(()=>this.L_())))}k_(e){this.q_(),this.stream.send(e)}async L_(){if(this.x_())return this.close(0)}q_(){this.D_&&(this.D_.cancel(),this.D_=null)}Q_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.Q_(),this.F_.cancel(),this.b_++,e!==4?this.F_.reset():t&&t.code===N.RESOURCE_EXHAUSTED?(nt(t.toString()),nt("Using maximum backoff delay to prevent overloading the backend."),this.F_.f_()):t&&t.code===N.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.U_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.n_(t)}U_(){}auth(){this.state=1;const e=this.K_(this.b_),t=this.b_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([r,s])=>{this.b_===t&&this.W_(r,s)}),(r=>{e((()=>{const s=new L(N.UNKNOWN,"Fetching auth token failed: "+r.message);return this.G_(s)}))}))}W_(e,t){const r=this.K_(this.b_);this.stream=this.z_(e,t),this.stream.Zo((()=>{r((()=>this.listener.Zo()))})),this.stream.e_((()=>{r((()=>(this.state=2,this.v_=this.Fi.enqueueAfterDelay(this.S_,1e4,(()=>(this.x_()&&(this.state=3),Promise.resolve()))),this.listener.e_())))})),this.stream.n_((s=>{r((()=>this.G_(s)))})),this.stream.onMessage((s=>{r((()=>++this.C_==1?this.j_(s):this.onNext(s)))}))}O_(){this.state=5,this.F_.g_((async()=>{this.state=0,this.start()}))}G_(e){return x(ou,`close with error: ${e}`),this.stream=null,this.close(4,e)}K_(e){return t=>{this.Fi.enqueueAndForget((()=>this.b_===e?t():(x(ou,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class sv extends rv{constructor(e,t,r,s,o,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,a),this.serializer=o}z_(e,t){return this.connection.P_("Listen",e,t)}j_(e){return this.onNext(e)}onNext(e){this.F_.reset();const t=py(this.serializer,e),r=(function(o){if(!("targetChange"in o))return $.min();const a=o.targetChange;return a.targetIds&&a.targetIds.length?$.min():a.readTime?an(a.readTime):$.min()})(e);return this.listener.J_(t,r)}H_(e){const t={};t.database=Yc(this.serializer),t.addTarget=(function(o,a){let u;const l=a.target;if(u=ji(l)?{documents:my(o,l)}:{query:gy(o,l).Vt},u.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){u.resumeToken=hy(o,a.resumeToken);const d=zi(o,a.expectedCount);d!==null&&(u.expectedCount=d)}else if(a.snapshotVersion.compareTo($.min())>0){u.readTime=ly(o,a.snapshotVersion.toTimestamp());const d=zi(o,a.expectedCount);d!==null&&(u.expectedCount=d)}return u})(this.serializer,e);const r=yy(this.serializer,e);r&&(t.labels=r),this.k_(t)}Y_(e){const t={};t.database=Yc(this.serializer),t.removeTarget=e,this.k_(t)}}/**
|
|
2822
2822
|
* @license
|
|
2823
2823
|
* Copyright 2017 Google LLC
|
|
2824
2824
|
*
|
|
@@ -2833,8 +2833,8 @@ Total Duration: ${d-p}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targe
|
|
|
2833
2833
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2834
2834
|
* See the License for the specific language governing permissions and
|
|
2835
2835
|
* limitations under the License.
|
|
2836
|
-
*/class iv{}class ov extends iv{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.ra=!1}ia(){if(this.ra)throw new
|
|
2837
|
-
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this._a?(nt(t),this._a=!1):
|
|
2836
|
+
*/class iv{}class ov extends iv{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.ra=!1}ia(){if(this.ra)throw new L(N.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,r,s){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([o,a])=>this.connection.Wo(e,Hi(t,r),s,o,a))).catch((o=>{throw o.name==="FirebaseError"?(o.code===N.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new L(N.UNKNOWN,o.toString())}))}Jo(e,t,r,s,o){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,u])=>this.connection.Jo(e,Hi(t,r),s,a,u,o))).catch((a=>{throw a.name==="FirebaseError"?(a.code===N.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new L(N.UNKNOWN,a.toString())}))}terminate(){this.ra=!0,this.connection.terminate()}}class av{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.sa=0,this.oa=null,this._a=!0}aa(){this.sa===0&&(this.ua("Unknown"),this.oa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.oa=null,this.ca("Backend didn't respond within 10 seconds."),this.ua("Offline"),Promise.resolve()))))}la(e){this.state==="Online"?this.ua("Unknown"):(this.sa++,this.sa>=1&&(this.ha(),this.ca(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ua("Offline")))}set(e){this.ha(),this.sa=0,e==="Online"&&(this._a=!1),this.ua(e)}ua(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ca(e){const t=`Could not reach Cloud Firestore backend. ${e}
|
|
2837
|
+
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this._a?(nt(t),this._a=!1):x("OnlineStateTracker",t)}ha(){this.oa!==null&&(this.oa.cancel(),this.oa=null)}}/**
|
|
2838
2838
|
* @license
|
|
2839
2839
|
* Copyright 2017 Google LLC
|
|
2840
2840
|
*
|
|
@@ -2849,7 +2849,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
2849
2849
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2850
2850
|
* See the License for the specific language governing permissions and
|
|
2851
2851
|
* limitations under the License.
|
|
2852
|
-
*/const mn="RemoteStore";class cv{constructor(e,t,r,s,o){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Set,this.da=[],this.Ea=o,this.Ea.xo((a=>{r.enqueueAndForget((async()=>{yr(this)&&(
|
|
2852
|
+
*/const mn="RemoteStore";class cv{constructor(e,t,r,s,o){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Set,this.da=[],this.Ea=o,this.Ea.xo((a=>{r.enqueueAndForget((async()=>{yr(this)&&(x(mn,"Restarting streams for network reachability change."),await(async function(l){const d=Q(l);d.Ia.add(4),await _r(d),d.Aa.set("Unknown"),d.Ia.delete(4),await Ms(d)})(this))}))})),this.Aa=new av(r,s)}}async function Ms(n){if(yr(n))for(const e of n.da)await e(!0)}async function _r(n){for(const e of n.da)await e(!1)}function ph(n,e){const t=Q(n);t.Ta.has(e.targetId)||(t.Ta.set(e.targetId,e),Oo(t)?ko(t):wn(t).x_()&&Po(t,e))}function Co(n,e){const t=Q(n),r=wn(t);t.Ta.delete(e),r.x_()&&mh(t,e),t.Ta.size===0&&(r.x_()?r.B_():yr(t)&&t.Aa.set("Unknown"))}function Po(n,e){if(n.Ra.$e(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo($.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}wn(n).H_(e)}function mh(n,e){n.Ra.$e(e),wn(n).Y_(e)}function ko(n){n.Ra=new iy({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),Et:e=>n.Ta.get(e)||null,lt:()=>n.datastore.serializer.databaseId}),wn(n).start(),n.Aa.aa()}function Oo(n){return yr(n)&&!wn(n).M_()&&n.Ta.size>0}function yr(n){return Q(n).Ia.size===0}function gh(n){n.Ra=void 0}async function uv(n){n.Aa.set("Online")}async function lv(n){n.Ta.forEach(((e,t)=>{Po(n,e)}))}async function hv(n,e){gh(n),Oo(n)?(n.Aa.la(e),ko(n)):n.Aa.set("Unknown")}async function dv(n,e,t){if(n.Aa.set("Online"),e instanceof th&&e.state===2&&e.cause)try{await(async function(s,o){const a=o.cause;for(const u of o.targetIds)s.Ta.has(u)&&(await s.remoteSyncer.rejectListen(u,a),s.Ta.delete(u),s.Ra.removeTarget(u))})(n,e)}catch(r){x(mn,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await au(n,r)}else if(e instanceof es?n.Ra.Ye(e):e instanceof eh?n.Ra.it(e):n.Ra.et(e),!t.isEqual($.min()))try{const r=await hh(n.localStore);t.compareTo(r)>=0&&await(function(o,a){const u=o.Ra.Pt(a);return u.targetChanges.forEach(((l,d)=>{if(l.resumeToken.approximateByteSize()>0){const p=o.Ta.get(d);p&&o.Ta.set(d,p.withResumeToken(l.resumeToken,a))}})),u.targetMismatches.forEach(((l,d)=>{const p=o.Ta.get(l);if(!p)return;o.Ta.set(l,p.withResumeToken(ge.EMPTY_BYTE_STRING,p.snapshotVersion)),mh(o,l);const v=new gt(p.target,l,d,p.sequenceNumber);Po(o,v)})),o.remoteSyncer.applyRemoteEvent(u)})(n,t)}catch(r){x(mn,"Failed to raise snapshot:",r),await au(n,r)}}async function au(n,e,t){if(!Tn(e))throw e;n.Ia.add(1),await _r(n),n.Aa.set("Offline"),t||(t=()=>hh(n.localStore)),n.asyncQueue.enqueueRetryable((async()=>{x(mn,"Retrying IndexedDB access"),await t(),n.Ia.delete(1),await Ms(n)}))}async function cu(n,e){const t=Q(n);t.asyncQueue.verifyOperationInProgress(),x(mn,"RemoteStore received new credentials");const r=yr(t);t.Ia.add(3),await _r(t),r&&t.Aa.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.Ia.delete(3),await Ms(t)}async function fv(n,e){const t=Q(n);e?(t.Ia.delete(2),await Ms(t)):e||(t.Ia.add(2),await _r(t),t.Aa.set("Unknown"))}function wn(n){return n.Va||(n.Va=(function(t,r,s){const o=Q(t);return o.ia(),new sv(r,o.connection,o.authCredentials,o.appCheckCredentials,o.serializer,s)})(n.datastore,n.asyncQueue,{Zo:uv.bind(null,n),e_:lv.bind(null,n),n_:hv.bind(null,n),J_:dv.bind(null,n)}),n.da.push((async e=>{e?(n.Va.N_(),Oo(n)?ko(n):n.Aa.set("Unknown")):(await n.Va.stop(),gh(n))}))),n.Va}/**
|
|
2853
2853
|
* @license
|
|
2854
2854
|
* Copyright 2017 Google LLC
|
|
2855
2855
|
*
|
|
@@ -2864,7 +2864,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
2864
2864
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2865
2865
|
* See the License for the specific language governing permissions and
|
|
2866
2866
|
* limitations under the License.
|
|
2867
|
-
*/class Do{constructor(e,t,r,s,o){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=o,this.deferred=new on,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((a=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,o){const a=Date.now()+r,u=new Do(e,t,a,s,o);return u.start(r),u}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new
|
|
2867
|
+
*/class Do{constructor(e,t,r,s,o){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=o,this.deferred=new on,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((a=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,o){const a=Date.now()+r,u=new Do(e,t,a,s,o);return u.start(r),u}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new L(N.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function _h(n,e){if(nt("AsyncQueue",`${e}: ${n}`),Tn(n))return new L(N.UNAVAILABLE,`${e}: ${n}`);throw n}/**
|
|
2868
2868
|
* @license
|
|
2869
2869
|
* Copyright 2017 Google LLC
|
|
2870
2870
|
*
|
|
@@ -2879,7 +2879,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
2879
2879
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2880
2880
|
* See the License for the specific language governing permissions and
|
|
2881
2881
|
* limitations under the License.
|
|
2882
|
-
*/class cn{static emptySet(e){return new cn(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||
|
|
2882
|
+
*/class cn{static emptySet(e){return new cn(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||F.comparator(t.key,r.key):(t,r)=>F.comparator(t.key,r.key),this.keyedMap=qn(),this.sortedSet=new ie(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,r)=>(e(t),!1)))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof cn)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){const s=t.getNext().key,o=r.getNext().key;if(!s.isEqual(o))return!1}return!0}toString(){const e=[];return this.forEach((t=>{e.push(t.toString())})),e.length===0?"DocumentSet ()":`DocumentSet (
|
|
2883
2883
|
`+e.join(`
|
|
2884
2884
|
`)+`
|
|
2885
2885
|
)`}copy(e,t){const r=new cn;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}/**
|
|
@@ -2897,7 +2897,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
2897
2897
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2898
2898
|
* See the License for the specific language governing permissions and
|
|
2899
2899
|
* limitations under the License.
|
|
2900
|
-
*/class uu{constructor(){this.fa=new ie(
|
|
2900
|
+
*/class uu{constructor(){this.fa=new ie(F.comparator)}track(e){const t=e.doc.key,r=this.fa.get(t);r?e.type!==0&&r.type===3?this.fa=this.fa.insert(t,e):e.type===3&&r.type!==1?this.fa=this.fa.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.fa=this.fa.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.fa=this.fa.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.fa=this.fa.remove(t):e.type===1&&r.type===2?this.fa=this.fa.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.fa=this.fa.insert(t,{type:2,doc:e.doc}):H(63341,{At:e,ga:r}):this.fa=this.fa.insert(t,e)}pa(){const e=[];return this.fa.inorderTraversal(((t,r)=>{e.push(r)})),e}}class gn{constructor(e,t,r,s,o,a,u,l,d){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=o,this.fromCache=a,this.syncStateChanged=u,this.excludesMetadataChanges=l,this.hasCachedResults=d}static fromInitialDocuments(e,t,r,s,o){const a=[];return t.forEach((u=>{a.push({type:0,doc:u})})),new gn(e,t,cn.emptySet(t),a,r,s,!0,!1,o)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&ks(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}}/**
|
|
2901
2901
|
* @license
|
|
2902
2902
|
* Copyright 2017 Google LLC
|
|
2903
2903
|
*
|
|
@@ -2912,7 +2912,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
2912
2912
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2913
2913
|
* See the License for the specific language governing permissions and
|
|
2914
2914
|
* limitations under the License.
|
|
2915
|
-
*/class pv{constructor(){this.ya=void 0,this.wa=[]}Sa(){return this.wa.some((e=>e.ba()))}}class mv{constructor(){this.queries=lu(),this.onlineState="Unknown",this.Da=new Set}terminate(){(function(t,r){const s=Q(t),o=s.queries;s.queries=lu(),o.forEach(((a,u)=>{for(const l of u.wa)l.onError(r)}))})(this,new
|
|
2915
|
+
*/class pv{constructor(){this.ya=void 0,this.wa=[]}Sa(){return this.wa.some((e=>e.ba()))}}class mv{constructor(){this.queries=lu(),this.onlineState="Unknown",this.Da=new Set}terminate(){(function(t,r){const s=Q(t),o=s.queries;s.queries=lu(),o.forEach(((a,u)=>{for(const l of u.wa)l.onError(r)}))})(this,new L(N.ABORTED,"Firestore shutting down"))}}function lu(){return new Wt((n=>zl(n)),ks)}async function gv(n,e){const t=Q(n);let r=3;const s=e.query;let o=t.queries.get(s);o?!o.Sa()&&e.ba()&&(r=2):(o=new pv,r=e.ba()?0:1);try{switch(r){case 0:o.ya=await t.onListen(s,!0);break;case 1:o.ya=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(a){const u=_h(a,`Initialization of query '${Zt(e.query)}' failed`);return void e.onError(u)}t.queries.set(s,o),o.wa.push(e),e.va(t.onlineState),o.ya&&e.Ca(o.ya)&&No(t)}async function _v(n,e){const t=Q(n),r=e.query;let s=3;const o=t.queries.get(r);if(o){const a=o.wa.indexOf(e);a>=0&&(o.wa.splice(a,1),o.wa.length===0?s=e.ba()?0:1:!o.Sa()&&e.ba()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function yv(n,e){const t=Q(n);let r=!1;for(const s of e){const o=s.query,a=t.queries.get(o);if(a){for(const u of a.wa)u.Ca(s)&&(r=!0);a.ya=s}}r&&No(t)}function vv(n,e,t){const r=Q(n),s=r.queries.get(e);if(s)for(const o of s.wa)o.onError(t);r.queries.delete(e)}function No(n){n.Da.forEach((e=>{e.next()}))}var Ki,hu;(hu=Ki||(Ki={})).Fa="default",hu.Cache="cache";class Ev{constructor(e,t,r){this.query=e,this.Ma=t,this.xa=!1,this.Oa=null,this.onlineState="Unknown",this.options=r||{}}Ca(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new gn(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.xa?this.Na(e)&&(this.Ma.next(e),t=!0):this.Ba(e,this.onlineState)&&(this.La(e),t=!0),this.Oa=e,t}onError(e){this.Ma.error(e)}va(e){this.onlineState=e;let t=!1;return this.Oa&&!this.xa&&this.Ba(this.Oa,e)&&(this.La(this.Oa),t=!0),t}Ba(e,t){if(!e.fromCache||!this.ba())return!0;const r=t!=="Offline";return(!this.options.ka||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Na(e){if(e.docChanges.length>0)return!0;const t=this.Oa&&this.Oa.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}La(e){e=gn.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.xa=!0,this.Ma.next(e)}ba(){return this.options.source!==Ki.Cache}}/**
|
|
2916
2916
|
* @license
|
|
2917
2917
|
* Copyright 2017 Google LLC
|
|
2918
2918
|
*
|
|
@@ -2927,7 +2927,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
2927
2927
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2928
2928
|
* See the License for the specific language governing permissions and
|
|
2929
2929
|
* limitations under the License.
|
|
2930
|
-
*/class yh{constructor(e){this.key=e}}class vh{constructor(e){this.key=e}}class Tv{constructor(e,t){this.query=e,this.Ha=t,this.Ya=null,this.hasCachedResults=!1,this.current=!1,this.Za=J(),this.mutatedKeys=J(),this.Xa=Hl(e),this.eu=new cn(this.Xa)}get tu(){return this.Ha}nu(e,t){const r=t?t.ru:new uu,s=t?t.eu:this.eu;let o=t?t.mutatedKeys:this.mutatedKeys,a=s,u=!1;const l=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,d=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal(((p,v)=>{const E=s.get(p),C=Os(this.query,v)?v:null,V=!!E&&this.mutatedKeys.has(E.key),M=!!C&&(C.hasLocalMutations||this.mutatedKeys.has(C.key)&&C.hasCommittedMutations);let k=!1;E&&C?E.data.isEqual(C.data)?V!==M&&(r.track({type:3,doc:C}),k=!0):this.iu(E,C)||(r.track({type:2,doc:C}),k=!0,(l&&this.Xa(C,l)>0||d&&this.Xa(C,d)<0)&&(u=!0)):!E&&C?(r.track({type:0,doc:C}),k=!0):E&&!C&&(r.track({type:1,doc:E}),k=!0,(l||d)&&(u=!0)),k&&(C?(a=a.add(C),o=M?o.add(p):o.delete(p)):(a=a.delete(p),o=o.delete(p)))})),this.query.limit!==null)for(;a.size>this.query.limit;){const p=this.query.limitType==="F"?a.last():a.first();a=a.delete(p.key),o=o.delete(p.key),r.track({type:1,doc:p})}return{eu:a,ru:r,Ds:u,mutatedKeys:o}}iu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const o=this.eu;this.eu=e.eu,this.mutatedKeys=e.mutatedKeys;const a=e.ru.pa();a.sort(((p,v)=>(function(C,V){const M=k=>{switch(k){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return H(20277,{At:k})}};return M(C)-M(V)})(p.type,v.type)||this.Xa(p.doc,v.doc))),this.su(r),s=s!=null&&s;const u=t&&!s?this.ou():[],l=this.Za.size===0&&this.current&&!s?1:0,d=l!==this.Ya;return this.Ya=l,a.length!==0||d?{snapshot:new gn(this.query,e.eu,o,a,e.mutatedKeys,l===0,d,!1,!!r&&r.resumeToken.approximateByteSize()>0),_u:u}:{_u:u}}va(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({eu:this.eu,ru:new uu,mutatedKeys:this.mutatedKeys,Ds:!1},!1)):{_u:[]}}au(e){return!this.Ha.has(e)&&!!this.eu.has(e)&&!this.eu.get(e).hasLocalMutations}su(e){e&&(e.addedDocuments.forEach((t=>this.Ha=this.Ha.add(t))),e.modifiedDocuments.forEach((t=>{})),e.removedDocuments.forEach((t=>this.Ha=this.Ha.delete(t))),this.current=e.current)}ou(){if(!this.current)return[];const e=this.Za;this.Za=J(),this.eu.forEach((r=>{this.au(r.key)&&(this.Za=this.Za.add(r.key))}));const t=[];return e.forEach((r=>{this.Za.has(r)||t.push(new vh(r))})),this.Za.forEach((r=>{e.has(r)||t.push(new yh(r))})),t}uu(e){this.Ha=e.qs,this.Za=J();const t=this.nu(e.documents);return this.applyChanges(t,!0)}cu(){return gn.fromInitialDocuments(this.query,this.eu,this.mutatedKeys,this.Ya===0,this.hasCachedResults)}}const Vo="SyncEngine";class wv{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class Iv{constructor(e){this.key=e,this.lu=!1}}class Av{constructor(e,t,r,s,o,a){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=o,this.maxConcurrentLimboResolutions=a,this.hu={},this.Pu=new Wt((u=>zl(u)),ks),this.Tu=new Map,this.Iu=new Set,this.du=new ie(U.comparator),this.Eu=new Map,this.Au=new Ao,this.Ru={},this.Vu=new Map,this.mu=pn.ur(),this.onlineState="Unknown",this.fu=void 0}get isPrimaryClient(){return this.fu===!0}}async function bv(n,e,t=!0){const r=Ah(n);let s;const o=r.Pu.get(e);return o?(r.sharedClientState.addLocalQueryTarget(o.targetId),s=o.view.cu()):s=await Eh(r,e,t,!0),s}async function Rv(n,e){const t=Ah(n);await Eh(t,e,!0,!1)}async function Eh(n,e,t,r){const s=await Qy(n.localStore,ze(e)),o=s.targetId,a=n.sharedClientState.addLocalQueryTarget(o,t);let u;return r&&(u=await Sv(n,e,o,a==="current",s.resumeToken)),n.isPrimaryClient&&t&&ph(n.remoteStore,s),u}async function Sv(n,e,t,r,s){n.gu=(v,E,C)=>(async function(M,k,q,z){let B=k.view.nu(q);B.Ds&&(B=await nu(M.localStore,k.query,!1).then((({documents:_})=>k.view.nu(_,B))));const Y=z&&z.targetChanges.get(k.targetId),he=z&&z.targetMismatches.get(k.targetId)!=null,P=k.view.applyChanges(B,M.isPrimaryClient,Y,he);return fu(M,k.targetId,P._u),P.snapshot})(n,v,E,C);const o=await nu(n.localStore,e,!0),a=new Tv(e,o.qs),u=a.nu(o.documents),l=gr.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),d=a.applyChanges(u,n.isPrimaryClient,l);fu(n,t,d._u);const p=new wv(e,t,a);return n.Pu.set(e,p),n.Tu.has(t)?n.Tu.get(t).push(e):n.Tu.set(t,[e]),d.snapshot}async function Cv(n,e,t){const r=Q(n),s=r.Pu.get(e),o=r.Tu.get(s.targetId);if(o.length>1)return r.Tu.set(s.targetId,o.filter((a=>!ks(a,e)))),void r.Pu.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await Wi(r.localStore,s.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(s.targetId),t&&Co(r.remoteStore,s.targetId),Qi(r,s.targetId)})).catch(bs)):(Qi(r,s.targetId),await Wi(r.localStore,s.targetId,!0))}async function Pv(n,e){const t=Q(n),r=t.Pu.get(e),s=t.Tu.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),Co(t.remoteStore,r.targetId))}async function Th(n,e){const t=Q(n);try{const r=await Gy(t.localStore,e);e.targetChanges.forEach(((s,o)=>{const a=t.Eu.get(o);a&&(ne(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?a.lu=!0:s.modifiedDocuments.size>0?ne(a.lu,14607):s.removedDocuments.size>0&&(ne(a.lu,42227),a.lu=!1))})),await Ih(t,r,e)}catch(r){await bs(r)}}function du(n,e,t){const r=Q(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.Pu.forEach(((o,a)=>{const u=a.view.va(e);u.snapshot&&s.push(u.snapshot)})),(function(a,u){const l=Q(a);l.onlineState=u;let d=!1;l.queries.forEach(((p,v)=>{for(const E of v.wa)E.va(u)&&(d=!0)})),d&&No(l)})(r.eventManager,e),s.length&&r.hu.J_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function kv(n,e,t){const r=Q(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Eu.get(e),o=s&&s.key;if(o){let a=new ie(U.comparator);a=a.insert(o,Ie.newNoDocument(o,$.min()));const u=J().add(o),l=new Vs($.min(),new Map,new ie(W),a,u);await Th(r,l),r.du=r.du.remove(o),r.Eu.delete(e),Mo(r)}else await Wi(r.localStore,e,!1).then((()=>Qi(r,e,t))).catch(bs)}function Qi(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.Tu.get(e))n.Pu.delete(r),t&&n.hu.pu(r,t);n.Tu.delete(e),n.isPrimaryClient&&n.Au.zr(e).forEach((r=>{n.Au.containsKey(r)||wh(n,r)}))}function wh(n,e){n.Iu.delete(e.path.canonicalString());const t=n.du.get(e);t!==null&&(Co(n.remoteStore,t),n.du=n.du.remove(e),n.Eu.delete(t),Mo(n))}function fu(n,e,t){for(const r of t)r instanceof yh?(n.Au.addReference(r.key,e),Ov(n,r)):r instanceof vh?(L(Vo,"Document no longer in limbo: "+r.key),n.Au.removeReference(r.key,e),n.Au.containsKey(r.key)||wh(n,r.key)):H(19791,{yu:r})}function Ov(n,e){const t=e.key,r=t.path.canonicalString();n.du.get(t)||n.Iu.has(r)||(L(Vo,"New document in limbo: "+t),n.Iu.add(r),Mo(n))}function Mo(n){for(;n.Iu.size>0&&n.du.size<n.maxConcurrentLimboResolutions;){const e=n.Iu.values().next().value;n.Iu.delete(e);const t=new U(te.fromString(e)),r=n.mu.next();n.Eu.set(r,new Iv(t)),n.du=n.du.insert(t,r),ph(n.remoteStore,new gt(ze(Eo(t.path)),r,"TargetPurposeLimboResolution",Rs.ue))}}async function Ih(n,e,t){const r=Q(n),s=[],o=[],a=[];r.Pu.isEmpty()||(r.Pu.forEach(((u,l)=>{a.push(r.gu(l,e,t).then((d=>{var p;if((d||t)&&r.isPrimaryClient){const v=d?!d.fromCache:(p=t?.targetChanges.get(l.targetId))===null||p===void 0?void 0:p.current;r.sharedClientState.updateQueryState(l.targetId,v?"current":"not-current")}if(d){s.push(d);const v=Ro.Es(l.targetId,d);o.push(v)}})))})),await Promise.all(a),r.hu.J_(s),await(async function(l,d){const p=Q(l);try{await p.persistence.runTransaction("notifyLocalViewChanges","readwrite",(v=>S.forEach(d,(E=>S.forEach(E.Is,(C=>p.persistence.referenceDelegate.addReference(v,E.targetId,C))).next((()=>S.forEach(E.ds,(C=>p.persistence.referenceDelegate.removeReference(v,E.targetId,C)))))))))}catch(v){if(!Tn(v))throw v;L(So,"Failed to update sequence numbers: "+v)}for(const v of d){const E=v.targetId;if(!v.fromCache){const C=p.Fs.get(E),V=C.snapshotVersion,M=C.withLastLimboFreeSnapshotVersion(V);p.Fs=p.Fs.insert(E,M)}}})(r.localStore,o))}async function Dv(n,e){const t=Q(n);if(!t.currentUser.isEqual(e)){L(Vo,"User change. New user:",e.toKey());const r=await lh(t.localStore,e);t.currentUser=e,(function(o,a){o.Vu.forEach((u=>{u.forEach((l=>{l.reject(new x(N.CANCELLED,a))}))})),o.Vu.clear()})(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Ih(t,r.Bs)}}function Nv(n,e){const t=Q(n),r=t.Eu.get(e);if(r&&r.lu)return J().add(r.key);{let s=J();const o=t.Tu.get(e);if(!o)return s;for(const a of o){const u=t.Pu.get(a);s=s.unionWith(u.view.tu)}return s}}function Ah(n){const e=Q(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=Th.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Nv.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=kv.bind(null,e),e.hu.J_=yv.bind(null,e.eventManager),e.hu.pu=vv.bind(null,e.eventManager),e}class _s{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=dh(e.databaseInfo.databaseId),this.sharedClientState=this.bu(e),this.persistence=this.Du(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Cu(e,this.localStore),this.indexBackfillerScheduler=this.Fu(e,this.localStore)}Cu(e,t){return null}Fu(e,t){return null}vu(e){return Wy(this.persistence,new qy,e.initialUser,this.serializer)}Du(e){return new uh(bo.Vi,this.serializer)}bu(e){return new Xy}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}_s.provider={build:()=>new _s};class Vv extends _s{constructor(e){super(),this.cacheSizeBytes=e}Cu(e,t){ne(this.persistence.referenceDelegate instanceof gs,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new Cy(r,e.asyncQueue,t)}Du(e){const t=this.cacheSizeBytes!==void 0?Pe.withCacheSize(this.cacheSizeBytes):Pe.DEFAULT;return new uh((r=>gs.Vi(r,t)),this.serializer)}}class Ji{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>du(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=Dv.bind(null,this.syncEngine),await fv(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new mv})()}createDatastore(e){const t=dh(e.databaseInfo.databaseId),r=(function(o){return new nv(o)})(e.databaseInfo);return(function(o,a,u,l){return new ov(o,a,u,l)})(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return(function(r,s,o,a,u){return new cv(r,s,o,a,u)})(this.localStore,this.datastore,e.asyncQueue,(t=>du(this.syncEngine,t,0)),(function(){return iu.C()?new iu:new Yy})())}createSyncEngine(e,t){return(function(s,o,a,u,l,d,p){const v=new Av(s,o,a,u,l,d);return p&&(v.fu=!0),v})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await(async function(s){const o=Q(s);L(mn,"RemoteStore shutting down."),o.Ia.add(5),await _r(o),o.Ea.shutdown(),o.Aa.set("Unknown")})(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}}Ji.provider={build:()=>new Ji};/**
|
|
2930
|
+
*/class yh{constructor(e){this.key=e}}class vh{constructor(e){this.key=e}}class Tv{constructor(e,t){this.query=e,this.Ha=t,this.Ya=null,this.hasCachedResults=!1,this.current=!1,this.Za=J(),this.mutatedKeys=J(),this.Xa=Hl(e),this.eu=new cn(this.Xa)}get tu(){return this.Ha}nu(e,t){const r=t?t.ru:new uu,s=t?t.eu:this.eu;let o=t?t.mutatedKeys:this.mutatedKeys,a=s,u=!1;const l=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,d=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal(((p,v)=>{const E=s.get(p),C=Os(this.query,v)?v:null,V=!!E&&this.mutatedKeys.has(E.key),M=!!C&&(C.hasLocalMutations||this.mutatedKeys.has(C.key)&&C.hasCommittedMutations);let k=!1;E&&C?E.data.isEqual(C.data)?V!==M&&(r.track({type:3,doc:C}),k=!0):this.iu(E,C)||(r.track({type:2,doc:C}),k=!0,(l&&this.Xa(C,l)>0||d&&this.Xa(C,d)<0)&&(u=!0)):!E&&C?(r.track({type:0,doc:C}),k=!0):E&&!C&&(r.track({type:1,doc:E}),k=!0,(l||d)&&(u=!0)),k&&(C?(a=a.add(C),o=M?o.add(p):o.delete(p)):(a=a.delete(p),o=o.delete(p)))})),this.query.limit!==null)for(;a.size>this.query.limit;){const p=this.query.limitType==="F"?a.last():a.first();a=a.delete(p.key),o=o.delete(p.key),r.track({type:1,doc:p})}return{eu:a,ru:r,Ds:u,mutatedKeys:o}}iu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const o=this.eu;this.eu=e.eu,this.mutatedKeys=e.mutatedKeys;const a=e.ru.pa();a.sort(((p,v)=>(function(C,V){const M=k=>{switch(k){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return H(20277,{At:k})}};return M(C)-M(V)})(p.type,v.type)||this.Xa(p.doc,v.doc))),this.su(r),s=s!=null&&s;const u=t&&!s?this.ou():[],l=this.Za.size===0&&this.current&&!s?1:0,d=l!==this.Ya;return this.Ya=l,a.length!==0||d?{snapshot:new gn(this.query,e.eu,o,a,e.mutatedKeys,l===0,d,!1,!!r&&r.resumeToken.approximateByteSize()>0),_u:u}:{_u:u}}va(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({eu:this.eu,ru:new uu,mutatedKeys:this.mutatedKeys,Ds:!1},!1)):{_u:[]}}au(e){return!this.Ha.has(e)&&!!this.eu.has(e)&&!this.eu.get(e).hasLocalMutations}su(e){e&&(e.addedDocuments.forEach((t=>this.Ha=this.Ha.add(t))),e.modifiedDocuments.forEach((t=>{})),e.removedDocuments.forEach((t=>this.Ha=this.Ha.delete(t))),this.current=e.current)}ou(){if(!this.current)return[];const e=this.Za;this.Za=J(),this.eu.forEach((r=>{this.au(r.key)&&(this.Za=this.Za.add(r.key))}));const t=[];return e.forEach((r=>{this.Za.has(r)||t.push(new vh(r))})),this.Za.forEach((r=>{e.has(r)||t.push(new yh(r))})),t}uu(e){this.Ha=e.qs,this.Za=J();const t=this.nu(e.documents);return this.applyChanges(t,!0)}cu(){return gn.fromInitialDocuments(this.query,this.eu,this.mutatedKeys,this.Ya===0,this.hasCachedResults)}}const Vo="SyncEngine";class wv{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class Iv{constructor(e){this.key=e,this.lu=!1}}class Av{constructor(e,t,r,s,o,a){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=o,this.maxConcurrentLimboResolutions=a,this.hu={},this.Pu=new Wt((u=>zl(u)),ks),this.Tu=new Map,this.Iu=new Set,this.du=new ie(F.comparator),this.Eu=new Map,this.Au=new Ao,this.Ru={},this.Vu=new Map,this.mu=pn.ur(),this.onlineState="Unknown",this.fu=void 0}get isPrimaryClient(){return this.fu===!0}}async function bv(n,e,t=!0){const r=Ah(n);let s;const o=r.Pu.get(e);return o?(r.sharedClientState.addLocalQueryTarget(o.targetId),s=o.view.cu()):s=await Eh(r,e,t,!0),s}async function Rv(n,e){const t=Ah(n);await Eh(t,e,!0,!1)}async function Eh(n,e,t,r){const s=await Qy(n.localStore,ze(e)),o=s.targetId,a=n.sharedClientState.addLocalQueryTarget(o,t);let u;return r&&(u=await Sv(n,e,o,a==="current",s.resumeToken)),n.isPrimaryClient&&t&&ph(n.remoteStore,s),u}async function Sv(n,e,t,r,s){n.gu=(v,E,C)=>(async function(M,k,q,z){let B=k.view.nu(q);B.Ds&&(B=await nu(M.localStore,k.query,!1).then((({documents:_})=>k.view.nu(_,B))));const Y=z&&z.targetChanges.get(k.targetId),he=z&&z.targetMismatches.get(k.targetId)!=null,P=k.view.applyChanges(B,M.isPrimaryClient,Y,he);return fu(M,k.targetId,P._u),P.snapshot})(n,v,E,C);const o=await nu(n.localStore,e,!0),a=new Tv(e,o.qs),u=a.nu(o.documents),l=gr.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),d=a.applyChanges(u,n.isPrimaryClient,l);fu(n,t,d._u);const p=new wv(e,t,a);return n.Pu.set(e,p),n.Tu.has(t)?n.Tu.get(t).push(e):n.Tu.set(t,[e]),d.snapshot}async function Cv(n,e,t){const r=Q(n),s=r.Pu.get(e),o=r.Tu.get(s.targetId);if(o.length>1)return r.Tu.set(s.targetId,o.filter((a=>!ks(a,e)))),void r.Pu.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await Wi(r.localStore,s.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(s.targetId),t&&Co(r.remoteStore,s.targetId),Qi(r,s.targetId)})).catch(bs)):(Qi(r,s.targetId),await Wi(r.localStore,s.targetId,!0))}async function Pv(n,e){const t=Q(n),r=t.Pu.get(e),s=t.Tu.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),Co(t.remoteStore,r.targetId))}async function Th(n,e){const t=Q(n);try{const r=await Gy(t.localStore,e);e.targetChanges.forEach(((s,o)=>{const a=t.Eu.get(o);a&&(ne(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?a.lu=!0:s.modifiedDocuments.size>0?ne(a.lu,14607):s.removedDocuments.size>0&&(ne(a.lu,42227),a.lu=!1))})),await Ih(t,r,e)}catch(r){await bs(r)}}function du(n,e,t){const r=Q(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.Pu.forEach(((o,a)=>{const u=a.view.va(e);u.snapshot&&s.push(u.snapshot)})),(function(a,u){const l=Q(a);l.onlineState=u;let d=!1;l.queries.forEach(((p,v)=>{for(const E of v.wa)E.va(u)&&(d=!0)})),d&&No(l)})(r.eventManager,e),s.length&&r.hu.J_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function kv(n,e,t){const r=Q(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Eu.get(e),o=s&&s.key;if(o){let a=new ie(F.comparator);a=a.insert(o,Ie.newNoDocument(o,$.min()));const u=J().add(o),l=new Vs($.min(),new Map,new ie(W),a,u);await Th(r,l),r.du=r.du.remove(o),r.Eu.delete(e),Mo(r)}else await Wi(r.localStore,e,!1).then((()=>Qi(r,e,t))).catch(bs)}function Qi(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.Tu.get(e))n.Pu.delete(r),t&&n.hu.pu(r,t);n.Tu.delete(e),n.isPrimaryClient&&n.Au.zr(e).forEach((r=>{n.Au.containsKey(r)||wh(n,r)}))}function wh(n,e){n.Iu.delete(e.path.canonicalString());const t=n.du.get(e);t!==null&&(Co(n.remoteStore,t),n.du=n.du.remove(e),n.Eu.delete(t),Mo(n))}function fu(n,e,t){for(const r of t)r instanceof yh?(n.Au.addReference(r.key,e),Ov(n,r)):r instanceof vh?(x(Vo,"Document no longer in limbo: "+r.key),n.Au.removeReference(r.key,e),n.Au.containsKey(r.key)||wh(n,r.key)):H(19791,{yu:r})}function Ov(n,e){const t=e.key,r=t.path.canonicalString();n.du.get(t)||n.Iu.has(r)||(x(Vo,"New document in limbo: "+t),n.Iu.add(r),Mo(n))}function Mo(n){for(;n.Iu.size>0&&n.du.size<n.maxConcurrentLimboResolutions;){const e=n.Iu.values().next().value;n.Iu.delete(e);const t=new F(te.fromString(e)),r=n.mu.next();n.Eu.set(r,new Iv(t)),n.du=n.du.insert(t,r),ph(n.remoteStore,new gt(ze(Eo(t.path)),r,"TargetPurposeLimboResolution",Rs.ue))}}async function Ih(n,e,t){const r=Q(n),s=[],o=[],a=[];r.Pu.isEmpty()||(r.Pu.forEach(((u,l)=>{a.push(r.gu(l,e,t).then((d=>{var p;if((d||t)&&r.isPrimaryClient){const v=d?!d.fromCache:(p=t?.targetChanges.get(l.targetId))===null||p===void 0?void 0:p.current;r.sharedClientState.updateQueryState(l.targetId,v?"current":"not-current")}if(d){s.push(d);const v=Ro.Es(l.targetId,d);o.push(v)}})))})),await Promise.all(a),r.hu.J_(s),await(async function(l,d){const p=Q(l);try{await p.persistence.runTransaction("notifyLocalViewChanges","readwrite",(v=>S.forEach(d,(E=>S.forEach(E.Is,(C=>p.persistence.referenceDelegate.addReference(v,E.targetId,C))).next((()=>S.forEach(E.ds,(C=>p.persistence.referenceDelegate.removeReference(v,E.targetId,C)))))))))}catch(v){if(!Tn(v))throw v;x(So,"Failed to update sequence numbers: "+v)}for(const v of d){const E=v.targetId;if(!v.fromCache){const C=p.Fs.get(E),V=C.snapshotVersion,M=C.withLastLimboFreeSnapshotVersion(V);p.Fs=p.Fs.insert(E,M)}}})(r.localStore,o))}async function Dv(n,e){const t=Q(n);if(!t.currentUser.isEqual(e)){x(Vo,"User change. New user:",e.toKey());const r=await lh(t.localStore,e);t.currentUser=e,(function(o,a){o.Vu.forEach((u=>{u.forEach((l=>{l.reject(new L(N.CANCELLED,a))}))})),o.Vu.clear()})(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Ih(t,r.Bs)}}function Nv(n,e){const t=Q(n),r=t.Eu.get(e);if(r&&r.lu)return J().add(r.key);{let s=J();const o=t.Tu.get(e);if(!o)return s;for(const a of o){const u=t.Pu.get(a);s=s.unionWith(u.view.tu)}return s}}function Ah(n){const e=Q(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=Th.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Nv.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=kv.bind(null,e),e.hu.J_=yv.bind(null,e.eventManager),e.hu.pu=vv.bind(null,e.eventManager),e}class _s{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=dh(e.databaseInfo.databaseId),this.sharedClientState=this.bu(e),this.persistence=this.Du(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Cu(e,this.localStore),this.indexBackfillerScheduler=this.Fu(e,this.localStore)}Cu(e,t){return null}Fu(e,t){return null}vu(e){return Wy(this.persistence,new qy,e.initialUser,this.serializer)}Du(e){return new uh(bo.Vi,this.serializer)}bu(e){return new Xy}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}_s.provider={build:()=>new _s};class Vv extends _s{constructor(e){super(),this.cacheSizeBytes=e}Cu(e,t){ne(this.persistence.referenceDelegate instanceof gs,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new Cy(r,e.asyncQueue,t)}Du(e){const t=this.cacheSizeBytes!==void 0?Pe.withCacheSize(this.cacheSizeBytes):Pe.DEFAULT;return new uh((r=>gs.Vi(r,t)),this.serializer)}}class Ji{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>du(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=Dv.bind(null,this.syncEngine),await fv(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new mv})()}createDatastore(e){const t=dh(e.databaseInfo.databaseId),r=(function(o){return new nv(o)})(e.databaseInfo);return(function(o,a,u,l){return new ov(o,a,u,l)})(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return(function(r,s,o,a,u){return new cv(r,s,o,a,u)})(this.localStore,this.datastore,e.asyncQueue,(t=>du(this.syncEngine,t,0)),(function(){return iu.C()?new iu:new Yy})())}createSyncEngine(e,t){return(function(s,o,a,u,l,d,p){const v=new Av(s,o,a,u,l,d);return p&&(v.fu=!0),v})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await(async function(s){const o=Q(s);x(mn,"RemoteStore shutting down."),o.Ia.add(5),await _r(o),o.Ea.shutdown(),o.Aa.set("Unknown")})(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}}Ji.provider={build:()=>new Ji};/**
|
|
2931
2931
|
* @license
|
|
2932
2932
|
* Copyright 2020 Google LLC
|
|
2933
2933
|
*
|
|
@@ -2972,7 +2972,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
2972
2972
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2973
2973
|
* See the License for the specific language governing permissions and
|
|
2974
2974
|
* limitations under the License.
|
|
2975
|
-
*/const Pt="FirestoreClient";class
|
|
2975
|
+
*/const Pt="FirestoreClient";class xv{constructor(e,t,r,s,o){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this.databaseInfo=s,this.user=we.UNAUTHENTICATED,this.clientId=mo.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=o,this.authCredentials.start(r,(async a=>{x(Pt,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a})),this.appCheckCredentials.start(r,(a=>(x(Pt,"Received new app check token=",a),this.appCheckCredentialListener(a,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new on;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const r=_h(t,"Failed to shutdown persistence");e.reject(r)}})),e.promise}}async function Ti(n,e){n.asyncQueue.verifyOperationInProgress(),x(Pt,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener((async s=>{r.isEqual(s)||(await lh(e.localStore,s),r=s)})),e.persistence.setDatabaseDeletedListener((()=>{It("Terminating Firestore due to IndexedDb database deletion"),n.terminate().then((()=>{x("Terminating Firestore due to IndexedDb database deletion completed successfully")})).catch((s=>{It("Terminating Firestore due to IndexedDb database deletion failed",s)}))})),n._offlineComponents=e}async function pu(n,e){n.asyncQueue.verifyOperationInProgress();const t=await Lv(n);x(Pt,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener((r=>cu(e.remoteStore,r))),n.setAppCheckTokenChangeListener(((r,s)=>cu(e.remoteStore,s))),n._onlineComponents=e}async function Lv(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){x(Pt,"Using user provided OfflineComponentProvider");try{await Ti(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!(function(s){return s.name==="FirebaseError"?s.code===N.FAILED_PRECONDITION||s.code===N.UNIMPLEMENTED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11})(t))throw t;It("Error using user provided cache. Falling back to memory cache: "+t),await Ti(n,new _s)}}else x(Pt,"Using default OfflineComponentProvider"),await Ti(n,new Vv(void 0));return n._offlineComponents}async function Uv(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(x(Pt,"Using user provided OnlineComponentProvider"),await pu(n,n._uninitializedComponentsProvider._online)):(x(Pt,"Using default OnlineComponentProvider"),await pu(n,new Ji))),n._onlineComponents}async function mu(n){const e=await Uv(n),t=e.eventManager;return t.onListen=bv.bind(null,e.syncEngine),t.onUnlisten=Cv.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=Rv.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=Pv.bind(null,e.syncEngine),t}/**
|
|
2976
2976
|
* @license
|
|
2977
2977
|
* Copyright 2023 Google LLC
|
|
2978
2978
|
*
|
|
@@ -3017,7 +3017,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
3017
3017
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3018
3018
|
* See the License for the specific language governing permissions and
|
|
3019
3019
|
* limitations under the License.
|
|
3020
|
-
*/const Rh="firestore.googleapis.com",_u=!0;class yu{constructor(e){var t,r;if(e.host===void 0){if(e.ssl!==void 0)throw new
|
|
3020
|
+
*/const Rh="firestore.googleapis.com",_u=!0;class yu{constructor(e){var t,r;if(e.host===void 0){if(e.ssl!==void 0)throw new L(N.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=Rh,this.ssl=_u}else this.host=e.host,this.ssl=(t=e.ssl)!==null&&t!==void 0?t:_u;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=ch;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<Ry)throw new L(N.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}a_("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=bh((r=e.experimentalLongPollingOptions)!==null&&r!==void 0?r:{}),(function(o){if(o.timeoutSeconds!==void 0){if(isNaN(o.timeoutSeconds))throw new L(N.INVALID_ARGUMENT,`invalid long polling timeout: ${o.timeoutSeconds} (must not be NaN)`);if(o.timeoutSeconds<5)throw new L(N.INVALID_ARGUMENT,`invalid long polling timeout: ${o.timeoutSeconds} (minimum allowed value is 5)`);if(o.timeoutSeconds>30)throw new L(N.INVALID_ARGUMENT,`invalid long polling timeout: ${o.timeoutSeconds} (maximum allowed value is 30)`)}})(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(function(r,s){return r.timeoutSeconds===s.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class xo{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new yu({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new L(N.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new L(N.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new yu(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(r){if(!r)return new Xg;switch(r.type){case"firstParty":return new t_(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new L(N.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(t){const r=gu.get(t);r&&(x("ComponentProvider","Removing Datastore"),gu.delete(t),r.terminate())})(this),Promise.resolve()}}function Fv(n,e,t,r={}){var s;n=Xr(n,xo);const o=_n(e),a=n._getSettings(),u=Object.assign(Object.assign({},a),{emulatorOptions:n._getEmulatorOptions()}),l=`${e}:${t}`;o&&(Vu(`https://${l}`),Mu("Firestore",!0)),a.host!==Rh&&a.host!==l&&It("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const d=Object.assign(Object.assign({},a),{host:l,ssl:o,emulatorOptions:r});if(!Bt(d,u)&&(n._setSettings(d),r.mockUserToken)){let p,v;if(typeof r.mockUserToken=="string")p=r.mockUserToken,v=we.MOCK_USER;else{p=ef(r.mockUserToken,(s=n._app)===null||s===void 0?void 0:s.options.projectId);const E=r.mockUserToken.sub||r.mockUserToken.user_id;if(!E)throw new L(N.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");v=new we(E)}n._authCredentials=new Yg(new kl(p,v))}}/**
|
|
3021
3021
|
* @license
|
|
3022
3022
|
* Copyright 2020 Google LLC
|
|
3023
3023
|
*
|
|
@@ -3032,7 +3032,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
3032
3032
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3033
3033
|
* See the License for the specific language governing permissions and
|
|
3034
3034
|
* limitations under the License.
|
|
3035
|
-
*/class
|
|
3035
|
+
*/class xs{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new xs(this.firestore,e,this._query)}}class Ce{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new ar(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Ce(this.firestore,e,this._key)}toJSON(){return{type:Ce._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(pr(t,Ce._jsonSchema))return new Ce(e,r||null,new F(te.fromString(t.referencePath)))}}Ce._jsonSchemaVersion="firestore/documentReference/1.0",Ce._jsonSchema={type:ce("string",Ce._jsonSchemaVersion),referencePath:ce("string")};class ar extends xs{constructor(e,t,r){super(e,t,Eo(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new Ce(this.firestore,null,new F(e))}withConverter(e){return new ar(this.firestore,e,this._path)}}function jv(n,e,...t){if(n=Le(n),arguments.length===1&&(e=mo.newId()),o_("doc","path",e),n instanceof xo){const r=te.fromString(e,...t);return kc(r),new Ce(n,null,new F(r))}{if(!(n instanceof Ce||n instanceof ar))throw new L(N.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(te.fromString(e,...t));return kc(r),new Ce(n.firestore,n instanceof ar?n.converter:null,new F(r))}}/**
|
|
3036
3036
|
* @license
|
|
3037
3037
|
* Copyright 2020 Google LLC
|
|
3038
3038
|
*
|
|
@@ -3047,7 +3047,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
3047
3047
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3048
3048
|
* See the License for the specific language governing permissions and
|
|
3049
3049
|
* limitations under the License.
|
|
3050
|
-
*/const vu="AsyncQueue";class Eu{constructor(e=Promise.resolve()){this.Zu=[],this.Xu=!1,this.ec=[],this.tc=null,this.nc=!1,this.rc=!1,this.sc=[],this.F_=new fh(this,"async_queue_retry"),this.oc=()=>{const r=Ei();r&&
|
|
3050
|
+
*/const vu="AsyncQueue";class Eu{constructor(e=Promise.resolve()){this.Zu=[],this.Xu=!1,this.ec=[],this.tc=null,this.nc=!1,this.rc=!1,this.sc=[],this.F_=new fh(this,"async_queue_retry"),this.oc=()=>{const r=Ei();r&&x(vu,"Visibility state changed to "+r.visibilityState),this.F_.y_()},this._c=e;const t=Ei();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.oc)}get isShuttingDown(){return this.Xu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.ac(),this.uc(e)}enterRestrictedMode(e){if(!this.Xu){this.Xu=!0,this.rc=e||!1;const t=Ei();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.oc)}}enqueue(e){if(this.ac(),this.Xu)return new Promise((()=>{}));const t=new on;return this.uc((()=>this.Xu&&this.rc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Zu.push(e),this.cc())))}async cc(){if(this.Zu.length!==0){try{await this.Zu[0](),this.Zu.shift(),this.F_.reset()}catch(e){if(!Tn(e))throw e;x(vu,"Operation failed with retryable error: "+e)}this.Zu.length>0&&this.F_.g_((()=>this.cc()))}}uc(e){const t=this._c.then((()=>(this.nc=!0,e().catch((r=>{throw this.tc=r,this.nc=!1,nt("INTERNAL UNHANDLED ERROR: ",Tu(r)),r})).then((r=>(this.nc=!1,r))))));return this._c=t,t}enqueueAfterDelay(e,t,r){this.ac(),this.sc.indexOf(e)>-1&&(t=0);const s=Do.createAndSchedule(this,e,t,r,(o=>this.lc(o)));return this.ec.push(s),s}ac(){this.tc&&H(47125,{hc:Tu(this.tc)})}verifyOperationInProgress(){}async Pc(){let e;do e=this._c,await e;while(e!==this._c)}Tc(e){for(const t of this.ec)if(t.timerId===e)return!0;return!1}Ic(e){return this.Pc().then((()=>{this.ec.sort(((t,r)=>t.targetTimeMs-r.targetTimeMs));for(const t of this.ec)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Pc()}))}dc(e){this.sc.push(e)}lc(e){const t=this.ec.indexOf(e);this.ec.splice(t,1)}}function Tu(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+`
|
|
3051
3051
|
`+n.stack),e}/**
|
|
3052
3052
|
* @license
|
|
3053
3053
|
* Copyright 2017 Google LLC
|
|
@@ -3063,7 +3063,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
3063
3063
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3064
3064
|
* See the License for the specific language governing permissions and
|
|
3065
3065
|
* limitations under the License.
|
|
3066
|
-
*/function wu(n){return(function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const o of r)if(o in s&&typeof s[o]=="function")return!0;return!1})(n,["next","error","complete"])}class Xi extends
|
|
3066
|
+
*/function wu(n){return(function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const o of r)if(o in s&&typeof s[o]=="function")return!0;return!1})(n,["next","error","complete"])}class Xi extends xo{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new Eu,this._persistenceKey=s?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new Eu(e),this._firestoreClient=void 0,await e}}}function Bv(n,e){const t=typeof n=="object"?n:Fu(),r=typeof n=="string"?n:hs,s=to(t,"firestore").getImmediate({identifier:r});if(!s._initialized){const o=Yd("firestore");o&&Fv(s,...o)}return s}function $v(n){if(n._terminated)throw new L(N.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||qv(n),n._firestoreClient}function qv(n){var e,t,r;const s=n._freezeSettings(),o=(function(u,l,d,p){return new T_(u,l,d,p.host,p.ssl,p.experimentalForceLongPolling,p.experimentalAutoDetectLongPolling,bh(p.experimentalLongPollingOptions),p.useFetchStreams,p.isUsingEmulator)})(n._databaseId,((e=n._app)===null||e===void 0?void 0:e.options.appId)||"",n._persistenceKey,s);n._componentsProvider||!((t=s.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((r=s.localCache)===null||r===void 0)&&r._onlineComponentProvider)&&(n._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),n._firestoreClient=new xv(n._authCredentials,n._appCheckCredentials,n._queue,o,n._componentsProvider&&(function(u){const l=u?._online.build();return{_offline:u?._offline.build(l),_online:l}})(n._componentsProvider))}/**
|
|
3067
3067
|
* @license
|
|
3068
3068
|
* Copyright 2020 Google LLC
|
|
3069
3069
|
*
|
|
@@ -3078,7 +3078,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
3078
3078
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3079
3079
|
* See the License for the specific language governing permissions and
|
|
3080
3080
|
* limitations under the License.
|
|
3081
|
-
*/class Be{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Be(ge.fromBase64String(e))}catch(t){throw new
|
|
3081
|
+
*/class Be{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Be(ge.fromBase64String(e))}catch(t){throw new L(N.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new Be(ge.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:Be._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(pr(e,Be._jsonSchema))return Be.fromBase64String(e.bytes)}}Be._jsonSchemaVersion="firestore/bytes/1.0",Be._jsonSchema={type:ce("string",Be._jsonSchemaVersion),bytes:ce("string")};/**
|
|
3082
3082
|
* @license
|
|
3083
3083
|
* Copyright 2020 Google LLC
|
|
3084
3084
|
*
|
|
@@ -3093,7 +3093,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
3093
3093
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3094
3094
|
* See the License for the specific language governing permissions and
|
|
3095
3095
|
* limitations under the License.
|
|
3096
|
-
*/class Sh{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new
|
|
3096
|
+
*/class Sh{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new L(N.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Se(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/**
|
|
3097
3097
|
* @license
|
|
3098
3098
|
* Copyright 2017 Google LLC
|
|
3099
3099
|
*
|
|
@@ -3108,7 +3108,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
3108
3108
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3109
3109
|
* See the License for the specific language governing permissions and
|
|
3110
3110
|
* limitations under the License.
|
|
3111
|
-
*/class Tt{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new
|
|
3111
|
+
*/class Tt{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new L(N.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new L(N.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return W(this._lat,e._lat)||W(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:Tt._jsonSchemaVersion}}static fromJSON(e){if(pr(e,Tt._jsonSchema))return new Tt(e.latitude,e.longitude)}}Tt._jsonSchemaVersion="firestore/geoPoint/1.0",Tt._jsonSchema={type:ce("string",Tt._jsonSchemaVersion),latitude:ce("number"),longitude:ce("number")};/**
|
|
3112
3112
|
* @license
|
|
3113
3113
|
* Copyright 2024 Google LLC
|
|
3114
3114
|
*
|
|
@@ -3123,7 +3123,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
3123
3123
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3124
3124
|
* See the License for the specific language governing permissions and
|
|
3125
3125
|
* limitations under the License.
|
|
3126
|
-
*/class wt{constructor(e){this._values=(e||[]).map((t=>t))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(r,s){if(r.length!==s.length)return!1;for(let o=0;o<r.length;++o)if(r[o]!==s[o])return!1;return!0})(this._values,e._values)}toJSON(){return{type:wt._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(pr(e,wt._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((t=>typeof t=="number")))return new wt(e.vectorValues);throw new
|
|
3126
|
+
*/class wt{constructor(e){this._values=(e||[]).map((t=>t))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(r,s){if(r.length!==s.length)return!1;for(let o=0;o<r.length;++o)if(r[o]!==s[o])return!1;return!0})(this._values,e._values)}toJSON(){return{type:wt._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(pr(e,wt._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((t=>typeof t=="number")))return new wt(e.vectorValues);throw new L(N.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}wt._jsonSchemaVersion="firestore/vectorValue/1.0",wt._jsonSchema={type:ce("string",wt._jsonSchemaVersion),vectorValues:ce("object")};const zv=new RegExp("[~\\*/\\[\\]]");function Hv(n,e,t){if(e.search(zv)>=0)throw Iu(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n);try{return new Sh(...e.split("."))._internalPath}catch{throw Iu(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n)}}function Iu(n,e,t,r,s){let o=`Function ${e}() called with invalid data`;o+=". ";let a="";return new L(N.INVALID_ARGUMENT,o+n+a)}/**
|
|
3127
3127
|
* @license
|
|
3128
3128
|
* Copyright 2020 Google LLC
|
|
3129
3129
|
*
|
|
@@ -3153,6 +3153,6 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
3153
3153
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3154
3154
|
* See the License for the specific language governing permissions and
|
|
3155
3155
|
* limitations under the License.
|
|
3156
|
-
*/function Gv(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new x(N.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Kv{convertValue(e,t="none"){switch(St(e)){case 0:return null;case 1:return e.booleanValue;case 2:return se(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Rt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw H(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return mr(e,((s,o)=>{r[s]=this.convertValue(o,t)})),r}convertVectorValue(e){var t,r,s;const o=(s=(r=(t=e.fields)===null||t===void 0?void 0:t[Li].arrayValue)===null||r===void 0?void 0:r.values)===null||s===void 0?void 0:s.map((a=>se(a.doubleValue)));return new wt(o)}convertGeoPoint(e){return new Tt(se(e.latitude),se(e.longitude))}convertArray(e,t){return(e.values||[]).map((r=>this.convertValue(r,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const r=Cs(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(sr(e));default:return null}}convertTimestamp(e){const t=bt(e);return new ae(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=te.fromString(e);ne(ah(r),9688,{name:e});const s=new ir(r.get(1),r.get(3)),o=new U(r.popFirst(5));return s.isEqual(t)||nt(`Document ${o} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),o}}class Hn{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class jt extends Ch{constructor(e,t,r,s,o,a){super(e,t,r,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=o}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new ts(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const r=this._document.data.field(Ph("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new x(N.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=jt._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}jt._jsonSchemaVersion="firestore/documentSnapshot/1.0",jt._jsonSchema={type:ce("string",jt._jsonSchemaVersion),bundleSource:ce("string","DocumentSnapshot"),bundleName:ce("string"),bundle:ce("string")};class ts extends jt{data(e={}){return super.data(e)}}class un{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new Hn(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((r=>{e.call(t,new ts(this._firestore,this._userDataWriter,r.key,r,new Hn(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new x(N.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=(function(s,o){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map((u=>{const l=new ts(s._firestore,s._userDataWriter,u.doc.key,u.doc,new Hn(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);return u.doc,{type:"added",doc:l,oldIndex:-1,newIndex:a++}}))}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter((u=>o||u.type!==3)).map((u=>{const l=new ts(s._firestore,s._userDataWriter,u.doc.key,u.doc,new Hn(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);let d=-1,p=-1;return u.type!==0&&(d=a.indexOf(u.doc.key),a=a.delete(u.doc.key)),u.type!==1&&(a=a.add(u.doc),p=a.indexOf(u.doc.key)),{type:Qv(u.type),doc:l,oldIndex:d,newIndex:p}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new x(N.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=un._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=mo.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach((o=>{o._document!==null&&(t.push(o._document),r.push(this._userDataWriter.convertObjectMap(o._document.data.value.mapValue.fields,"previous")),s.push(o.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function Qv(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return H(61501,{type:n})}}un._jsonSchemaVersion="firestore/querySnapshot/1.0",un._jsonSchema={type:ce("string",un._jsonSchemaVersion),bundleSource:ce("string","QuerySnapshot"),bundleName:ce("string"),bundle:ce("string")};class kh extends Kv{constructor(e){super(),this.firestore=e}convertBytes(e){return new Be(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Ce(this.firestore,null,t)}}function Jv(n,...e){var t,r,s;n=xe(n);let o={includeMetadataChanges:!1,source:"default"},a=0;typeof e[a]!="object"||wu(e[a])||(o=e[a++]);const u={includeMetadataChanges:o.includeMetadataChanges,source:o.source};if(wu(e[a])){const v=e[a];e[a]=(t=v.next)===null||t===void 0?void 0:t.bind(v),e[a+1]=(r=v.error)===null||r===void 0?void 0:r.bind(v),e[a+2]=(s=v.complete)===null||s===void 0?void 0:s.bind(v)}let l,d,p;if(n instanceof Ce)d=Xr(n.firestore,Xi),p=Eo(n._key.path),l={next:v=>{e[a]&&e[a](Xv(d,n,v))},error:e[a+1],complete:e[a+2]};else{const v=Xr(n,Ls);d=Xr(v.firestore,Xi),p=v._query;const E=new kh(d);l={next:C=>{e[a]&&e[a](new un(d,E,v,C))},error:e[a+1],complete:e[a+2]},Gv(n._query)}return(function(E,C,V,M){const k=new Mv(M),q=new Ev(C,k,V);return E.asyncQueue.enqueueAndForget((async()=>gv(await mu(E),q))),()=>{k.Ou(),E.asyncQueue.enqueueAndForget((async()=>_v(await mu(E),q)))}})($v(d),p,u,l)}function Xv(n,e,t){const r=t.docs.get(e._key),s=new kh(n);return new jt(n,s,e._key,r,new Hn(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(s){En=s})(yn),ln(new $t("firestore",((r,{instanceIdentifier:s,options:o})=>{const a=r.getProvider("app").getImmediate(),u=new Xi(new Zg(r.getProvider("auth-internal")),new n_(a,r.getProvider("app-check-internal")),(function(d,p){if(!Object.prototype.hasOwnProperty.apply(d.options,["projectId"]))throw new x(N.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ir(d.options.projectId,p)})(a,s),a);return o=Object.assign({useFetchStreams:t},o),u._setSettings(o),u}),"PUBLIC").setMultipleInstances(!0)),vt(bc,Rc,e),vt(bc,Rc,"esm2017")})();const Yv=typeof location<"u"&&/^(localhost|127\.0\.0\.1)$/.test(location.hostname),Zv={apiKey:"AIzaSyDzUGG3LEJbx0XccOWH2xEhZcttMw_238E",authDomain:Yv?"mrcong-d8b07.firebaseapp.com":location.host,projectId:"mrcong-d8b07",storageBucket:"mrcong-d8b07.firebasestorage.app",messagingSenderId:"926811951160",appId:"1:926811951160:web:acdfdd0941e12be35d96cd"},Oh=yp()[0]||Uu(Zv),rt=Qg(Oh),eE=Bv(Oh),sI=(async()=>{if(typeof location>"u")return;const n=/[#&]t=([^&]+)/.exec(location.hash);if(n){history.replaceState(null,"",location.pathname+location.search);try{await km(rt,decodeURIComponent(n[1]))}catch(e){console.warn("[auth] sso handoff failed:",e?.code||e?.message)}}})();async function iI(){const n=new Xe;n.addScope("email"),n.addScope("profile"),n.setCustomParameters({prompt:"select_account"});try{return await rg(rt,n)}catch(e){const t=e?.code||"";if(["auth/popup-blocked","auth/popup-closed-by-user","auth/cancelled-popup-request","auth/operation-not-supported-in-this-environment"].includes(t))return await ug(rt,n),null;throw e}}const wi={code:null};hg(rt).catch(n=>{wi.code=n?.code||n?.message||"unknown",console.warn("[auth] redirect result:",wi.code),document.dispatchEvent(new CustomEvent("clipoox:auth-error",{detail:wi.code}))});const oI=(n,e)=>Nm(rt,n.trim(),e),aI=n=>Dm(rt,n.trim()),cI=()=>xm(rt),uI=n=>Lm(rt,n);async function tE(){const n=rt.currentUser;return n?n.getIdToken():null}function lI(n,e,t){return Jv(jv(eE,"users",n),r=>{!r.exists()&&!r.metadata.fromCache&&t?.();const s=r.data()||{},o=typeof s.planCredits=="number"?s.planCredits:0,a=typeof s.extraCredits=="number"?s.extraCredits:0,u=typeof s.credits=="number"?s.credits:0,l=o===0&&a===0&&!s.planExpiresAt;e({credits:l?u:Math.round((o+a)*100)/100,planCredits:o,extraCredits:a,activePlan:s.activePlan||"free",planExpiresAt:typeof s.planExpiresAt?.toMillis=="function"?s.planExpiresAt.toMillis():typeof s.planExpiresAt=="number"?s.planExpiresAt:null})},()=>e({credits:0,planCredits:0,extraCredits:0,activePlan:"free"}))}async function b(n){const e=await jd(n).catch(r=>{throw Object.assign(new Error(De("Mất kết nối khi đang chờ kết quả từ máy chủ. Hãy thử lại.")),{status:n.status,code:r?.code||"reply_lost"})}),t=n.ok&&typeof e.error=="string"&&typeof e.status=="number"&&e.status>=400;if(!n.ok||t){const r=t?e.status:n.status,s=new Error(e.error||`${n.status} ${n.statusText}`);throw s.status=r,s.code=e.code,s.data=e,s}return e}async function kt(){const n=await tE();return n?{"X-Firebase-Token":n}:{}}const j=async n=>fetch(n,{headers:await kt()}),nE=()=>j("/api/mocap/hy/status").then(n=>n.ok?n.json():null),O=async(n,e,t="POST")=>fetch(n,{method:t,headers:{"Content-Type":"application/json","Accept-Language":Yn(),...await kt()},body:JSON.stringify(n.startsWith("/api/agent")||n.startsWith("/api/shot-agent")?{...e,locale:Yn()}:e)}),rE=()=>j("/api/me").then(n=>b(n)),sE=()=>j("/api/health").then(n=>b(n)),iE=()=>j("/api/generate").then(n=>b(n)).then(n=>n.generators),oE=(n,e)=>O("/api/generate/estimate",{generator:n,inputs:e}).then(t=>b(t)),aE=(n,e,t)=>O("/api/generate",{generator:n,inputs:e,canvasId:t}).then(r=>b(r)),cE=(n,e=!1)=>{const t=new URL(`/api/jobs/${n}`,window.location.origin);return e&&t.searchParams.set("poll","1"),j(t.toString()).then(r=>b(r)).then(r=>r.job)},uE=(n,e=50)=>{const t=new URL("/api/jobs",window.location.origin);return n&&t.searchParams.set("canvasId",n),t.searchParams.set("limit",String(e)),j(t.toString()).then(r=>b(r)).then(r=>r.jobs)},lE=(n,e,t)=>O("/api/media/trim",{videoUrl:n,start:e,end:t}).then(r=>b(r)),hE=(n,e)=>O("/api/media/region-splice",{sourceUrl:n,regions:e}).then(t=>b(t)),dE=(n,e)=>O("/api/media/frame",{videoUrl:n,...e}).then(t=>b(t)),Dh=(n,e,t,r)=>O("/api/uploads/sign",{filename:n,contentType:e,kind:t,...r?{rightsConfirmed:!0}:{}}).then(s=>b(s));function fE(n){return new Promise(e=>{const t=document.createElement(n.type.startsWith("audio/")?"audio":"video"),r=URL.createObjectURL(n),s=a=>{clearTimeout(o),t.onloadedmetadata=t.onerror=null,t.removeAttribute("src"),t.load(),URL.revokeObjectURL(r),e(a)},o=setTimeout(()=>s(null),1e4);t.preload="metadata",t.onloadedmetadata=()=>s(Number.isFinite(t.duration)?t.duration:null),t.onerror=()=>s(null),t.src=r})}async function pE(n,e,t,r=!1){const s=xd(n)||t==="audio"||t==="voice";if(s&&!r&&!await Ud([n.name]))throw new Error(De("Cần xác nhận quyền sử dụng bản nhạc trước khi tải lên"));if(/^(video|audio)\//.test(n.type)&&typeof document<"u"){const a=await fE(n);if(a!==null&&a>Cd+.001)throw new Error(De("Video/âm thanh đầu vào tối đa 20 phút"))}const o=await Dh(n.name,n.type||"application/octet-stream",t,s);return await new Promise((a,u)=>{const l=new XMLHttpRequest;l.open("PUT",o.uploadUrl),Object.entries(o.headers).forEach(([d,p])=>l.setRequestHeader(d,p)),l.upload.onprogress=d=>{d.lengthComputable&&e&&e(Math.round(d.loaded/d.total*100))},l.onload=()=>l.status>=200&&l.status<300?a():u(new Error(`upload failed: ${l.status}`)),l.onerror=()=>u(new Error("upload network error")),l.send(n)}),{url:o.readUrl,gcsUri:o.gcsUri,...o.rightsConfirmed?{rightsConfirmed:o.rightsConfirmed}:{}}}const mE=(n,e,t)=>O("/api/uploads/sign",{filename:n,contentType:e,temp:t}).then(r=>b(r)),gE=()=>j("/api/uploads/temp").then(n=>b(n)),_E=n=>O("/api/uploads/temp/sign",{gcsUri:n}).then(e=>b(e)),yE=n=>O("/api/uploads/temp",n,"DELETE").then(e=>b(e));function vE(n,e,t,r){return new Promise((s,o)=>{const a=new XMLHttpRequest;a.open("PUT",n.uploadUrl),Object.entries(n.headers).forEach(([u,l])=>a.setRequestHeader(u,l)),a.upload.onprogress=u=>{u.lengthComputable&&t?.(u.loaded,u.total)},a.onload=()=>a.status>=200&&a.status<300?s():o(new Error(`upload failed: ${a.status}`)),a.onerror=()=>o(new Error("upload network error")),a.onabort=()=>o(Object.assign(new Error(De("Đã huỷ gửi tạm")),{name:"AbortError"})),r?.addEventListener("abort",()=>a.abort(),{once:!0}),a.send(e)})}const EE=n=>O("/api/uploads/model-url",{gcsUri:n}).then(e=>b(e)).then(e=>e.url),TE=n=>O("/api/plugins/asset-urls",{uris:n}).then(e=>b(e)).then(e=>e.urls),wE=n=>O("/api/outputs/sign",n).then(e=>b(e)).then(e=>e.url),IE=(n={})=>O("/api/canvases",n).then(e=>b(e)).then(e=>e.canvas),AE=n=>j(`/api/canvases/${n}`).then(e=>b(e)).then(e=>e.canvas),bE=(n,e)=>O(`/api/canvases/${n}`,e,"PUT").then(t=>b(t)),RE=(n,e)=>j(`/api/canvases/${encodeURIComponent(n)}/shot-rev/${encodeURIComponent(e)}`).then(t=>b(t)),SE=n=>j(`/api/canvases/${encodeURIComponent(n)}/timeline-rev`).then(e=>b(e)),CE=n=>j(`/api/timeline-docs/${encodeURIComponent(n)}/rev`).then(e=>b(e)),PE=n=>O(`/api/canvases/${n}`,{},"DELETE").then(e=>b(e)),kE=n=>O("/api/blender/device/approve",{userCode:n}).then(e=>b(e)),OE=()=>j("/api/blender-remote/devices").then(n=>b(n)),DE=n=>O("/api/blender-remote/missions",n).then(e=>b(e)),NE=(n=8)=>j(`/api/blender-remote/missions?limit=${n}`).then(e=>b(e)),VE=n=>j(`/api/blender-remote/missions/${encodeURIComponent(n)}`).then(e=>b(e)),ME=n=>O("/api/blender-remote/vcam/session",{deviceId:n}).then(e=>b(e)),LE=n=>O(`/api/blender-remote/missions/${encodeURIComponent(n)}/cancel`,{}).then(e=>b(e)),xE=n=>j(`/api/canvases${n?`?limit=${n}`:""}`).then(e=>b(e)).then(e=>e.canvases),UE=(n,e)=>O(`/api/canvases/${n}/archive`,{archived:e}).then(t=>b(t)),FE=n=>O(`/api/canvases/${n}/duplicate`,{}).then(e=>b(e)).then(e=>e.canvas),jE=()=>j("/api/skills").then(n=>b(n)),BE=n=>O("/api/skills",n).then(e=>b(e)).then(e=>e.skill),$E=(n,e)=>O(`/api/skills/${n}`,e,"PUT").then(t=>b(t)).then(t=>t.skill),qE=n=>O(`/api/skills/${n}`,{},"DELETE").then(e=>b(e)),zE=()=>j("/api/series").then(n=>b(n)),HE=n=>j(`/api/series/${encodeURIComponent(n)}`).then(e=>b(e)),WE=(n,e)=>O(`/api/series/${encodeURIComponent(n)}`,e,"PUT").then(t=>b(t)),GE=n=>j(`/api/sets/${encodeURIComponent(n)}`).then(e=>b(e)),KE=(n,e,t)=>O(`/api/sets/${encodeURIComponent(n)}`,{name:e,recipe:t},"PUT").then(r=>b(r)),QE=async n=>{const e=await j(`/api/timeline-docs/${encodeURIComponent(n)}`);return e.status===404?null:(await b(e)).timeline},JE=(n,e)=>O(`/api/timeline-docs/${encodeURIComponent(n)}`,e,"PUT").then(t=>b(t)),XE=async(n,e,t)=>{const r=await O(`/api/timeline-docs/${encodeURIComponent(n)}/copy`,{id:e,nodeId:t.nodeId,...t.canvasId?{canvasId:t.canvasId}:{}});return r.status===404?!1:(await b(r),!0)},YE=()=>j("/api/canvas-inbox").then(n=>b(n)),ZE=n=>O("/api/canvas-inbox/consume",{ids:n}).then(e=>b(e)),eT=(n,e,t="upload")=>j("/api/assets?"+new URLSearchParams({source:t,...n?{kind:n}:{},...e?{cursor:e}:{}})).then(r=>b(r)),tT=(n,e)=>O("/api/director/"+encodeURIComponent(n)+"/context",e,"PUT").then(t=>b(t)),nT=n=>j(`/api/director/${encodeURIComponent(n)}`).then(e=>b(e)),rT=n=>j(`/api/director-references/${encodeURIComponent(n)}`).then(e=>b(e)),sT=(n,e,t,r)=>O(`/api/director-references/${encodeURIComponent(n)}`,{gcsUri:e,label:t,role:r}).then(s=>b(s)),iT=n=>j(`/api/library${n?`?kind=${encodeURIComponent(n)}`:""}`).then(e=>b(e)).then(e=>e.assets),oT=()=>j("/api/library/usage").then(n=>b(n)),aT=n=>O("/api/library/pin",n).then(e=>b(e)),cT=n=>O(`/api/library/${encodeURIComponent(n)}`,{},"DELETE").then(e=>b(e)),uT=(n,e)=>O(`/api/timeline-agent/${encodeURIComponent(n)}`,e).then(t=>b(t)),lT=(n,e)=>O(`/api/timeline-agent/${encodeURIComponent(n)}/locate-object`,e).then(t=>b(t)),hT=n=>O("/api/timeline-agent/usage",{events:n}).then(e=>b(e));async function dT(n,e,t,r){const s=`/api/timeline-agent/${encodeURIComponent(n)}/describe`;if(!r)return O(s,{items:e,locale:t}).then(v=>b(v));const o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:`${rs}, application/json;q=0.9`,"Accept-Language":Yn(),...await kt()},body:JSON.stringify({items:e,locale:t})});if(!o.ok||!(o.headers.get("Content-Type")||"").startsWith(rs)||!o.body)return b(o);const a=o.body.pipeThrough(new TextDecoderStream).getReader();let u="",l=null;const d=v=>{if(!v.trim())return;const E=JSON.parse(v);if(E&&typeof E=="object"&&E.progress)try{r(E.progress)}catch{}else l=E};for(;;){const{value:v,done:E}=await a.read();if(E)break;u+=v;let C;for(;(C=u.indexOf(`
|
|
3157
|
-
`))>=0;)d(u.slice(0,C)),u=u.slice(C+1)}d(u);const p=l||{};if(typeof p.error=="string"&&typeof p.status=="number"&&p.status>=400){const v=new Error(p.error);throw v.status=p.status,v.code=p.code,v.data=p,v}if(!l)throw new Error(De("Phân tích bị ngắt giữa chừng. Hãy thử lại."));return l}async function
|
|
3158
|
-
`))>=0;)u(o.slice(0,v)),o=o.slice(v+1)}u(o);const l=a||{};if(typeof l.error=="string"&&typeof l.status=="number"&&l.status>=400){const d=new Error(l.error);throw d.status=l.status,d.code=l.code,d}if(!l.item)throw new Error(De("Chép lời bị ngắt giữa chừng. Hãy thử lại."));return l.item}const pT=(n,e,t=0)=>j(`/api/timeline-agent/plan-price?model=${encodeURIComponent(n)}&chars=${Math.round(e)}&refs=${t}`).then(r=>b(r)),mT=(n,e=!0)=>j(`/api/timeline-agent/describe-price?audioOnly=${e?1:0}${n&&n>0?`&duration=${Math.ceil(n)}`:""}`).then(t=>b(t)),gT=(n,e,t)=>O("/api/timeline/multicam/sync",{canvasId:n,items:e,...t?{main:t}:{}}).then(r=>b(r)),xs=(n,e)=>`/api/production/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,_T=(n,e)=>j(xs(n,e)).then(t=>b(t)),yT=(n,e,t)=>O(`${xs(n,e)}/quote`,{imageGenerator:t}).then(r=>b(r)),vT=(n,e,t,r)=>O(`${xs(n,e)}/${t}`,{revision:r}).then(s=>b(s)),ET=(n,e,t,r,s,o,a,u)=>O(`/api/director/${encodeURIComponent(n)}`,{input:e,requestId:t,referenceIds:r,defaults:s,...o?{skill:o.id?{id:o.id}:{title:o.title,instruction:o.instruction}}:{},...a?{model:a}:{},...u?{aspectRatio:u}:{}}).then(l=>b(l)),TT=(n,e,t,r)=>O(`${xs(n,e)}/accept`,{revision:t,totalCredits:r}).then(s=>b(s)),wT=n=>O(`/api/director/${encodeURIComponent(n)}`,{},"DELETE").then(e=>b(e)),IT=(n,e,t,r)=>O("/api/agent",{messages:n.map(({role:s,content:o})=>({role:s,content:o})),canvas:e,model:t||void 0,defaults:r}).then(s=>b(s)),AT=()=>j("/api/agent/models").then(n=>n.json()),bT=(n="published",e)=>j("/api/model-library?"+new URLSearchParams({status:n,...e?{cursor:e}:{}})).then(t=>b(t)),RT=()=>j("/api/model-library/categories").then(n=>b(n)),ST=(n,e)=>O("/api/model-library/"+encodeURIComponent(n)+"/thumbnail",{gcsUri:e}).then(t=>b(t)),CT=n=>O("/api/model-library",n).then(e=>b(e)),PT=(n,e)=>O("/api/model-library/"+encodeURIComponent(n),{status:e},"PATCH").then(t=>b(t)),kT=(n={})=>j("/api/asset-library?"+new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0&&e!=="").map(([e,t])=>[e,String(t)]))).then(e=>b(e)),OT=n=>j("/api/asset-library/categories"+(n?"?kind="+n:"")).then(e=>b(e)),DT=n=>j("/api/asset-library/"+encodeURIComponent(n)).then(e=>b(e)).then(e=>e.item),NT=(n="published")=>j("/api/text-templates?"+new URLSearchParams({status:n})).then(e=>b(e)),VT=()=>j("/api/brands").then(n=>b(n)),MT=()=>j("/api/fonts").then(n=>b(n)),LT=n=>O("/api/fonts",n).then(e=>b(e)),xT=n=>O("/api/fonts/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),UT=(n,e)=>O("/api/brands"+(e?"/"+encodeURIComponent(e):""),n,e?"PUT":"POST").then(t=>b(t)),FT=n=>O("/api/brands/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),jT=n=>O("/api/luts",n).then(e=>b(e)),BT=()=>j("/api/luts").then(n=>b(n)),$T=n=>O("/api/luts/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),qT=n=>j("/api/luts/"+encodeURIComponent(n)).then(e=>b(e)),zT=(n="published")=>j("/api/transitions?"+new URLSearchParams({status:n})).then(e=>b(e)),HT=n=>O("/api/model-library/share",n).then(e=>b(e)),WT=()=>j("/api/shot-agent").then(n=>b(n)),GT=(n,e,t)=>O("/api/shot-agent/estimate",{scene:n,messages:e,model:t}).then(r=>b(r)),KT=(n,e,t,r)=>O("/api/shot-agent",{scene:n,messages:e,requestId:t,model:r}).then(s=>b(s)),QT=n=>O("/api/shot-agent/mission/turn",n).then(e=>b(e)),JT=(n,e="build")=>O("/api/shot-agent/mission/quote",{model:n,kind:e}).then(t=>b(t)),XT=n=>O("/api/shot-agent/mission/cancel",{missionId:n}).then(e=>b(e)),YT=n=>O("/api/shot-agent/remote/poll",n).then(e=>b(e)),ZT=n=>O("/api/shot-agent/live/poll",n).then(e=>b(e)),ew=n=>O("/api/timeline-live/poll",n).then(e=>b(e)),tw=(n,e)=>O(`/api/timeline-live/${encodeURIComponent(n)}/progress`,e).then(t=>b(t)),nw=(n,e)=>O(`/api/timeline-live/${encodeURIComponent(n)}/result`,e).then(t=>b(t)),rw=(n,e)=>O(`/api/shot-agent/live/${encodeURIComponent(n)}/result`,e).then(t=>b(t)),sw=(n,e)=>O(`/api/shot-agent/remote/missions/${encodeURIComponent(n)}/status`,e).then(t=>b(t)),iw=n=>O("/api/person-mattes",{data:n}).then(e=>b(e)).then(e=>e.ref),ow=async n=>{const e=await j(`/api/person-mattes/${n}`);return e.ok||await b(e),e.text()},aw=n=>O("/api/roto-masks",{data:n}).then(e=>b(e)).then(e=>e.ref),cw=async n=>{const e=await j(`/api/roto-masks/${n}`);return e.ok||await b(e),e.text()},uw=n=>O("/api/shot-scenes",{data:n}).then(e=>b(e)).then(e=>e.ref),lw=async n=>{const e=await j(`/api/shot-scenes/${n}`);return e.ok||await b(e),e.text()},hw=n=>O("/api/color-agent/price",n).then(e=>b(e)),dw=(n,e)=>O(`/api/color-agent/${encodeURIComponent(n)}`,e).then(t=>b(t)),fw=n=>O("/api/broll-prompt/price",n).then(e=>b(e)),pw=(n,e)=>O(`/api/broll-prompt/${encodeURIComponent(n)}`,e).then(t=>b(t)),mw=n=>O("/api/geo/hd",n).then(e=>b(e)),gw=async n=>{const e=await O("/api/geo/blender-city",n);if(!e.ok)throw await b(e),Error("Blender city failed");return{script:await e.text(),buildings:Number(e.headers.get("x-city-buildings"))||0}},_w=n=>O("/api/geo/resolve",{ops:n}).then(e=>b(e)),yw=(n,e=!0,t="vi")=>j(`/api/geo/search?${new URLSearchParams({q:n,shape:e?"1":"0",lang:t})}`).then(r=>b(r)).then(r=>r.results),vw=n=>O("/api/caption-keywords/price",{words:n}).then(e=>b(e)),Ew=(n,e,t)=>O(`/api/caption-keywords/${encodeURIComponent(n)}`,{words:e,locale:t}).then(r=>b(r)),Tw=(n,e)=>O("/api/caption-translate/price",{lines:n,target:e}).then(t=>b(t)),ww=(n,e,t)=>O(`/api/caption-translate/${encodeURIComponent(n)}`,{lines:e,target:t}).then(r=>b(r)),Iw=n=>O("/api/media-peaks",{url:n}).then(e=>b(e)),Aw=n=>O("/api/stabilize",n).then(e=>b(e)),bw=n=>O("/api/audio-tools",n).then(e=>b(e)),Rw=n=>O("/api/media/frames/sign",{count:n}).then(e=>b(e)).then(e=>e.chunks);let Sw=null;const Nh=()=>Sw??=j("/api/media/render-target").then(n=>n.ok?n.json():{}).then(n=>({url:n?.url||"",gpu:n?.gpu!==!1})).catch(()=>({url:"",gpu:!1})),vr=()=>Nh().then(n=>n.url),Vh=n=>n<=30?1:Math.min(8,Math.ceil(n/10));function Cw(n){vr().then(e=>{if(e)for(let t=0;t<Vh(n);t++)fetch(`${e}/api/health`,{cache:"no-store"}).catch(()=>{})}).catch(()=>{})}async function Pw(n,e){const t=await vr();for(let r=0;;r++){const s=await fetch(`${t}/api/media/proxy`,{method:"POST",signal:e,headers:{"Content-Type":"application/json",...await kt()},body:JSON.stringify({gcsUri:n})});if(s.status===429&&r<6){await xo(1e4,e);continue}const o=await b(s);return o.needed&&o.url&&o.gcsUri?{url:o.url,gcsUri:o.gcsUri,fps:Number(o.fps),width:Number(o.width),height:Number(o.height),...o.alpha===!0?{alpha:!0}:{}}:null}}let Au=null;const kw=()=>Au??=vr().then(async n=>fetch(`${n}/api/shot-inbetween`,{headers:await kt()})).then(n=>b(n)).catch(()=>(Au=null,{available:!1,maxSeconds:0}));async function Ow(n,e){const t=await vr();for(let r=0;;r++){const s=await fetch(`${t}/api/shot-inbetween`,{method:"POST",signal:e,headers:{"Content-Type":"application/json",...await kt()},body:JSON.stringify(n)});if(s.status===429&&r<6){await xo(5e3,e);continue}return b(s)}}const bu=[5,10,15,20,30,30,30,30,30,30].map(n=>n*1e3),xo=(n,e)=>new Promise((t,r)=>{const s=setTimeout(t,n);e?.addEventListener("abort",()=>{clearTimeout(s),r(new DOMException("Aborted","AbortError"))},{once:!0})});function Mh(n){try{const e=n.headers.get("X-Clipoox-Review"),t=e?JSON.parse(decodeURIComponent(e)):null;return t&&Array.isArray(t.checks)&&Array.isArray(t.platforms)?t:null}catch{return null}}const Ut=.9;async function Dw(n,e){const t=Number(n.headers.get("Content-Length"))||0;if(!n.body||!t)return n.blob();const r=n.body.getReader(),s=[];let o=0;for(;;){const{done:a,value:u}=await r.read();if(a)break;s.push(u),o+=u.length,e(Math.min(1,o/t))}return new Blob(s,{type:n.headers.get("Content-Type")||"video/mp4"})}let Us=null,ys=null,vs=null;const Lh=n=>{const e=/^(\d+)\/(\d+)$/.exec(n.headers.get("X-Clipoox-Export-Quota")||"");return e?{used:+e[1],limit:+e[2]}:null};async function Nw(n,e,t,r,s){if(!n.body)throw new Error("Export failed (empty reply)");const o=n.body.getReader(),a=Fd(),u=[];let l=0,d=0,p=null,v=null,E=0;for(;;){const{done:C,value:V}=await o.read();if(C)break;for(const M of a.push(V))if(M.type==="progress")t?.(Ut*M.value);else if(M.type==="review"){const k=M.review;p=k&&Array.isArray(k.checks)&&Array.isArray(k.platforms)?k:null}else if(M.type==="timings")v=M.timings;else{if(M.type==="error")throw Object.assign(new Error(Uo(M.error)),{status:M.status});M.type==="file"?(l=M.size,E=performance.now(),e?.("download")):M.type==="stored"?(vs={gcsUri:M.gcsUri,size:M.size},l=M.size,E=performance.now()):M.type==="data"&&(u.push(M.chunk),d+=M.chunk.length,t?.(Ut+(1-Ut)*(l?Math.min(1,d/l):0)))}}if(!a.complete)throw new Error("Export interrupted — please try again");return s&&(Us={totalMs:Math.round(performance.now()-s.start),framesMs:Math.round(s.posted-s.start),renderMs:Math.round((E||performance.now())-s.posted),downloadMs:E?Math.round(performance.now()-E):0,server:v}),v&&s&&console.info("[export] timings",{server:v,browser:{frames_ms:Math.round(s.posted-s.start),request_to_file_ms:Math.round(E-s.posted),download_ms:Math.round(performance.now()-E),total_ms:Math.round(performance.now()-s.start),bytes:l}}),r?.(p),new Blob(vs?[]:u,{type:"video/mp4"})}function Uo(n){const e=/^Media exceeds (\d+) MB per export/.exec(n||"");if(e)return De("Video, ảnh và nhạc gốc trong Timeline nặng hơn {0} MB cho một lần xuất. Hãy cắt bớt hoặc bỏ các clip dài không dùng tới rồi xuất lại.",[e[1]]);const t=/^Media link missing: “(.*)” \(([\d.]+)s\)/.exec(n||"");return t?De("Lớp “{0}” (giây {1}) chưa có file media. Mở lớp đó chọn lại media, hoặc xoá lớp rồi xuất lại.",[t[1],t[2]]):/^MP4 render failed|Error opening input|Stream #\d|Input #\d|\/tmp\/canvas-/.test(n||"")?(console.warn("[export] render failed:",n),De("Không xuất được video lần này. Nếu bạn vừa sửa Timeline trong lúc xuất, hãy chờ lưu xong rồi bấm xuất lại. Nếu vẫn lỗi, hãy báo Clipoox.")):n||""}function xh(n){return n.code==="export_quota"?Object.assign(new Error(De("Bạn đã dùng hết lượt xuất video tháng này")),{planGate:{kind:"count",plan:n.plan||"free",offer:n.offer??null,seconds:0,limit:Number(n.limit)||0,used:Number(n.used)||0,resetAt:Number(n.resetAt)||0}}):n.code==="plan_required"&&n.offer?Object.assign(new Error(De("Cần nâng cấp gói để xuất video dài hơn")),{planGate:{kind:"length",plan:n.plan||"free",offer:n.offer,seconds:Number(n.seconds)||0}}):null}let Je=[];const Vw=n=>n.map(e=>e.replace(/[^A-Za-z0-9 _.:-]/g,"").slice(0,48)).filter(Boolean).slice(0,16).join(",");async function Mw(n,e,t,r,s,o,a,u){try{if(localStorage.getItem("clipoox.gpuExport")==="off")return Je=["off in this browser"],null}catch{}if(!(await Nh()).gpu)return Je=["off on the server"],null;const l=e.format||{resolution:"720p",aspectRatio:"16:9",fps:30},{clientExportCheck:d,clientExportCodes:p,softwareRetry:v,gpuErrorText:E}=await pe(async()=>{const{clientExportCheck:k,clientExportCodes:q,softwareRetry:z,gpuErrorText:B}=await import("./clientExport-pkLbOmEF.js");return{clientExportCheck:k,clientExportCodes:q,softwareRetry:z,gpuErrorText:B}},__vite__mapDeps([0,1,2])),C=d(n,{format:l,camera:e.camera,look:e.look,encode:e.encode});if(!C.ok)return console.info("[export] server render:",C.reasons.slice(0,5).join(" · ")),Je=p(n,{format:l,camera:e.camera,look:e.look,encode:e.encode}),null;const V=await pe(()=>import("./gpuExport-oA2mUsdm.js"),__vite__mapDeps([3,1,4,2,5,6,7,8,9,10,11]));if(!await V.gpuExportSupported(l,e.encode))return console.info("[export] server render: no hardware video encoder here"),Je=[e.encode?.codec==="hevc"&&await V.gpuExportSupported(l)?"no hevc encoder":"no hardware encoder"],null;const M=n.reduce((k,q)=>q.disabled?k:Math.max(k,q.start+q.duration),0);{const k=await O("/api/media/client-export/check",{seconds:M,...e.aiJob?{aiJob:e.aiJob}:{}});if(k.status===402){const z=xh(await k.json().catch(()=>({})));if(z)throw z}if(!k.ok)return Je=[`plan check ${k.status}`],null;const q=(await k.json().catch(()=>null))?.hold;u.hold=typeof q=="string"?q:null}r?.("local"),s?.(0);try{let k=!1;const q=_=>V.exportOnGpu(n,{format:l,encode:e.encode,tracks:e.tracks,camera:e.camera,signal:t,onProgress:m=>s?.(m),software:_}),{blob:z,ms:B}=await q(!1).catch(_=>{if(t?.aborted||!v(_,V.gpuExportStage(),e.encode))throw _;return console.warn("[export] hardware encoder failed, again with the software encoder:",_),s?.(0),k=!0,q(!0)}),{width:Y,height:he,fps:P}=Xt(l);Us={totalMs:Math.round(performance.now()-a.start),framesMs:B.titles,renderMs:B.video+B.audio,downloadMs:0,server:{gpu:!0,...B}};{const _=await O("/api/media/client-export/done",{seconds:M,...u.hold?{hold:u.hold}:{},...k?{software:!0}:{},ms:B.total,titlesMs:B.titles,audioMs:B.audio,width:Y,height:he,fps:P,clips:n.length,...e.aiJob?{aiJob:e.aiJob}:{}}).catch(()=>null);_?.ok&&(ys=Lh(_)),u.hold=null}return o?.(null),z}catch(k){if(t?.aborted||k?.name==="AbortError")throw k;return console.warn("[export] GPU export failed, the server renders it:",k),Je=[`gpu failed: ${k?.name||"Error"} at ${V.gpuExportStage()||"start"}`,...E(k)?[`gpu error: ${E(k)}`]:[]],r?.("frames"),s?.(null),null}}async function Lw(n,e,t={},r,s,o){r?.("frames"),o?.(null);const a={start:performance.now(),posted:0};t.mode===void 0&&(Us=null,ys=null,vs=null),n=Ad(n,Xt(t.format||{resolution:"720p",aspectRatio:"16:9",fps:30}).fps);{const{expandComps:P}=await pe(async()=>{const{expandComps:m}=await import("./timelineComp-i-zdaoB2.js").then(g=>g.t);return{expandComps:m}},__vite__mapDeps([2,1])),_=Xt(t.format||{resolution:"720p",aspectRatio:"16:9",fps:30});n=P(n.filter(m=>!m.disabled),{W:_.width,H:_.height})}n=n.filter(P=>!P.disabled).map(bd);const u=Md(n);n=u.clips;const l=n.filter(P=>P.title&&!P.url&&!Rd(P));if(l.length){const P=new Map((await(await pe(async()=>{const{materializeTitles:_}=await import("./timelineText-DurRhyuh.js");return{materializeTitles:_}},__vite__mapDeps([12,13,1,11,14,15,10]))).materializeTitles(l)).map(_=>[_.id,_]));n=n.map(_=>P.get(_.id)??_)}if(u.fixes.length&&s){const P=s;s=_=>P({..._??{ok:!0,checks:[],platforms:[],duration:0,ms:0},fixes:[...u.fixes,..._?.fixes??[]].slice(0,10)})}if(Je=t.breakdown?["breakdown"]:[],t.mode===void 0&&!t.breakdown){const P={hold:null},_=await Mw(n,t,e,r,o,s,a,P);if(_)return _;P.hold&&(t={...t,hold:P.hold})}t.mode===void 0&&Cw(n.reduce((P,_)=>_.disabled?P:Math.max(P,_.start+_.duration),0)),n.some(P=>P.join)&&(n=[...n,...(await pe(async()=>{const{joinDecoLayers:P}=await import("./titleFrameBudget-DsM0V482.js").then(_=>_.nM);return{joinDecoLayers:P}},[])).joinDecoLayers(n)]);const d=new(await pe(async()=>{const{FrameSink:P}=await import("./frameSink-CSRqCnwI.js");return{FrameSink:P}},__vite__mapDeps([16,1]))).FrameSink({signal:e}),p=t.format||{resolution:"720p",aspectRatio:"16:9",fps:30};if(n.some(Sd)){const P=await(await pe(async()=>{const{distortForServer:_}=await import("./distortFrames-D_v-aSVO.js");return{distortForServer:_}},__vite__mapDeps([17,1,7,8]))).distortForServer(n,p,d,e,t.tracks);n=P.clips,t={...t,tracks:P.tracks}}if(n.some(P=>P.kind==="model")&&await(await pe(async()=>{const{render3DFrames:P}=await import("./timeline3dExport-Uo0S0CR0.js");return{render3DFrames:P}},__vite__mapDeps([18,1,19,20,21,22,16,10,11]))).render3DFrames(n,p,d,e,t.camera),n.some(P=>Fa(P.title)||P.shape||P.motion||P.lottie||P.card||P.geo)&&await(await pe(async()=>{const{renderTitleFrames:P}=await import("./titleFrames-C8kvflgT.js");return{renderTitleFrames:P}},__vite__mapDeps([23,1,14,15,24,25,10,11,16]))).renderTitleFrames([...n,...ja(n)],p,d,e,t.camera),n.some(P=>P.mask||P.person)){const P=await pe(()=>import("./rotoMatte-7b7Ow64f.js").then(_=>_.r),__vite__mapDeps([26,1,13,11]));await P.renderMatteFrames([...n,...P.maskedCopies(n)],Xt(p).fps,d,e)}{const P=await pe(()=>import("./windowFrames-DhhJLIs-.js"),__vite__mapDeps([27,1,26,13,11,10]));P.hasMovingWindows(n)&&await P.renderWindowFrames(n,Xt(p).fps,d,e)}{const{groupedLevels:P}=await pe(async()=>{const{groupedLevels:m}=await import("./timelineComp-i-zdaoB2.js").then(g=>g.t);return{groupedLevels:m}},__vite__mapDeps([2,1])),_=Xt(p);for(const m of P(n,{W:_.width,H:_.height})){if(m.some(g=>g.kind==="model")&&await(await pe(async()=>{const{render3DFrames:g}=await import("./timeline3dExport-Uo0S0CR0.js");return{render3DFrames:g}},__vite__mapDeps([18,1,19,20,21,22,16,10,11]))).render3DFrames(m,p,d,e,null),m.some(g=>Fa(g.title)||g.shape||g.motion||g.lottie||g.card||g.geo)&&await(await pe(async()=>{const{renderTitleFrames:g}=await import("./titleFrames-C8kvflgT.js");return{renderTitleFrames:g}},__vite__mapDeps([23,1,14,15,24,25,10,11,16]))).renderTitleFrames([...m,...ja(m)],p,d,e,null),m.some(g=>g.mask||g.person)){const g=await pe(()=>import("./rotoMatte-7b7Ow64f.js").then(T=>T.r),__vite__mapDeps([26,1,13,11]));await g.renderMatteFrames([...m,...g.maskedCopies(m)],_.fps,d,e)}{const g=await pe(()=>import("./windowFrames-DhhJLIs-.js"),__vite__mapDeps([27,1,26,13,11,10]));g.hasMovingWindows(m)&&await g.renderWindowFrames(m,_.fps,d,e)}}}n.some(P=>P.mask||P.planar||P.sceneTrack)&&(n=await(await pe(async()=>{const{packMasks:P}=await import("./rotoMaskStore-pE1AIt3I.js");return{packMasks:P}},__vite__mapDeps([28,1,29,10,11]))).packMasks(n));const v=JSON.stringify({clips:n,...t,...await d.finish()}),E=await vr();r?.("render");const C=typeof CompressionStream=="function"&&v.length>256*1024,V=C?await new Response(new Blob([v]).stream().pipeThrough(new CompressionStream("gzip"))).blob():v;a.posted=performance.now();const M=!!o&&t.mode===void 0,k=async P=>fetch(P,{method:"POST",signal:e,headers:{"Content-Type":"application/json","X-Clipoox-Frames-Ms":String(Math.round(a.posted-a.start)),...t.mode===void 0&&Je.length?{"X-Clipoox-Gpu-Skip":Vw(Je)}:{},...M?{Accept:`${Ha}, video/mp4;q=0.9, */*;q=0.5`}:{},...C?{"Content-Encoding":"gzip"}:{},...await kt()},body:V}),q=n.reduce((P,_)=>Math.max(P,_.start+_.duration),0),z=performance.now();let B=!1;const Y=o?setInterval(()=>{B||o(Ut*Su((performance.now()-z)/1e3,10+q*.8))},500):null,he=P=>{B=!0,o?.(P)};try{let P;for(let _=0;;_++){try{P=await k(`${E}/api/media/timeline`)}catch(m){if(!E||e?.aborted)throw m;P=await k("/api/media/timeline")}if(P.status!==429||_>=bu.length)break;r?.("queue"),await xo(bu[_],e),r?.("render")}if(P.ok&&t.mode===void 0&&(ys=Lh(P)),P.ok&&M&&(P.headers.get("Content-Type")||"").startsWith(Ha))return await Nw(P,r,he,s,a);if(r?.("download"),!P.ok){const _=await P.json().catch(()=>({}));{const m=xh(_);if(m)throw m}throw _.clip?new Error(De("Không xuất được: clip “{0}” (giây {1}) có dữ liệu lỗi — {2}. Hãy sửa hoặc xoá clip đó rồi xuất lại.",[_.clip.label||"?",Number(_.clip.start||0).toFixed(1),_.reason||_.error||""])):new Error(_.code==="render_unavailable"?De("Máy render đang bận hoặc vừa khởi động lại, bản xuất này quá nặng để chạy dự phòng. Hãy xuất lại sau khoảng 1 phút."):Uo(_.error)||`Export failed (${P.status})`)}return s?.(Mh(P)),o?(he(Ut),await Dw(P,_=>he(Ut+(1-Ut)*_))):P.blob()}finally{Y&&clearInterval(Y)}}const xw=n=>j(`/api/motion-agent/price${n?`?chars=${n.chars}&duration=${n.duration}&kind=${n.kind}`:""}`).then(e=>b(e)),Uw=n=>O("/api/motion-agent",n).then(e=>b(e)).then(e=>{if(e.error)throw Object.assign(new Error(e.error),{status:e.status});return e}),Fw=()=>j("/api/rig-agent/price").then(n=>b(n)),jw=n=>O("/api/rig-agent",n).then(e=>b(e)),Bw=()=>{const n=navigator.userAgent,e=/(Edg|OPR|Firefox|Chrome|Version)\/(\d+)/.exec(n),t=e?(e[1]==="Edg"?"Edge":e[1]==="OPR"?"Opera":e[1]==="Version"?"Safari":e[1])+" "+e[2]:"other";return/Windows/.test(n)?`${t} Windows`:/Mac OS X/.test(n)?`${t} macOS`:/Android/.test(n)?`${t} Android`:/iPhone|iPad/.test(n)?`${t} iOS`:`${t} other`};function $w(n,e,t={}){try{const r=navigator;O("/api/client-log",{kind:n,message:String(e||"").slice(0,300),detail:{browser:Bw(),cores:r.hardwareConcurrency,memory:r.deviceMemory,...t}}).catch(()=>{})}catch{}}const hI=Object.freeze(Object.defineProperty({__proto__:null,acceptProduction:TT,addUserFont:LT,approveBlenderDevice:kE,archiveCanvas:UE,askAgent:IT,askShotAgent:KT,attachDirectorReference:sT,brollPrompt:pw,brollPromptPrice:fw,cancelRemoteMission:LE,canvasInbox:YE,captionKeywords:Ew,captionKeywordsPrice:vw,captionTranslate:ww,captionTranslatePrice:Tw,clearDirector:wT,colorAgent:dw,colorAgentPrice:hw,consumeCanvasInbox:ZE,copyTimelineDoc:XE,createCanvas:IE,createLibraryModel:CT,createRemoteMission:DE,createSkill:BE,createVcamSession:ME,deleteBrand:FT,deleteCanvas:PE,deleteLibraryAsset:cT,deleteLut:$T,deleteSkill:qE,deleteTempUploads:yE,deleteUserFont:xT,describeFootage:dT,describePrice:mT,duplicateCanvas:FE,estimate:oE,estimateShotAgent:GT,exportReviewOf:Mh,exportTimeline:Lw,extractFrame:dE,fetchHealth:sE,fetchLut:qT,freeTranscript:fT,friendlyExportError:Uo,geoSearch:yw,getAssetLibraryItem:DT,getCanvas:AE,getCanvasShotRev:RE,getCanvasTimelineRev:SE,getDirector:nT,getPersonMatte:ow,getProduction:_T,getRemoteMission:VE,getRotoMask:cw,getSeries:HE,getSet:GE,getShotScene:lw,getTimelineDoc:QE,getTimelineDocRev:CE,get lastExportQuota(){return ys},get lastExportStored(){return vs},get lastExportTimes(){return Us},libraryUsage:oT,listAgentModels:AT,listAssetLibrary:kT,listAssetLibraryCategories:OT,listAssets:eT,listBlenderDevices:OE,listBrands:VT,listCanvases:xE,listDirectorReferences:rT,listGenerators:iE,listJobs:uE,listLibrary:iT,listModelCategories:RT,listModelLibrary:bT,listMyLuts:BT,listRemoteMissions:NE,listSeries:zE,listSkills:jE,listTempUploads:gE,listTextTemplates:NT,listTransitions:zT,listUserFonts:MT,locateObject:lT,mapBlenderScript:gw,mapHd:mw,me:rE,mediaPeaks:Iw,mediaProxy:Pw,mocapRegionStatus:nE,modelReadUrl:EE,motionAgent:Uw,motionAgentPrice:xw,motionUsage:hT,multicamSync:gT,pinToLibrary:aT,pluginAssetUrls:TE,pollJob:cE,prewarmCount:Vh,processAudio:bw,productionAction:vT,publishLibraryModel:PT,putSigned:vE,quoteProduction:yT,reportClient:$w,requestTempUpload:mE,requestUpload:Dh,resolveMapPlaces:_w,rigAgent:jw,rigAgentPrice:Fw,runGenerator:aE,saveBrand:UT,saveCanvas:bE,saveLut:jT,saveModelThumbnail:ST,savePersonMatte:iw,saveProjectContext:tT,saveRotoMask:aw,saveSeries:WE,saveSet:KE,saveShotScene:uw,saveTimelineDoc:JE,sendDirector:ET,shareModelAsset:HT,shotAgentInfo:WT,shotInbetween:Ow,shotInbetweenInfo:kw,shotLivePoll:ZT,shotLiveResult:rw,shotMissionCancel:XT,shotMissionQuote:JT,shotMissionTurn:QT,shotRemotePoll:YT,shotRemoteReport:sw,signFrameChunks:Rw,signOutput:wE,signTempUpload:_E,spliceRegionsMedia:hE,stabilizeClip:Aw,timelineAgent:uT,timelineAgentPrice:pT,timelineLivePoll:ew,timelineLiveProgress:tw,timelineLiveResult:nw,trimMedia:lE,updateSkill:$E,uploadFile:pE},Symbol.toStringTag,{value:"Module"}));export{_E as $,UT as A,jE as B,$E as C,BE as D,qE as E,_T as F,vT as G,yT as H,TT as I,rT as J,sT as K,AT as L,ET as M,nT as N,wT as O,tT as P,uE as Q,Uw as R,xw as S,HT as T,iT as U,oT as V,xd as W,cT as X,bT as Y,eT as Z,DT as _,cE as a,ME as a$,mE as a0,vE as a1,gE as a2,yE as a3,BT as a4,hT as a5,Tw as a6,ww as a7,vw as a8,Ew as a9,Bd as aA,Zw as aB,ew as aC,vs as aD,nw as aE,tw as aF,CE as aG,SE as aH,kd as aI,Jw as aJ,Qw as aK,Lw as aL,Us as aM,ys as aN,Aw as aO,bw as aP,Xw as aQ,wi as aR,aI as aS,iI as aT,oI as aU,kE as aV,OE as aW,NE as aX,VE as aY,DE as aZ,LE as a_,fT as aa,nI as ab,eI as ac,tI as ad,NT as ae,yw as af,mw as ag,gw as ah,kT as ai,Su as aj,gT as ak,$w as al,Gw as am,Ww as an,Kw as ao,EE as ap,zT as aq,Pw as ar,$T as as,hw as at,dw as au,fw as av,pw as aw,pT as ax,uT as ay,Yw as az,hE as b,FE as b0,UE as b1,ln as b2,$t as b3,vt as b4,ke as b5,xe as b6,to as b7,Yd as b8,Fu as b9,KT as bA,ZT as bB,rw as bC,HE as bD,zE as bE,WE as bF,GE as bG,nE as bH,qT as bI,jT as bJ,TE as bK,aw as bL,cw as bM,_w as bN,iw as bO,Od as bP,MT as bQ,xT as bR,LT as bS,ow as bT,lT as bU,hI as bV,_n as ba,Vu as bb,Mu as bc,st as bd,yp as be,sI as bf,uI as bg,lI as bh,iE as bi,uw as bj,lw as bk,RT as bl,ST as bm,CT as bn,PT as bo,RE as bp,XT as bq,QT as br,YT as bs,sw as bt,JT as bu,KE as bv,Fw as bw,jw as bx,GT as by,WT as bz,dT as c,mT as d,oE as e,JE as f,QE as g,XE as h,AE as i,IE as j,bE as k,YE as l,ZE as m,dE as n,Ud as o,aT as p,xE as q,aE as r,wE as s,PE as t,pE as u,cI as v,tE as w,lE as x,VT as y,FT as z};
|
|
3156
|
+
*/function Gv(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new L(N.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Kv{convertValue(e,t="none"){switch(St(e)){case 0:return null;case 1:return e.booleanValue;case 2:return se(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Rt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw H(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return mr(e,((s,o)=>{r[s]=this.convertValue(o,t)})),r}convertVectorValue(e){var t,r,s;const o=(s=(r=(t=e.fields)===null||t===void 0?void 0:t[xi].arrayValue)===null||r===void 0?void 0:r.values)===null||s===void 0?void 0:s.map((a=>se(a.doubleValue)));return new wt(o)}convertGeoPoint(e){return new Tt(se(e.latitude),se(e.longitude))}convertArray(e,t){return(e.values||[]).map((r=>this.convertValue(r,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const r=Cs(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(sr(e));default:return null}}convertTimestamp(e){const t=bt(e);return new ae(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=te.fromString(e);ne(ah(r),9688,{name:e});const s=new ir(r.get(1),r.get(3)),o=new F(r.popFirst(5));return s.isEqual(t)||nt(`Document ${o} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),o}}class Hn{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class jt extends Ch{constructor(e,t,r,s,o,a){super(e,t,r,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=o}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new ts(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const r=this._document.data.field(Ph("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new L(N.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=jt._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}jt._jsonSchemaVersion="firestore/documentSnapshot/1.0",jt._jsonSchema={type:ce("string",jt._jsonSchemaVersion),bundleSource:ce("string","DocumentSnapshot"),bundleName:ce("string"),bundle:ce("string")};class ts extends jt{data(e={}){return super.data(e)}}class un{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new Hn(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((r=>{e.call(t,new ts(this._firestore,this._userDataWriter,r.key,r,new Hn(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new L(N.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=(function(s,o){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map((u=>{const l=new ts(s._firestore,s._userDataWriter,u.doc.key,u.doc,new Hn(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);return u.doc,{type:"added",doc:l,oldIndex:-1,newIndex:a++}}))}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter((u=>o||u.type!==3)).map((u=>{const l=new ts(s._firestore,s._userDataWriter,u.doc.key,u.doc,new Hn(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);let d=-1,p=-1;return u.type!==0&&(d=a.indexOf(u.doc.key),a=a.delete(u.doc.key)),u.type!==1&&(a=a.add(u.doc),p=a.indexOf(u.doc.key)),{type:Qv(u.type),doc:l,oldIndex:d,newIndex:p}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new L(N.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=un._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=mo.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach((o=>{o._document!==null&&(t.push(o._document),r.push(this._userDataWriter.convertObjectMap(o._document.data.value.mapValue.fields,"previous")),s.push(o.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function Qv(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return H(61501,{type:n})}}un._jsonSchemaVersion="firestore/querySnapshot/1.0",un._jsonSchema={type:ce("string",un._jsonSchemaVersion),bundleSource:ce("string","QuerySnapshot"),bundleName:ce("string"),bundle:ce("string")};class kh extends Kv{constructor(e){super(),this.firestore=e}convertBytes(e){return new Be(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Ce(this.firestore,null,t)}}function Jv(n,...e){var t,r,s;n=Le(n);let o={includeMetadataChanges:!1,source:"default"},a=0;typeof e[a]!="object"||wu(e[a])||(o=e[a++]);const u={includeMetadataChanges:o.includeMetadataChanges,source:o.source};if(wu(e[a])){const v=e[a];e[a]=(t=v.next)===null||t===void 0?void 0:t.bind(v),e[a+1]=(r=v.error)===null||r===void 0?void 0:r.bind(v),e[a+2]=(s=v.complete)===null||s===void 0?void 0:s.bind(v)}let l,d,p;if(n instanceof Ce)d=Xr(n.firestore,Xi),p=Eo(n._key.path),l={next:v=>{e[a]&&e[a](Xv(d,n,v))},error:e[a+1],complete:e[a+2]};else{const v=Xr(n,xs);d=Xr(v.firestore,Xi),p=v._query;const E=new kh(d);l={next:C=>{e[a]&&e[a](new un(d,E,v,C))},error:e[a+1],complete:e[a+2]},Gv(n._query)}return(function(E,C,V,M){const k=new Mv(M),q=new Ev(C,k,V);return E.asyncQueue.enqueueAndForget((async()=>gv(await mu(E),q))),()=>{k.Ou(),E.asyncQueue.enqueueAndForget((async()=>_v(await mu(E),q)))}})($v(d),p,u,l)}function Xv(n,e,t){const r=t.docs.get(e._key),s=new kh(n);return new jt(n,s,e._key,r,new Hn(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(s){En=s})(yn),ln(new $t("firestore",((r,{instanceIdentifier:s,options:o})=>{const a=r.getProvider("app").getImmediate(),u=new Xi(new Zg(r.getProvider("auth-internal")),new n_(a,r.getProvider("app-check-internal")),(function(d,p){if(!Object.prototype.hasOwnProperty.apply(d.options,["projectId"]))throw new L(N.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ir(d.options.projectId,p)})(a,s),a);return o=Object.assign({useFetchStreams:t},o),u._setSettings(o),u}),"PUBLIC").setMultipleInstances(!0)),vt(bc,Rc,e),vt(bc,Rc,"esm2017")})();const Yv=typeof location<"u"&&/^(localhost|127\.0\.0\.1)$/.test(location.hostname),Zv={apiKey:"AIzaSyDzUGG3LEJbx0XccOWH2xEhZcttMw_238E",authDomain:Yv?"mrcong-d8b07.firebaseapp.com":location.host,projectId:"mrcong-d8b07",storageBucket:"mrcong-d8b07.firebasestorage.app",messagingSenderId:"926811951160",appId:"1:926811951160:web:acdfdd0941e12be35d96cd"},Oh=yp()[0]||Uu(Zv),rt=Qg(Oh),eE=Bv(Oh),lI=(async()=>{if(typeof location>"u")return;const n=/[#&]t=([^&]+)/.exec(location.hash);if(n){history.replaceState(null,"",location.pathname+location.search);try{await km(rt,decodeURIComponent(n[1]))}catch(e){console.warn("[auth] sso handoff failed:",e?.code||e?.message)}}})();async function hI(){const n=new Xe;n.addScope("email"),n.addScope("profile"),n.setCustomParameters({prompt:"select_account"});try{return await rg(rt,n)}catch(e){const t=e?.code||"";if(["auth/popup-blocked","auth/popup-closed-by-user","auth/cancelled-popup-request","auth/operation-not-supported-in-this-environment"].includes(t))return await ug(rt,n),null;throw e}}const wi={code:null};hg(rt).catch(n=>{wi.code=n?.code||n?.message||"unknown",console.warn("[auth] redirect result:",wi.code),document.dispatchEvent(new CustomEvent("clipoox:auth-error",{detail:wi.code}))});const dI=(n,e)=>Nm(rt,n.trim(),e),fI=n=>Dm(rt,n.trim()),pI=()=>Lm(rt),mI=n=>xm(rt,n);async function tE(){const n=rt.currentUser;return n?n.getIdToken():null}function gI(n,e,t){return Jv(jv(eE,"users",n),r=>{!r.exists()&&!r.metadata.fromCache&&t?.();const s=r.data()||{},o=typeof s.planCredits=="number"?s.planCredits:0,a=typeof s.extraCredits=="number"?s.extraCredits:0,u=typeof s.credits=="number"?s.credits:0,l=o===0&&a===0&&!s.planExpiresAt;e({credits:l?u:Math.round((o+a)*100)/100,planCredits:o,extraCredits:a,activePlan:s.activePlan||"free",planExpiresAt:typeof s.planExpiresAt?.toMillis=="function"?s.planExpiresAt.toMillis():typeof s.planExpiresAt=="number"?s.planExpiresAt:null})},()=>e({credits:0,planCredits:0,extraCredits:0,activePlan:"free"}))}async function b(n){const e=await jd(n).catch(r=>{throw Object.assign(new Error(De("Mất kết nối khi đang chờ kết quả từ máy chủ. Hãy thử lại.")),{status:n.status,code:r?.code||"reply_lost"})}),t=n.ok&&typeof e.error=="string"&&typeof e.status=="number"&&e.status>=400;if(!n.ok||t){const r=t?e.status:n.status,s=new Error(e.error||`${n.status} ${n.statusText}`);throw s.status=r,s.code=e.code,s.data=e,s}return e}async function kt(){const n=await tE();return n?{"X-Firebase-Token":n}:{}}const U=async n=>fetch(n,{headers:await kt()}),nE=()=>U("/api/mocap/hy/status").then(n=>n.ok?n.json():null),O=async(n,e,t="POST")=>fetch(n,{method:t,headers:{"Content-Type":"application/json","Accept-Language":Yn(),...await kt()},body:JSON.stringify(n.startsWith("/api/agent")||n.startsWith("/api/shot-agent")?{...e,locale:Yn()}:e)}),rE=()=>U("/api/me").then(n=>b(n)),sE=()=>U("/api/health").then(n=>b(n)),iE=()=>U("/api/generate").then(n=>b(n)).then(n=>n.generators),oE=(n,e)=>O("/api/generate/estimate",{generator:n,inputs:e}).then(t=>b(t)),aE=(n,e,t)=>O("/api/generate",{generator:n,inputs:e,canvasId:t}).then(r=>b(r)),cE=(n,e=!1)=>{const t=new URL(`/api/jobs/${n}`,window.location.origin);return e&&t.searchParams.set("poll","1"),U(t.toString()).then(r=>b(r)).then(r=>r.job)},uE=(n,e=50)=>{const t=new URL("/api/jobs",window.location.origin);return n&&t.searchParams.set("canvasId",n),t.searchParams.set("limit",String(e)),U(t.toString()).then(r=>b(r)).then(r=>r.jobs)},lE=(n,e,t)=>O("/api/media/trim",{videoUrl:n,start:e,end:t}).then(r=>b(r)),hE=(n,e)=>O("/api/media/region-splice",{sourceUrl:n,regions:e}).then(t=>b(t)),dE=(n,e)=>O("/api/media/frame",{videoUrl:n,...e}).then(t=>b(t)),Dh=(n,e,t,r)=>O("/api/uploads/sign",{filename:n,contentType:e,kind:t,...r?{rightsConfirmed:!0}:{}}).then(s=>b(s));function fE(n){return new Promise(e=>{const t=document.createElement(n.type.startsWith("audio/")?"audio":"video"),r=URL.createObjectURL(n),s=a=>{clearTimeout(o),t.onloadedmetadata=t.onerror=null,t.removeAttribute("src"),t.load(),URL.revokeObjectURL(r),e(a)},o=setTimeout(()=>s(null),1e4);t.preload="metadata",t.onloadedmetadata=()=>s(Number.isFinite(t.duration)?t.duration:null),t.onerror=()=>s(null),t.src=r})}async function pE(n,e,t,r=!1){const s=Ld(n)||t==="audio"||t==="voice";if(s&&!r&&!await Ud([n.name]))throw new Error(De("Cần xác nhận quyền sử dụng bản nhạc trước khi tải lên"));if(/^(video|audio)\//.test(n.type)&&typeof document<"u"){const a=await fE(n);if(a!==null&&a>Cd+.001)throw new Error(De("Video/âm thanh đầu vào tối đa 20 phút"))}const o=await Dh(n.name,n.type||"application/octet-stream",t,s);return await new Promise((a,u)=>{const l=new XMLHttpRequest;l.open("PUT",o.uploadUrl),Object.entries(o.headers).forEach(([d,p])=>l.setRequestHeader(d,p)),l.upload.onprogress=d=>{d.lengthComputable&&e&&e(Math.round(d.loaded/d.total*100))},l.onload=()=>l.status>=200&&l.status<300?a():u(new Error(`upload failed: ${l.status}`)),l.onerror=()=>u(new Error("upload network error")),l.send(n)}),{url:o.readUrl,gcsUri:o.gcsUri,...o.rightsConfirmed?{rightsConfirmed:o.rightsConfirmed}:{}}}const mE=(n,e,t)=>O("/api/uploads/sign",{filename:n,contentType:e,temp:t}).then(r=>b(r)),gE=()=>U("/api/uploads/temp").then(n=>b(n)),_E=n=>O("/api/uploads/temp/sign",{gcsUri:n}).then(e=>b(e)),yE=n=>O("/api/uploads/temp",n,"DELETE").then(e=>b(e));function vE(n,e,t,r){return new Promise((s,o)=>{const a=new XMLHttpRequest;a.open("PUT",n.uploadUrl),Object.entries(n.headers).forEach(([u,l])=>a.setRequestHeader(u,l)),a.upload.onprogress=u=>{u.lengthComputable&&t?.(u.loaded,u.total)},a.onload=()=>a.status>=200&&a.status<300?s():o(new Error(`upload failed: ${a.status}`)),a.onerror=()=>o(new Error("upload network error")),a.onabort=()=>o(Object.assign(new Error(De("Đã huỷ gửi tạm")),{name:"AbortError"})),r?.addEventListener("abort",()=>a.abort(),{once:!0}),a.send(e)})}const EE=n=>O("/api/uploads/model-url",{gcsUri:n}).then(e=>b(e)).then(e=>e.url),TE=n=>O("/api/plugins/asset-urls",{uris:n}).then(e=>b(e)).then(e=>e.urls),wE=n=>O("/api/outputs/sign",n).then(e=>b(e)).then(e=>e.url),IE=(n={})=>O("/api/canvases",n).then(e=>b(e)).then(e=>e.canvas),AE=n=>U(`/api/canvases/${n}`).then(e=>b(e)).then(e=>e.canvas),bE=(n,e)=>O(`/api/canvases/${n}`,e,"PUT").then(t=>b(t)),RE=(n,e)=>U(`/api/canvases/${encodeURIComponent(n)}/shot-rev/${encodeURIComponent(e)}`).then(t=>b(t)),SE=n=>U(`/api/canvases/${encodeURIComponent(n)}/timeline-rev`).then(e=>b(e)),CE=n=>U(`/api/timeline-docs/${encodeURIComponent(n)}/rev`).then(e=>b(e)),PE=n=>O(`/api/canvases/${n}`,{},"DELETE").then(e=>b(e)),kE=n=>O("/api/blender/device/approve",{userCode:n}).then(e=>b(e)),OE=()=>U("/api/blender-remote/devices").then(n=>b(n)),DE=n=>O("/api/blender-remote/missions",n).then(e=>b(e)),NE=(n=8)=>U(`/api/blender-remote/missions?limit=${n}`).then(e=>b(e)),VE=n=>U(`/api/blender-remote/missions/${encodeURIComponent(n)}`).then(e=>b(e)),ME=n=>O("/api/blender-remote/vcam/session",{deviceId:n}).then(e=>b(e)),xE=n=>O(`/api/blender-remote/missions/${encodeURIComponent(n)}/cancel`,{}).then(e=>b(e)),LE=n=>U(`/api/canvases${n?`?limit=${n}`:""}`).then(e=>b(e)).then(e=>e.canvases),UE=(n,e)=>O(`/api/canvases/${n}/archive`,{archived:e}).then(t=>b(t)),FE=n=>O(`/api/canvases/${n}/duplicate`,{}).then(e=>b(e)).then(e=>e.canvas),jE=()=>U("/api/skills").then(n=>b(n)),BE=n=>O("/api/skills",n).then(e=>b(e)).then(e=>e.skill),$E=(n,e)=>O(`/api/skills/${n}`,e,"PUT").then(t=>b(t)).then(t=>t.skill),qE=n=>O(`/api/skills/${n}`,{},"DELETE").then(e=>b(e)),zE=()=>U("/api/series").then(n=>b(n)),HE=n=>U(`/api/series/${encodeURIComponent(n)}`).then(e=>b(e)),WE=(n,e)=>O(`/api/series/${encodeURIComponent(n)}`,e,"PUT").then(t=>b(t)),GE=n=>U(`/api/sets/${encodeURIComponent(n)}`).then(e=>b(e)),KE=(n,e,t)=>O(`/api/sets/${encodeURIComponent(n)}`,{name:e,recipe:t},"PUT").then(r=>b(r)),QE=async n=>{const e=await U(`/api/timeline-docs/${encodeURIComponent(n)}`);return e.status===404?null:(await b(e)).timeline},JE=(n,e)=>O(`/api/timeline-docs/${encodeURIComponent(n)}`,e,"PUT").then(t=>b(t)),XE=async(n,e,t)=>{const r=await O(`/api/timeline-docs/${encodeURIComponent(n)}/copy`,{id:e,nodeId:t.nodeId,...t.canvasId?{canvasId:t.canvasId}:{}});return r.status===404?!1:(await b(r),!0)},YE=n=>U(`/api/design-docs/${encodeURIComponent(n)}`).then(e=>b(e)).then(e=>e.design),ZE=n=>U(`/api/design-docs/${encodeURIComponent(n)}/rev`).then(e=>b(e)),eT=(n,e)=>O(`/api/design-docs/${encodeURIComponent(n)}`,e,"PUT").then(t=>b(t)),tT=()=>U("/api/canvas-inbox").then(n=>b(n)),nT=n=>O("/api/canvas-inbox/consume",{ids:n}).then(e=>b(e)),rT=(n,e,t="upload")=>U("/api/assets?"+new URLSearchParams({source:t,...n?{kind:n}:{},...e?{cursor:e}:{}})).then(r=>b(r)),sT=(n,e)=>O("/api/director/"+encodeURIComponent(n)+"/context",e,"PUT").then(t=>b(t)),iT=n=>U(`/api/director/${encodeURIComponent(n)}`).then(e=>b(e)),oT=n=>U(`/api/director-references/${encodeURIComponent(n)}`).then(e=>b(e)),aT=(n,e,t,r)=>O(`/api/director-references/${encodeURIComponent(n)}`,{gcsUri:e,label:t,role:r}).then(s=>b(s)),cT=n=>U(`/api/library${n?`?kind=${encodeURIComponent(n)}`:""}`).then(e=>b(e)).then(e=>e.assets),uT=()=>U("/api/library/usage").then(n=>b(n)),lT=n=>O("/api/library/pin",n).then(e=>b(e)),hT=n=>O(`/api/library/${encodeURIComponent(n)}`,{},"DELETE").then(e=>b(e)),dT=(n,e)=>O(`/api/timeline-agent/${encodeURIComponent(n)}`,e).then(t=>b(t)),fT=(n,e)=>O(`/api/timeline-agent/${encodeURIComponent(n)}/locate-object`,e).then(t=>b(t)),pT=n=>O("/api/timeline-agent/usage",{events:n}).then(e=>b(e)),mT=n=>O("/api/timeline-agent/signal",n).then(e=>b(e));async function gT(n,e,t,r){const s=`/api/timeline-agent/${encodeURIComponent(n)}/describe`;if(!r)return O(s,{items:e,locale:t}).then(v=>b(v));const o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:`${rs}, application/json;q=0.9`,"Accept-Language":Yn(),...await kt()},body:JSON.stringify({items:e,locale:t})});if(!o.ok||!(o.headers.get("Content-Type")||"").startsWith(rs)||!o.body)return b(o);const a=o.body.pipeThrough(new TextDecoderStream).getReader();let u="",l=null;const d=v=>{if(!v.trim())return;const E=JSON.parse(v);if(E&&typeof E=="object"&&E.progress)try{r(E.progress)}catch{}else l=E};for(;;){const{value:v,done:E}=await a.read();if(E)break;u+=v;let C;for(;(C=u.indexOf(`
|
|
3157
|
+
`))>=0;)d(u.slice(0,C)),u=u.slice(C+1)}d(u);const p=l||{};if(typeof p.error=="string"&&typeof p.status=="number"&&p.status>=400){const v=new Error(p.error);throw v.status=p.status,v.code=p.code,v.data=p,v}if(!l)throw new Error(De("Phân tích bị ngắt giữa chừng. Hãy thử lại."));return l}async function _T(n,e,t={}){const r=await fetch(`/api/transcribe/${encodeURIComponent(n)}`,{method:"POST",signal:t.signal,headers:{"Content-Type":"application/json",Accept:`${rs}, application/json;q=0.9`,"Accept-Language":Yn(),...await kt()},body:JSON.stringify({...e,terms:t.terms||"",locale:t.locale||Yn()})});if(!r.ok||!(r.headers.get("Content-Type")||"").startsWith(rs)||!r.body)return b(r).then(d=>d.item);const s=r.body.pipeThrough(new TextDecoderStream).getReader();let o="",a=null;const u=d=>{if(!d.trim())return;const p=JSON.parse(d);if(p&&typeof p=="object"&&p.progress)try{t.onProgress?.(p.progress)}catch{}else a=p};for(;;){const{value:d,done:p}=await s.read();if(p)break;o+=d;let v;for(;(v=o.indexOf(`
|
|
3158
|
+
`))>=0;)u(o.slice(0,v)),o=o.slice(v+1)}u(o);const l=a||{};if(typeof l.error=="string"&&typeof l.status=="number"&&l.status>=400){const d=new Error(l.error);throw d.status=l.status,d.code=l.code,d}if(!l.item)throw new Error(De("Chép lời bị ngắt giữa chừng. Hãy thử lại."));return l.item}const yT=(n,e,t=0)=>U(`/api/timeline-agent/plan-price?model=${encodeURIComponent(n)}&chars=${Math.round(e)}&refs=${t}`).then(r=>b(r)),vT=(n,e=!0)=>U(`/api/timeline-agent/describe-price?audioOnly=${e?1:0}${n&&n>0?`&duration=${Math.ceil(n)}`:""}`).then(t=>b(t)),ET=(n,e,t)=>O("/api/timeline/multicam/sync",{canvasId:n,items:e,...t?{main:t}:{}}).then(r=>b(r)),Ls=(n,e)=>`/api/production/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,TT=(n,e)=>U(Ls(n,e)).then(t=>b(t)),wT=(n,e,t)=>O(`${Ls(n,e)}/quote`,{imageGenerator:t}).then(r=>b(r)),IT=(n,e,t,r)=>O(`${Ls(n,e)}/${t}`,{revision:r}).then(s=>b(s)),AT=(n,e,t,r,s,o,a,u)=>O(`/api/director/${encodeURIComponent(n)}`,{input:e,requestId:t,referenceIds:r,defaults:s,...o?{skill:o.id?{id:o.id}:{title:o.title,instruction:o.instruction}}:{},...a?{model:a}:{},...u?{aspectRatio:u}:{}}).then(l=>b(l)),bT=(n,e,t,r)=>O(`${Ls(n,e)}/accept`,{revision:t,totalCredits:r}).then(s=>b(s)),RT=n=>O(`/api/director/${encodeURIComponent(n)}`,{},"DELETE").then(e=>b(e)),ST=(n,e,t,r)=>O("/api/agent",{messages:n.map(({role:s,content:o})=>({role:s,content:o})),canvas:e,model:t||void 0,defaults:r}).then(s=>b(s)),CT=()=>U("/api/agent/models").then(n=>n.json()),PT=(n="published",e)=>U("/api/model-library?"+new URLSearchParams({status:n,...e?{cursor:e}:{}})).then(t=>b(t)),kT=()=>U("/api/model-library/categories").then(n=>b(n)),OT=(n,e)=>O("/api/model-library/"+encodeURIComponent(n)+"/thumbnail",{gcsUri:e}).then(t=>b(t)),DT=n=>O("/api/model-library",n).then(e=>b(e)),NT=(n,e)=>O("/api/model-library/"+encodeURIComponent(n),{status:e},"PATCH").then(t=>b(t)),VT=(n={})=>U("/api/asset-library?"+new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0&&e!=="").map(([e,t])=>[e,String(t)]))).then(e=>b(e)),MT=n=>U("/api/asset-library/categories"+(n?"?kind="+n:"")).then(e=>b(e)),xT=n=>U("/api/asset-library/"+encodeURIComponent(n)).then(e=>b(e)).then(e=>e.item),LT=(n="published")=>U("/api/text-templates?"+new URLSearchParams({status:n})).then(e=>b(e)),UT=()=>U("/api/brands").then(n=>b(n)),FT=()=>U("/api/fonts").then(n=>b(n)),jT=n=>O("/api/fonts",n).then(e=>b(e)),BT=n=>O("/api/fonts/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),$T=(n,e)=>O("/api/brands"+(e?"/"+encodeURIComponent(e):""),n,e?"PUT":"POST").then(t=>b(t)),qT=n=>O("/api/brands/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),zT=n=>O("/api/luts",n).then(e=>b(e)),HT=()=>U("/api/luts").then(n=>b(n)),WT=n=>O("/api/luts/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),GT=n=>U("/api/luts/"+encodeURIComponent(n)).then(e=>b(e)),KT=(n="published")=>U("/api/transitions?"+new URLSearchParams({status:n})).then(e=>b(e)),QT=n=>O("/api/model-library/share",n).then(e=>b(e)),JT=()=>U("/api/shot-agent").then(n=>b(n)),XT=(n,e,t)=>O("/api/shot-agent/estimate",{scene:n,messages:e,model:t}).then(r=>b(r)),YT=(n,e,t,r)=>O("/api/shot-agent",{scene:n,messages:e,requestId:t,model:r}).then(s=>b(s)),ZT=n=>O("/api/shot-agent/mission/turn",n).then(e=>b(e)),ew=(n,e="build")=>O("/api/shot-agent/mission/quote",{model:n,kind:e}).then(t=>b(t)),tw=n=>O("/api/shot-agent/mission/cancel",{missionId:n}).then(e=>b(e)),nw=n=>O("/api/shot-agent/remote/poll",n).then(e=>b(e)),rw=n=>O("/api/shot-agent/live/poll",n).then(e=>b(e)),sw=n=>O("/api/timeline-live/poll",n).then(e=>b(e)),iw=(n,e)=>O(`/api/timeline-live/${encodeURIComponent(n)}/progress`,e).then(t=>b(t)),ow=(n,e)=>O(`/api/timeline-live/${encodeURIComponent(n)}/result`,e).then(t=>b(t)),aw=(n,e)=>O(`/api/shot-agent/live/${encodeURIComponent(n)}/result`,e).then(t=>b(t)),cw=(n,e)=>O(`/api/shot-agent/remote/missions/${encodeURIComponent(n)}/status`,e).then(t=>b(t)),uw=n=>O("/api/person-mattes",{data:n}).then(e=>b(e)).then(e=>e.ref),lw=async n=>{const e=await U(`/api/person-mattes/${n}`);return e.ok||await b(e),e.text()},hw=n=>O("/api/roto-masks",{data:n}).then(e=>b(e)).then(e=>e.ref),dw=async n=>{const e=await U(`/api/roto-masks/${n}`);return e.ok||await b(e),e.text()},fw=n=>O("/api/shot-scenes",{data:n}).then(e=>b(e)).then(e=>e.ref),pw=async n=>{const e=await U(`/api/shot-scenes/${n}`);return e.ok||await b(e),e.text()},mw=n=>O("/api/color-agent/price",n).then(e=>b(e)),gw=(n,e)=>O(`/api/color-agent/${encodeURIComponent(n)}`,e).then(t=>b(t)),_w=n=>O("/api/broll-prompt/price",n).then(e=>b(e)),yw=(n,e)=>O(`/api/broll-prompt/${encodeURIComponent(n)}`,e).then(t=>b(t)),vw=n=>O("/api/geo/hd",n).then(e=>b(e)),Ew=async n=>{const e=await O("/api/geo/blender-city",n);if(!e.ok)throw await b(e),Error("Blender city failed");return{script:await e.text(),buildings:Number(e.headers.get("x-city-buildings"))||0}},Tw=n=>O("/api/geo/resolve",{ops:n}).then(e=>b(e)),ww=(n,e=!0,t="vi")=>U(`/api/geo/search?${new URLSearchParams({q:n,shape:e?"1":"0",lang:t})}`).then(r=>b(r)).then(r=>r.results),Iw=n=>O("/api/caption-keywords/price",{words:n}).then(e=>b(e)),Aw=(n,e,t)=>O(`/api/caption-keywords/${encodeURIComponent(n)}`,{words:e,locale:t}).then(r=>b(r)),bw=(n,e)=>O("/api/caption-translate/price",{lines:n,target:e}).then(t=>b(t)),Rw=(n,e,t)=>O(`/api/caption-translate/${encodeURIComponent(n)}`,{lines:e,target:t}).then(r=>b(r)),Sw=n=>O("/api/media-peaks",{url:n}).then(e=>b(e)),Cw=n=>O("/api/stabilize",n).then(e=>b(e)),Pw=n=>O("/api/audio-tools",n).then(e=>b(e)),kw=n=>O("/api/media/frames/sign",{count:n}).then(e=>b(e)).then(e=>e.chunks);let Ow=null;const Nh=()=>Ow??=U("/api/media/render-target").then(n=>n.ok?n.json():{}).then(n=>({url:n?.url||"",gpu:n?.gpu!==!1})).catch(()=>({url:"",gpu:!1})),vr=()=>Nh().then(n=>n.url),Vh=n=>n<=30?1:Math.min(8,Math.ceil(n/10));function Dw(n){vr().then(e=>{if(e)for(let t=0;t<Vh(n);t++)fetch(`${e}/api/health`,{cache:"no-store"}).catch(()=>{})}).catch(()=>{})}async function Nw(n,e){const t=await vr();for(let r=0;;r++){const s=await fetch(`${t}/api/media/proxy`,{method:"POST",signal:e,headers:{"Content-Type":"application/json",...await kt()},body:JSON.stringify({gcsUri:n})});if(s.status===429&&r<6){await Lo(1e4,e);continue}const o=await b(s),a=o.preview?.url&&o.preview.gcsUri?{url:o.preview.url,gcsUri:o.preview.gcsUri}:null;return{proxy:o.needed&&o.url&&o.gcsUri?{url:o.url,gcsUri:o.gcsUri,fps:Number(o.fps),width:Number(o.width),height:Number(o.height),...o.alpha===!0?{alpha:!0}:{}}:null,preview:a}}}let Au=null;const Vw=()=>Au??=vr().then(async n=>fetch(`${n}/api/shot-inbetween`,{headers:await kt()})).then(n=>b(n)).catch(()=>(Au=null,{available:!1,maxSeconds:0}));async function Mw(n,e){const t=await vr();for(let r=0;;r++){const s=await fetch(`${t}/api/shot-inbetween`,{method:"POST",signal:e,headers:{"Content-Type":"application/json",...await kt()},body:JSON.stringify(n)});if(s.status===429&&r<6){await Lo(5e3,e);continue}return b(s)}}const bu=[5,10,15,20,30,30,30,30,30,30].map(n=>n*1e3),Lo=(n,e)=>new Promise((t,r)=>{const s=setTimeout(t,n);e?.addEventListener("abort",()=>{clearTimeout(s),r(new DOMException("Aborted","AbortError"))},{once:!0})});function Mh(n){try{const e=n.headers.get("X-Clipoox-Review"),t=e?JSON.parse(decodeURIComponent(e)):null;return t&&Array.isArray(t.checks)&&Array.isArray(t.platforms)?t:null}catch{return null}}const Ut=.9;async function xw(n,e){const t=Number(n.headers.get("Content-Length"))||0;if(!n.body||!t)return n.blob();const r=n.body.getReader(),s=[];let o=0;for(;;){const{done:a,value:u}=await r.read();if(a)break;s.push(u),o+=u.length,e(Math.min(1,o/t))}return new Blob(s,{type:n.headers.get("Content-Type")||"video/mp4"})}let Us=null,ys=null,vs=null;const xh=n=>{const e=/^(\d+)\/(\d+)$/.exec(n.headers.get("X-Clipoox-Export-Quota")||"");return e?{used:+e[1],limit:+e[2]}:null};async function Lw(n,e,t,r,s){if(!n.body)throw new Error("Export failed (empty reply)");const o=n.body.getReader(),a=Fd(),u=[];let l=0,d=0,p=null,v=null,E=0;for(;;){const{done:C,value:V}=await o.read();if(C)break;for(const M of a.push(V))if(M.type==="progress")t?.(Ut*M.value);else if(M.type==="review"){const k=M.review;p=k&&Array.isArray(k.checks)&&Array.isArray(k.platforms)?k:null}else if(M.type==="timings")v=M.timings;else{if(M.type==="error")throw Object.assign(new Error(Uo(M.error)),{status:M.status});M.type==="file"?(l=M.size,E=performance.now(),e?.("download")):M.type==="stored"?(vs={gcsUri:M.gcsUri,size:M.size},l=M.size,E=performance.now()):M.type==="data"&&(u.push(M.chunk),d+=M.chunk.length,t?.(Ut+(1-Ut)*(l?Math.min(1,d/l):0)))}}if(!a.complete)throw new Error("Export interrupted — please try again");return s&&(Us={totalMs:Math.round(performance.now()-s.start),framesMs:Math.round(s.posted-s.start),renderMs:Math.round((E||performance.now())-s.posted),downloadMs:E?Math.round(performance.now()-E):0,server:v}),v&&s&&console.info("[export] timings",{server:v,browser:{frames_ms:Math.round(s.posted-s.start),request_to_file_ms:Math.round(E-s.posted),download_ms:Math.round(performance.now()-E),total_ms:Math.round(performance.now()-s.start),bytes:l}}),r?.(p),new Blob(vs?[]:u,{type:"video/mp4"})}function Uo(n){const e=/^Media exceeds (\d+) MB per export/.exec(n||"");if(e)return De("Video, ảnh và nhạc gốc trong Timeline nặng hơn {0} MB cho một lần xuất. Hãy cắt bớt hoặc bỏ các clip dài không dùng tới rồi xuất lại.",[e[1]]);const t=/^Media link missing: “(.*)” \(([\d.]+)s\)/.exec(n||"");return t?De("Lớp “{0}” (giây {1}) chưa có file media. Mở lớp đó chọn lại media, hoặc xoá lớp rồi xuất lại.",[t[1],t[2]]):/^MP4 render failed|Error opening input|Stream #\d|Input #\d|\/tmp\/canvas-/.test(n||"")?(console.warn("[export] render failed:",n),De("Không xuất được video lần này. Nếu bạn vừa sửa Timeline trong lúc xuất, hãy chờ lưu xong rồi bấm xuất lại. Nếu vẫn lỗi, hãy báo Clipoox.")):n||""}function Lh(n){return n.code==="export_quota"?Object.assign(new Error(De("Bạn đã dùng hết lượt xuất video tháng này")),{planGate:{kind:"count",plan:n.plan||"free",offer:n.offer??null,seconds:0,limit:Number(n.limit)||0,used:Number(n.used)||0,resetAt:Number(n.resetAt)||0}}):n.code==="plan_required"&&n.offer?Object.assign(new Error(De("Cần nâng cấp gói để xuất video dài hơn")),{planGate:{kind:"length",plan:n.plan||"free",offer:n.offer,seconds:Number(n.seconds)||0}}):null}let Je=[];const Uw=n=>n.map(e=>e.replace(/[^A-Za-z0-9 _.:-]/g,"").slice(0,48)).filter(Boolean).slice(0,16).join(",");async function Fw(n,e,t,r,s,o,a,u){try{if(localStorage.getItem("clipoox.gpuExport")==="off")return Je=["off in this browser"],null}catch{}if(!(await Nh()).gpu)return Je=["off on the server"],null;const l=e.format||{resolution:"720p",aspectRatio:"16:9",fps:30},{clientExportCheck:d,clientExportCodes:p,softwareRetry:v,gpuErrorText:E}=await pe(async()=>{const{clientExportCheck:k,clientExportCodes:q,softwareRetry:z,gpuErrorText:B}=await import("./clientExport-BXegTdNc.js");return{clientExportCheck:k,clientExportCodes:q,softwareRetry:z,gpuErrorText:B}},__vite__mapDeps([0,1,2])),C=d(n,{format:l,camera:e.camera,look:e.look,encode:e.encode});if(!C.ok)return console.info("[export] server render:",C.reasons.slice(0,5).join(" · ")),Je=p(n,{format:l,camera:e.camera,look:e.look,encode:e.encode}),null;const V=await pe(()=>import("./gpuExport-DwrXpVGF.js"),__vite__mapDeps([3,1,4,2,5,6,7,8,9,10,11]));if(!await V.gpuExportSupported(l,e.encode))return console.info("[export] server render: no hardware video encoder here"),Je=[e.encode?.codec==="hevc"&&await V.gpuExportSupported(l)?"no hevc encoder":"no hardware encoder"],null;const M=n.reduce((k,q)=>q.disabled?k:Math.max(k,q.start+q.duration),0);{const k=await O("/api/media/client-export/check",{seconds:M,...e.aiJob?{aiJob:e.aiJob}:{}});if(k.status===402){const z=Lh(await k.json().catch(()=>({})));if(z)throw z}if(!k.ok)return Je=[`plan check ${k.status}`],null;const q=(await k.json().catch(()=>null))?.hold;u.hold=typeof q=="string"?q:null}r?.("local"),s?.(0);try{let k=!1;const q=_=>V.exportOnGpu(n,{format:l,encode:e.encode,tracks:e.tracks,camera:e.camera,signal:t,onProgress:m=>s?.(m),software:_}),{blob:z,ms:B}=await q(!1).catch(_=>{if(t?.aborted||!v(_,V.gpuExportStage(),e.encode))throw _;return console.warn("[export] hardware encoder failed, again with the software encoder:",_),s?.(0),k=!0,q(!0)}),{width:Y,height:he,fps:P}=Xt(l);Us={totalMs:Math.round(performance.now()-a.start),framesMs:B.titles,renderMs:B.video+B.audio,downloadMs:0,server:{gpu:!0,...B}};{const _=await O("/api/media/client-export/done",{seconds:M,...u.hold?{hold:u.hold}:{},...k?{software:!0}:{},ms:B.total,titlesMs:B.titles,audioMs:B.audio,width:Y,height:he,fps:P,clips:n.length,...e.aiJob?{aiJob:e.aiJob}:{}}).catch(()=>null);_?.ok&&(ys=xh(_)),u.hold=null}return o?.(null),z}catch(k){if(t?.aborted||k?.name==="AbortError")throw k;return console.warn("[export] GPU export failed, the server renders it:",k),Je=[`gpu failed: ${k?.name||"Error"} at ${V.gpuExportStage()||"start"}`,...E(k)?[`gpu error: ${E(k)}`]:[]],r?.("frames"),s?.(null),null}}async function jw(n,e,t={},r,s,o){r?.("frames"),o?.(null);const a={start:performance.now(),posted:0};t.mode===void 0&&(Us=null,ys=null,vs=null),n=Ad(n,Xt(t.format||{resolution:"720p",aspectRatio:"16:9",fps:30}).fps);{const{expandComps:P}=await pe(async()=>{const{expandComps:m}=await import("./timelineComp-Ciu9JCWJ.js").then(g=>g.t);return{expandComps:m}},__vite__mapDeps([2,1])),_=Xt(t.format||{resolution:"720p",aspectRatio:"16:9",fps:30});n=P(n.filter(m=>!m.disabled),{W:_.width,H:_.height})}n=n.filter(P=>!P.disabled).map(bd);const u=Md(n);n=u.clips;const l=n.filter(P=>P.title&&!P.url&&!Rd(P));if(l.length){const P=new Map((await(await pe(async()=>{const{materializeTitles:_}=await import("./timelineText-Cppd4KB7.js");return{materializeTitles:_}},__vite__mapDeps([12,13,1,11,14,15,10]))).materializeTitles(l)).map(_=>[_.id,_]));n=n.map(_=>P.get(_.id)??_)}if(u.fixes.length&&s){const P=s;s=_=>P({..._??{ok:!0,checks:[],platforms:[],duration:0,ms:0},fixes:[...u.fixes,..._?.fixes??[]].slice(0,10)})}if(Je=t.breakdown?["breakdown"]:[],t.mode===void 0&&!t.breakdown){const P={hold:null},_=await Fw(n,t,e,r,o,s,a,P);if(_)return _;P.hold&&(t={...t,hold:P.hold})}t.mode===void 0&&Dw(n.reduce((P,_)=>_.disabled?P:Math.max(P,_.start+_.duration),0)),n.some(P=>P.join)&&(n=[...n,...(await pe(async()=>{const{joinDecoLayers:P}=await import("./titleFrameBudget-h4nOQ5u9.js").then(_=>_.nT);return{joinDecoLayers:P}},[])).joinDecoLayers(n)]);const d=new(await pe(async()=>{const{FrameSink:P}=await import("./frameSink-Rj02YES5.js");return{FrameSink:P}},__vite__mapDeps([16,1]))).FrameSink({signal:e}),p=t.format||{resolution:"720p",aspectRatio:"16:9",fps:30};if(n.some(Sd)){const P=await(await pe(async()=>{const{distortForServer:_}=await import("./distortFrames-DMnZ8OYh.js");return{distortForServer:_}},__vite__mapDeps([17,1,7,8]))).distortForServer(n,p,d,e,t.tracks);n=P.clips,t={...t,tracks:P.tracks}}if(n.some(P=>P.kind==="model")&&await(await pe(async()=>{const{render3DFrames:P}=await import("./timeline3dExport-DgnorHLm.js");return{render3DFrames:P}},__vite__mapDeps([18,1,19,20,21,22,16,10,11]))).render3DFrames(n,p,d,e,t.camera),n.some(P=>Fa(P.title)||P.shape||P.motion||P.lottie||P.card||P.geo)&&await(await pe(async()=>{const{renderTitleFrames:P}=await import("./titleFrames-DnCzi_AI.js");return{renderTitleFrames:P}},__vite__mapDeps([23,1,14,15,24,25,10,11,16]))).renderTitleFrames([...n,...ja(n)],p,d,e,t.camera),n.some(P=>P.mask||P.person)){const P=await pe(()=>import("./rotoMatte-BI-vjjrv.js").then(_=>_.r),__vite__mapDeps([26,1,13,11]));await P.renderMatteFrames([...n,...P.maskedCopies(n)],Xt(p).fps,d,e)}{const P=await pe(()=>import("./windowFrames-dBMXwGek.js"),__vite__mapDeps([27,1,26,13,11,10]));P.hasMovingWindows(n)&&await P.renderWindowFrames(n,Xt(p).fps,d,e)}{const{groupedLevels:P}=await pe(async()=>{const{groupedLevels:m}=await import("./timelineComp-Ciu9JCWJ.js").then(g=>g.t);return{groupedLevels:m}},__vite__mapDeps([2,1])),_=Xt(p);for(const m of P(n,{W:_.width,H:_.height})){if(m.some(g=>g.kind==="model")&&await(await pe(async()=>{const{render3DFrames:g}=await import("./timeline3dExport-DgnorHLm.js");return{render3DFrames:g}},__vite__mapDeps([18,1,19,20,21,22,16,10,11]))).render3DFrames(m,p,d,e,null),m.some(g=>Fa(g.title)||g.shape||g.motion||g.lottie||g.card||g.geo)&&await(await pe(async()=>{const{renderTitleFrames:g}=await import("./titleFrames-DnCzi_AI.js");return{renderTitleFrames:g}},__vite__mapDeps([23,1,14,15,24,25,10,11,16]))).renderTitleFrames([...m,...ja(m)],p,d,e,null),m.some(g=>g.mask||g.person)){const g=await pe(()=>import("./rotoMatte-BI-vjjrv.js").then(T=>T.r),__vite__mapDeps([26,1,13,11]));await g.renderMatteFrames([...m,...g.maskedCopies(m)],_.fps,d,e)}{const g=await pe(()=>import("./windowFrames-dBMXwGek.js"),__vite__mapDeps([27,1,26,13,11,10]));g.hasMovingWindows(m)&&await g.renderWindowFrames(m,_.fps,d,e)}}}n.some(P=>P.mask||P.planar||P.sceneTrack)&&(n=await(await pe(async()=>{const{packMasks:P}=await import("./rotoMaskStore-BZBJLcCp.js");return{packMasks:P}},__vite__mapDeps([28,1,29,10,11]))).packMasks(n));const v=JSON.stringify({clips:n,...t,...await d.finish()}),E=await vr();r?.("render");const C=typeof CompressionStream=="function"&&v.length>256*1024,V=C?await new Response(new Blob([v]).stream().pipeThrough(new CompressionStream("gzip"))).blob():v;a.posted=performance.now();const M=!!o&&t.mode===void 0,k=async P=>fetch(P,{method:"POST",signal:e,headers:{"Content-Type":"application/json","X-Clipoox-Frames-Ms":String(Math.round(a.posted-a.start)),...t.mode===void 0&&Je.length?{"X-Clipoox-Gpu-Skip":Uw(Je)}:{},...M?{Accept:`${Ha}, video/mp4;q=0.9, */*;q=0.5`}:{},...C?{"Content-Encoding":"gzip"}:{},...await kt()},body:V}),q=n.reduce((P,_)=>Math.max(P,_.start+_.duration),0),z=performance.now();let B=!1;const Y=o?setInterval(()=>{B||o(Ut*Su((performance.now()-z)/1e3,10+q*.8))},500):null,he=P=>{B=!0,o?.(P)};try{let P;for(let _=0;;_++){try{P=await k(`${E}/api/media/timeline`)}catch(m){if(!E||e?.aborted)throw m;P=await k("/api/media/timeline")}if(P.status!==429||_>=bu.length)break;r?.("queue"),await Lo(bu[_],e),r?.("render")}if(P.ok&&t.mode===void 0&&(ys=xh(P)),P.ok&&M&&(P.headers.get("Content-Type")||"").startsWith(Ha))return await Lw(P,r,he,s,a);if(r?.("download"),!P.ok){const _=await P.json().catch(()=>({}));{const m=Lh(_);if(m)throw m}throw _.clip?new Error(De("Không xuất được: clip “{0}” (giây {1}) có dữ liệu lỗi — {2}. Hãy sửa hoặc xoá clip đó rồi xuất lại.",[_.clip.label||"?",Number(_.clip.start||0).toFixed(1),_.reason||_.error||""])):new Error(_.code==="render_unavailable"?De("Máy render đang bận hoặc vừa khởi động lại, bản xuất này quá nặng để chạy dự phòng. Hãy xuất lại sau khoảng 1 phút."):Uo(_.error)||`Export failed (${P.status})`)}return s?.(Mh(P)),o?(he(Ut),await xw(P,_=>he(Ut+(1-Ut)*_))):P.blob()}finally{Y&&clearInterval(Y)}}const Bw=n=>U(`/api/motion-agent/price${n?`?chars=${n.chars}&duration=${n.duration}&kind=${n.kind}`:""}`).then(e=>b(e)),$w=n=>O("/api/motion-agent",n).then(e=>b(e)).then(e=>{if(e.error)throw Object.assign(new Error(e.error),{status:e.status});return e}),qw=()=>U("/api/rig-agent/price").then(n=>b(n)),zw=n=>O("/api/rig-agent",n).then(e=>b(e)),Hw=()=>{const n=navigator.userAgent,e=/(Edg|OPR|Firefox|Chrome|Version)\/(\d+)/.exec(n),t=e?(e[1]==="Edg"?"Edge":e[1]==="OPR"?"Opera":e[1]==="Version"?"Safari":e[1])+" "+e[2]:"other";return/Windows/.test(n)?`${t} Windows`:/Mac OS X/.test(n)?`${t} macOS`:/Android/.test(n)?`${t} Android`:/iPhone|iPad/.test(n)?`${t} iOS`:`${t} other`};function Ww(n,e,t={}){try{const r=navigator;O("/api/client-log",{kind:n,message:String(e||"").slice(0,300),detail:{browser:Hw(),cores:r.hardwareConcurrency,memory:r.deviceMemory,...t}}).catch(()=>{})}catch{}}const Gw=()=>U("/api/vfx-lora/catalog").then(n=>b(n)),Kw=n=>O("/api/vfx-lora/render",n).then(e=>b(e)),_I=Object.freeze(Object.defineProperty({__proto__:null,acceptProduction:bT,addUserFont:jT,approveBlenderDevice:kE,archiveCanvas:UE,askAgent:ST,askShotAgent:YT,attachDirectorReference:aT,brollPrompt:yw,brollPromptPrice:_w,cancelRemoteMission:xE,canvasInbox:tT,captionKeywords:Aw,captionKeywordsPrice:Iw,captionTranslate:Rw,captionTranslatePrice:bw,clearDirector:RT,colorAgent:gw,colorAgentPrice:mw,consumeCanvasInbox:nT,copyTimelineDoc:XE,createCanvas:IE,createLibraryModel:DT,createRemoteMission:DE,createSkill:BE,createVcamSession:ME,deleteBrand:qT,deleteCanvas:PE,deleteLibraryAsset:hT,deleteLut:WT,deleteSkill:qE,deleteTempUploads:yE,deleteUserFont:BT,describeFootage:gT,describePrice:vT,duplicateCanvas:FE,estimate:oE,estimateShotAgent:XT,exportReviewOf:Mh,exportTimeline:jw,extractFrame:dE,fetchHealth:sE,fetchLut:GT,freeTranscript:_T,friendlyExportError:Uo,geoSearch:ww,getAssetLibraryItem:xT,getCanvas:AE,getCanvasShotRev:RE,getCanvasTimelineRev:SE,getDesignDoc:YE,getDesignRev:ZE,getDirector:iT,getPersonMatte:lw,getProduction:TT,getRemoteMission:VE,getRotoMask:dw,getSeries:HE,getSet:GE,getShotScene:pw,getTimelineDoc:QE,getTimelineDocRev:CE,get lastExportQuota(){return ys},get lastExportStored(){return vs},get lastExportTimes(){return Us},libraryUsage:uT,listAgentModels:CT,listAssetLibrary:VT,listAssetLibraryCategories:MT,listAssets:rT,listBlenderDevices:OE,listBrands:UT,listCanvases:LE,listDirectorReferences:oT,listGenerators:iE,listJobs:uE,listLibrary:cT,listModelCategories:kT,listModelLibrary:PT,listMyLuts:HT,listRemoteMissions:NE,listSeries:zE,listSkills:jE,listTempUploads:gE,listTextTemplates:LT,listTransitions:KT,listUserFonts:FT,locateObject:fT,mapBlenderScript:Ew,mapHd:vw,me:rE,mediaPeaks:Sw,mediaProxy:Nw,mocapRegionStatus:nE,modelReadUrl:EE,motionAgent:$w,motionAgentPrice:Bw,motionUsage:pT,multicamSync:ET,pinToLibrary:lT,planSignal:mT,pluginAssetUrls:TE,pollJob:cE,pooxVfxCatalog:Gw,prewarmCount:Vh,processAudio:Pw,productionAction:IT,publishLibraryModel:NT,putSigned:vE,quoteProduction:wT,renderPooxVfx:Kw,reportClient:Ww,requestTempUpload:mE,requestUpload:Dh,resolveMapPlaces:Tw,rigAgent:zw,rigAgentPrice:qw,runGenerator:aE,saveBrand:$T,saveCanvas:bE,saveDesignDoc:eT,saveLut:zT,saveModelThumbnail:OT,savePersonMatte:uw,saveProjectContext:sT,saveRotoMask:hw,saveSeries:WE,saveSet:KE,saveShotScene:fw,saveTimelineDoc:JE,sendDirector:AT,shareModelAsset:QT,shotAgentInfo:JT,shotInbetween:Mw,shotInbetweenInfo:Vw,shotLivePoll:rw,shotLiveResult:aw,shotMissionCancel:tw,shotMissionQuote:ew,shotMissionTurn:ZT,shotRemotePoll:nw,shotRemoteReport:cw,signFrameChunks:kw,signOutput:wE,signTempUpload:_E,spliceRegionsMedia:hE,stabilizeClip:Cw,timelineAgent:dT,timelineAgentPrice:yT,timelineLivePoll:sw,timelineLiveProgress:iw,timelineLiveResult:ow,trimMedia:lE,updateSkill:$E,uploadFile:pE},Symbol.toStringTag,{value:"Module"}));export{xT as $,qT as A,$T as B,jE as C,$E as D,BE as E,qE as F,TT as G,IT as H,wT as I,bT as J,oT as K,aT as L,CT as M,AT as N,iT as O,RT as P,sT as Q,uE as R,$w as S,Bw as T,QT as U,cT as V,uT as W,Ld as X,hT as Y,PT as Z,rT as _,wE as a,DE as a$,_E as a0,mE as a1,vE as a2,gE as a3,yE as a4,HT as a5,pT as a6,bw as a7,Rw as a8,Iw as a9,dT as aA,sI as aB,Bd as aC,iI as aD,sw as aE,vs as aF,ow as aG,iw as aH,CE as aI,SE as aJ,kd as aK,nI as aL,tI as aM,jw as aN,Us as aO,ys as aP,Cw as aQ,Pw as aR,rI as aS,wi as aT,fI as aU,hI as aV,dI as aW,kE as aX,OE as aY,NE as aZ,VE as a_,Aw as aa,_T as ab,cI as ac,oI as ad,aI as ae,LT as af,ww as ag,vw as ah,Ew as ai,VT as aj,Su as ak,ET as al,Ww as am,Zw as an,Yw as ao,eI as ap,EE as aq,KT as ar,Nw as as,WT as at,mw as au,gw as av,mT as aw,_w as ax,yw as ay,yT as az,cE as b,xE as b0,ME as b1,FE as b2,UE as b3,ln as b4,$t as b5,vt as b6,ke as b7,Le as b8,to as b9,XT as bA,JT as bB,YT as bC,rw as bD,aw as bE,HE as bF,zE as bG,WE as bH,GE as bI,nE as bJ,YE as bK,ZE as bL,GT as bM,zT as bN,TE as bO,hw as bP,dw as bQ,Tw as bR,uw as bS,Od as bT,FT as bU,BT as bV,jT as bW,lw as bX,fT as bY,_I as bZ,Yd as ba,Fu as bb,_n as bc,Vu as bd,Mu as be,st as bf,yp as bg,lI as bh,mI as bi,gI as bj,iE as bk,fw as bl,pw as bm,kT as bn,OT as bo,DT as bp,NT as bq,RE as br,tw as bs,ZT as bt,nw as bu,cw as bv,ew as bw,KE as bx,qw as by,zw as bz,hE as c,vT as d,oE as e,gT as f,QE as g,JE as h,XE as i,AE as j,IE as k,bE as l,tT as m,nT as n,dE as o,lT as p,Ud as q,aE as r,eT as s,LE as t,pE as u,PE as v,pI as w,tE as x,lE as y,UT as z};
|