forked from bombastictranz/public-docs
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex-EO662V74.min.js.download
54 lines (47 loc) · 270 KB
/
index-EO662V74.min.js.download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import{A as zl,B as Ul,C as Yl,E as Ai,F as Fl,G as Kl,H as Wl,I as Vl,J as Jl,K as ql,L as Gl,M as $l,N as jl,O as Xl,P as Ql,Q as Zl,R as eu,S as tu,T as nu,U as ru,V as ou,W as iu,X as au,_ as su,a as vi,b as Ls,ba as cu,ca as lu,d as cc,da as uu,e as to,ea as mu,f as Oc,fa as hu,g as kc,ga as xi,h as xc,ha as Ei,i as Ec,ia as gu,j as Tc,ja as yu,k as Dc,l as Mc,m as Hc,n as tl,o as wl,p as xl,q as po,r as Tl,t as _l,u as ki,v as Ml,w as Hl,x as Nl,y as Bl,z as Ll}from"/public/dist/chunks/chunk-L7NPK5TU.min.js";import{a as hn,c as Ic}from"/public/dist/chunks/chunk-5SCFXNTI.min.js";import"/public/dist/chunks/chunk-YQT34PDG.min.js";import{e as kl}from"/public/dist/chunks/chunk-SIENTTAZ.min.js";import{d as uc}from"/public/dist/chunks/chunk-VNQHYW5T.min.js";import"/public/dist/chunks/chunk-L53ZXECF.min.js";import{$ as Bc,_ as dc,a as Rs}from"/public/dist/chunks/chunk-DXT3OPYV.min.js";import"/public/dist/chunks/chunk-MNUQNWL5.min.js";import{G as du,H as pu,I as fu,J as Rt,K as Ti,l as pc,m as oo,o as zc,p as Cl,q as Rn,r as Pn,s as Rl,u as so,v as co}from"/public/dist/chunks/chunk-MEJDXFDI.min.js";import{c as sr,f as Pc}from"/public/dist/chunks/chunk-FKA3QQKD.min.js";import{a as zr,b as ts}from"/public/dist/chunks/chunk-RBOJOHTO.min.js";import"/public/dist/chunks/chunk-H2C6UPHY.min.js";import{c as z,d as Lc,e as cr}from"/public/dist/chunks/chunk-SFEIUMSG.min.js";import"/public/dist/chunks/chunk-AXQ3YKHM.min.js";import{a as Uc,b as gn,c as Al,d as vu}from"/public/dist/chunks/chunk-NIUEBYJL.min.js";import"/public/dist/chunks/chunk-KIFOF67C.min.js";import{b as gs,d as un,e as dn,f as ys,g as fo,h as mo,i as El}from"/public/dist/chunks/chunk-KLCNJ54B.min.js";import{a as bu}from"/public/dist/chunks/chunk-3ZFVCCPK.min.js";import{F as pr,c as hs,k as cl,l as ll,v as Ol,w as uo}from"/public/dist/chunks/chunk-O2LJZ7WZ.min.js";import"/public/dist/chunks/chunk-AXDVVOHC.min.js";import"/public/dist/chunks/chunk-6HXEVIX5.min.js";import"/public/dist/chunks/chunk-4UDRI63P.min.js";import{a as ps}from"/public/dist/chunks/chunk-UYOGNNK6.min.js";import{a as go}from"/public/dist/chunks/chunk-3ADICUSO.min.js";import"/public/dist/chunks/chunk-QKCMGGFO.min.js";import"/public/dist/chunks/chunk-QESBGOAJ.min.js";import{b as Cn}from"/public/dist/chunks/chunk-BZP52NPG.min.js";import{A as Sl,K as On,e as zs,g as ic,k as yl,l as vl}from"/public/dist/chunks/chunk-CPEUZE5T.min.js";import{a as ol,b as il}from"/public/dist/chunks/chunk-XHYHTT5Z.min.js";import"/public/dist/chunks/chunk-3S3T3GZX.min.js";import{a as Le,d as _s,l as jr}from"/public/dist/chunks/chunk-6TAVA5ER.min.js";import{a as is,d as As,e as bi,f as xs,g as Es,h as Ds,j as ac,m as sc}from"/public/dist/chunks/chunk-ANUJLAI3.min.js";import{b as Hs,c as Jr,d as qr}from"/public/dist/chunks/chunk-RZX3IFLB.min.js";import{b as In,c as lo,h as Dl}from"/public/dist/chunks/chunk-TGO3IE7Z.min.js";import{e as or,f as Xr,i as ir}from"/public/dist/chunks/chunk-4LXDY6MF.min.js";import{a as Fr}from"/public/dist/chunks/chunk-XNHZVLJL.min.js";import{a as us}from"/public/dist/chunks/chunk-W5QIW24P.min.js";import"/public/dist/chunks/chunk-67CTVIUQ.min.js";import"/public/dist/chunks/chunk-INPR7JFX.min.js";import{a as gl,c as Ct,d as Pl,e as Il}from"/public/dist/chunks/chunk-HWO3VQLR.min.js";import{a as oc}from"/public/dist/chunks/chunk-2WTMOSUL.min.js";import{a as Yr,f as ho}from"/public/dist/chunks/chunk-47KQ26HM.min.js";import"/public/dist/chunks/chunk-TNLNWMUG.min.js";import{b as qe,d as Oi,e as ul,f as dl,g as pl,k as fl,l as wn,s as wt}from"/public/dist/chunks/chunk-DB6VIC5B.min.js";import{Aa as Ge,Ba as Qc,Ca as Zc,Da as el,Fa as io,Ga as nl,Ha as vn,Ia as rl,L as es,N as ns,P as rs,Qa as dr,S as qc,Sa as bn,Y as Gc,_a as U,ab as bl,ja as $c,va as jc,xa as Xc,ya as ur}from"/public/dist/chunks/chunk-VKQUYSR7.min.js";import{b as Us,j as ze,o as et,p as lc}from"/public/dist/chunks/chunk-URFLMWYV.min.js";import{a as bt,b as Y,d as Ns,e as Gr,f as pn}from"/public/dist/chunks/chunk-DYMDDH4Z.min.js";import"/public/dist/chunks/chunk-Q4E2SK5G.min.js";import{a as pt}from"/public/dist/chunks/chunk-H4SAVNB4.min.js";import{a as Xm,b as vs,c as bs,f as ao,g as al,h as Sn,i as sl}from"/public/dist/chunks/chunk-IQ676DS3.min.js";import"/public/dist/chunks/chunk-OW5MLSZY.min.js";import{A as Pi,B as wc,C as Cc,D as Rc,E as eo,F as Yt,G as Ye,H as ar,I as ke,J as q,K as be,L as tt,M as ie,N as R,Nb as yn,O as Ii,Pb as Fc,Qc as Vc,R as no,S as ro,T as Ac,Tb as Kc,Y as _c,c as lt,h as Za,id as Jc,j as sn,jd as re,k as se,l as Ut,m as nc,n as rc,nc as Ft,p as fc,q as mc,r as Ue,rc as Wc,s as hc,t as Qr,u as gc,v as Zr,vd as lr,w as yc,x as vc,y as bc,z as Sc,zb as Yc}from"/public/dist/chunks/chunk-L5TOBK2L.min.js";import"/public/dist/chunks/chunk-MFK7PWV2.min.js";import{b as Ms,e as ml,f as hl,h as Z}from"/public/dist/chunks/chunk-PGUON4XT.min.js";import{pb as Xn,qb as Be}from"/public/dist/chunks/chunk-3QPBAMM7.min.js";import{b as Bs,c as Ze}from"/public/dist/chunks/chunk-JZJAOGSC.min.js";import{b as Ts}from"/public/dist/chunks/chunk-S2OJGX4N.min.js";import{a as fs,d as ms,e as ks,m as Vr}from"/public/dist/chunks/chunk-MN7NX5IJ.min.js";import{A as ss,B as cs,C as ls,E as ln,H as Kr,I as ds,K as de,P as Cs,b as u,d as Ur,h as O,l as T}from"/public/dist/chunks/chunk-NFUQHH4C.min.js";import{B as S,I as Zn,J as er,K as J,L as dt,V as Ss,W as ws,Y as Ps,_ as Is,aa as St,da as Os,ea as Wr,m as k,o as Ve,q as os,r as cn,v as ut,w as Oe,x as Je}from"/public/dist/chunks/chunk-NTC4SP6I.min.js";import{b as zt}from"/public/dist/chunks/chunk-EKMUVPJP.min.js";import"/public/dist/chunks/chunk-PTTS3Y3D.min.js";import"/public/dist/chunks/chunk-M5GZ4M7R.min.js";import"/public/dist/chunks/chunk-DVK3YBMS.min.js";import"/public/dist/chunks/chunk-5CJE7YRS.min.js";import{c as Lt,d as Nc}from"/public/dist/chunks/chunk-WFBDSFKJ.min.js";import{A as Qm,B as js,C as Ci,Cb as Zs,Db as ec,Eb as Ri,Fa as Xs,Ga as Qs,Gb as tc,e as fn,f as Ys,g as $r,i as mn,n as Fs,o as nr,p as Ks,q as Ws,r as Vs,s as Si,u as Js,v as qs,w as Gs,x as wi,y as $s,z as rr}from"/public/dist/chunks/chunk-L5XQ77O4.min.js";import{a as W}from"/public/dist/chunks/chunk-YUOC3LIL.min.js";import{a as tr}from"/public/dist/chunks/chunk-44JP3I6H.min.js";import{b as te,c as as,d as Qn,e as ue}from"/public/dist/chunks/chunk-QQR5YZU3.min.js";import"/public/dist/chunks/chunk-LIAWMKRI.min.js";import"/public/dist/chunks/chunk-ARNXK4DR.min.js";import{b as De,c as jm,d as P,f as s}from"/public/dist/chunks/chunk-YFNJ7WVR.min.js";var Nd=De((PT,Hd)=>{s();var Qg="Expected a function",_d=NaN,Zg="[object Symbol]",ey=/^\s+|\s+$/g,ty=/^[-+]0x[0-9a-f]+$/i,ny=/^0b[01]+$/i,ry=/^0o[0-7]+$/i,oy=parseInt,iy=typeof window=="object"&&window&&window.Object===Object&&window,ay=typeof self=="object"&&self&&self.Object===Object&&self,sy=iy||ay||Function("return this")(),cy=Object.prototype,ly=cy.toString,uy=Math.max,dy=Math.min,$i=function(){return sy.Date.now()};function py(r,n,e){var t,o,i,a,c,h,p=0,d=!1,f=!1,y=!0;if(typeof r!="function")throw new TypeError(Qg);n=Md(n)||0,ji(e)&&(d=!!e.leading,f="maxWait"in e,i=f?uy(Md(e.maxWait)||0,n):i,y="trailing"in e?!!e.trailing:y);function C(K){var ee=t,ae=o;return t=o=void 0,p=K,a=r.apply(ae,ee),a}function I(K){return p=K,c=setTimeout(b,n),d?C(K):a}function v(K){var ee=K-h,ae=K-p,Te=n-ee;return f?dy(Te,i-ae):Te}function g(K){var ee=K-h,ae=K-p;return h===void 0||ee>=n||ee<0||f&&ae>=i}function b(){var K=$i();if(g(K))return A(K);c=setTimeout(b,v(K))}function A(K){return c=void 0,y&&t?C(K):(t=o=void 0,a)}function E(){c!==void 0&&clearTimeout(c),p=0,t=h=o=c=void 0}function N(){return c===void 0?a:A($i())}function B(){var K=$i(),ee=g(K);if(t=arguments,o=this,h=K,ee){if(c===void 0)return I(h);if(f)return c=setTimeout(b,n),C(h)}return c===void 0&&(c=setTimeout(b,n)),a}return B.cancel=E,B.flush=N,B}function ji(r){var n=typeof r;return!!r&&(n=="object"||n=="function")}function fy(r){return!!r&&typeof r=="object"}function my(r){return typeof r=="symbol"||fy(r)&&ly.call(r)==Zg}function Md(r){if(typeof r=="number")return r;if(my(r))return _d;if(ji(r)){var n=typeof r.valueOf=="function"?r.valueOf():r;r=ji(n)?n+"":n}if(typeof r!="string")return r===0?r:+r;r=r.replace(ey,"");var e=ny.test(r);return e||ry.test(r)?oy(r.slice(2),e?2:8):ty.test(r)?_d:+r}Hd.exports=py});var zd=De((OT,Ld)=>{s();var Bd=function(){if(typeof self=="object"&&self)return self;if(typeof window=="object"&&window)return window;throw new Error("Unable to resolve global `this`")};Ld.exports=function(){if(this)return this;if(typeof globalThis=="object"&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch{return Bd()}try{return __global__||Bd()}finally{delete Object.prototype.__global__}}()});var Ud=De((AT,hy)=>{hy.exports={name:"websocket",description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],author:"Brian McKelvey <[email protected]> (https://github.com/theturtle32)",contributors:["I\xF1aki Baz Castillo <[email protected]> (http://dev.sipdoc.net)"],version:"1.0.34",repository:{type:"git",url:"https://github.com/theturtle32/WebSocket-Node.git"},homepage:"https://github.com/theturtle32/WebSocket-Node",engines:{node:">=4.0.0"},dependencies:{bufferutil:"^4.0.1",debug:"^2.2.0","es5-ext":"^0.10.50","typedarray-to-buffer":"^3.1.5","utf-8-validate":"^5.0.2",yaeti:"^0.0.6"},devDependencies:{"buffer-equal":"^1.0.0",gulp:"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1",jshint:"^2.0.0",tape:"^4.9.1"},config:{verbose:!1},scripts:{test:"tape test/unit/*.js",gulp:"gulp"},main:"index",directories:{lib:"./lib"},browser:"lib/browser.js",license:"Apache-2.0"}});var Fd=De((xT,Yd)=>{s();Yd.exports=Ud().version});var Vd=De((TT,Wd)=>{s();var qt;if(typeof globalThis=="object")qt=globalThis;else try{qt=zd()}catch{}finally{if(!qt&&typeof window<"u"&&(qt=window),!qt)throw new Error("Could not determine global this")}var vr=qt.WebSocket||qt.MozWebSocket,gy=Fd();function Kd(r,n){var e;return n?e=new vr(r,n):e=new vr(r),e}vr&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(r){Object.defineProperty(Kd,r,{get:function(){return vr[r]}})});Wd.exports={w3cwebsocket:vr?Kd:null,version:gy}});var Mf=De(Ha=>{"use strict";s();Object.defineProperty(Ha,"__esModule",{value:!0});var Tv={justifyContent:"center",alignItems:"center",overflow:"hidden",backgroundColor:"transparent"};Ha.default={container:Tv}});var Na=De(Kn=>{"use strict";s();Object.defineProperty(Kn,"__esModule",{value:!0});Kn.ImageZoomState=Kn.ImageZoomProps=void 0;var Dv=function(){function r(){this.cropWidth=100,this.cropHeight=100,this.imageWidth=100,this.imageHeight=100,this.panToMove=!0,this.pinchToZoom=!0,this.enableDoubleClickZoom=!0,this.clickDistance=10,this.maxOverflow=100,this.longPressTime=800,this.doubleClickInterval=175,this.style={},this.swipeDownThreshold=230,this.enableSwipeDown=!1,this.enableCenterFocus=!0,this.useHardwareTextureAndroid=!0,this.minScale=.6,this.maxScale=10,this.useNativeDriver=!1,this.onClick=function(){},this.onDoubleClick=function(){},this.onLongPress=function(){},this.horizontalOuterRangeOffset=function(){},this.onDragLeft=function(){},this.responderRelease=function(){},this.onMove=function(){},this.layoutChange=function(){},this.onSwipeDown=function(){},this.onStartShouldSetPanResponder=function(){return!0},this.onPanResponderTerminationRequest=function(){return!1}}return r}();Kn.ImageZoomProps=Dv;var _v=function(){function r(){this.centerX=.5,this.centerY=.5}return r}();Kn.ImageZoomState=_v});var Nf=De(tn=>{"use strict";s();var Mv=tn&&tn.__extends||function(){var r=function(n,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var i in o)o.hasOwnProperty(i)&&(t[i]=o[i])},r(n,e)};return function(n,e){r(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}}(),Mr=tn&&tn.__assign||function(){return Mr=Object.assign||function(r){for(var n,e=1,t=arguments.length;e<t;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])}return r},Mr.apply(this,arguments)};Object.defineProperty(tn,"__esModule",{value:!0});var di=k(),Q=Ve(),Hv=Mf(),Hf=Na(),Nv=function(r){Mv(n,r);function n(){var e=r!==null&&r.apply(this,arguments)||this;return e.state=new Hf.ImageZoomState,e.lastPositionX=null,e.positionX=0,e.animatedPositionX=new Q.Animated.Value(0),e.lastPositionY=null,e.positionY=0,e.animatedPositionY=new Q.Animated.Value(0),e.scale=1,e.animatedScale=new Q.Animated.Value(1),e.zoomLastDistance=null,e.zoomCurrentDistance=0,e.lastTouchStartTime=0,e.horizontalWholeOuterCounter=0,e.swipeDownOffset=0,e.horizontalWholeCounter=0,e.verticalWholeCounter=0,e.centerDiffX=0,e.centerDiffY=0,e.lastClickTime=0,e.doubleClickX=0,e.doubleClickY=0,e.isDoubleClick=!1,e.isLongPress=!1,e.isHorizontalWrap=!1,e.imagePanResponder=Q.PanResponder.create({onStartShouldSetPanResponder:e.props.onStartShouldSetPanResponder,onPanResponderTerminationRequest:e.props.onPanResponderTerminationRequest,onMoveShouldSetPanResponder:e.props.onMoveShouldSetPanResponder,onPanResponderGrant:function(t){if(e.lastPositionX=null,e.lastPositionY=null,e.zoomLastDistance=null,e.horizontalWholeCounter=0,e.verticalWholeCounter=0,e.lastTouchStartTime=new Date().getTime(),e.isDoubleClick=!1,e.isLongPress=!1,e.isHorizontalWrap=!1,e.singleClickTimeout&&clearTimeout(e.singleClickTimeout),t.nativeEvent.changedTouches.length>1){var o=(t.nativeEvent.changedTouches[0].pageX+t.nativeEvent.changedTouches[1].pageX)/2;e.centerDiffX=o-e.props.cropWidth/2;var i=(t.nativeEvent.changedTouches[0].pageY+t.nativeEvent.changedTouches[1].pageY)/2;e.centerDiffY=i-e.props.cropHeight/2}e.longPressTimeout&&clearTimeout(e.longPressTimeout);var a=t.nativeEvent,c=a.locationX,h=a.locationY,p=a.pageX,d=a.pageY;if(e.longPressTimeout=setTimeout(function(){e.isLongPress=!0,e.props.onLongPress&&e.props.onLongPress({locationX:c,locationY:h,pageX:p,pageY:d})},e.props.longPressTime),t.nativeEvent.changedTouches.length<=1)if(new Date().getTime()-e.lastClickTime<(e.props.doubleClickInterval||0)){if(e.lastClickTime=0,e.doubleClickX=t.nativeEvent.changedTouches[0].pageX,e.doubleClickY=t.nativeEvent.changedTouches[0].pageY,e.props.onDoubleClick&&e.props.onDoubleClick({locationX:t.nativeEvent.changedTouches[0].locationX,locationY:t.nativeEvent.changedTouches[0].locationY,pageX:e.doubleClickX,pageY:e.doubleClickY}),clearTimeout(e.longPressTimeout),e.isDoubleClick=!0,e.props.enableDoubleClickZoom){if(e.scale>1||e.scale<1)e.scale=1,e.positionX=0,e.positionY=0;else{var f=e.scale;e.scale=2;var y=e.scale-f;e.positionX=(e.props.cropWidth/2-e.doubleClickX)*y/e.scale,e.positionY=(e.props.cropHeight/2-e.doubleClickY)*y/e.scale}e.imageDidMove("centerOn"),Q.Animated.parallel([Q.Animated.timing(e.animatedScale,{toValue:e.scale,duration:100,useNativeDriver:!!e.props.useNativeDriver}),Q.Animated.timing(e.animatedPositionX,{toValue:e.positionX,duration:100,useNativeDriver:!!e.props.useNativeDriver}),Q.Animated.timing(e.animatedPositionY,{toValue:e.positionY,duration:100,useNativeDriver:!!e.props.useNativeDriver})]).start()}}else e.lastClickTime=new Date().getTime()},onPanResponderMove:function(t,o){if(!e.isDoubleClick){if(t.nativeEvent.changedTouches.length<=1){var i=o.dx-(e.lastPositionX||0);e.lastPositionX===null&&(i=0);var a=o.dy-(e.lastPositionY||0);if(e.lastPositionY===null&&(a=0),e.lastPositionX=o.dx,e.lastPositionY=o.dy,e.horizontalWholeCounter+=i,e.verticalWholeCounter+=a,(Math.abs(e.horizontalWholeCounter)>5||Math.abs(e.verticalWholeCounter)>5)&&clearTimeout(e.longPressTimeout),e.props.panToMove){if(e.swipeDownOffset===0){if(Math.abs(i)>Math.abs(a)&&(e.isHorizontalWrap=!0),e.props.imageWidth*e.scale>e.props.cropWidth){e.horizontalWholeOuterCounter>0?i<0?e.horizontalWholeOuterCounter>Math.abs(i)?(e.horizontalWholeOuterCounter+=i,i=0):(i+=e.horizontalWholeOuterCounter,e.horizontalWholeOuterCounter=0,e.props.horizontalOuterRangeOffset&&e.props.horizontalOuterRangeOffset(0)):e.horizontalWholeOuterCounter+=i:e.horizontalWholeOuterCounter<0&&(i>0?Math.abs(e.horizontalWholeOuterCounter)>i?(e.horizontalWholeOuterCounter+=i,i=0):(i+=e.horizontalWholeOuterCounter,e.horizontalWholeOuterCounter=0,e.props.horizontalOuterRangeOffset&&e.props.horizontalOuterRangeOffset(0)):e.horizontalWholeOuterCounter+=i),e.positionX+=i/e.scale;var c=(e.props.imageWidth*e.scale-e.props.cropWidth)/2/e.scale;e.positionX<-c?(e.positionX=-c,e.horizontalWholeOuterCounter+=-1/1e10):e.positionX>c&&(e.positionX=c,e.horizontalWholeOuterCounter+=1/1e10),e.animatedPositionX.setValue(e.positionX)}else e.horizontalWholeOuterCounter+=i;e.horizontalWholeOuterCounter>(e.props.maxOverflow||0)?e.horizontalWholeOuterCounter=e.props.maxOverflow||0:e.horizontalWholeOuterCounter<-(e.props.maxOverflow||0)&&(e.horizontalWholeOuterCounter=-(e.props.maxOverflow||0)),e.horizontalWholeOuterCounter!==0&&e.props.horizontalOuterRangeOffset&&e.props.horizontalOuterRangeOffset(e.horizontalWholeOuterCounter)}e.props.imageHeight*e.scale>e.props.cropHeight?(e.positionY+=a/e.scale,e.animatedPositionY.setValue(e.positionY)):e.props.enableSwipeDown&&!e.isHorizontalWrap&&(e.swipeDownOffset+=a,e.swipeDownOffset>0&&(e.positionY+=a/e.scale,e.animatedPositionY.setValue(e.positionY),e.scale=e.scale-a/1e3,e.animatedScale.setValue(e.scale)))}}else if(e.longPressTimeout&&clearTimeout(e.longPressTimeout),e.props.pinchToZoom){var h=void 0,p=void 0;t.nativeEvent.changedTouches[0].locationX>t.nativeEvent.changedTouches[1].locationX?(h=t.nativeEvent.changedTouches[1].pageX,p=t.nativeEvent.changedTouches[0].pageX):(h=t.nativeEvent.changedTouches[0].pageX,p=t.nativeEvent.changedTouches[1].pageX);var d=void 0,f=void 0;t.nativeEvent.changedTouches[0].locationY>t.nativeEvent.changedTouches[1].locationY?(d=t.nativeEvent.changedTouches[1].pageY,f=t.nativeEvent.changedTouches[0].pageY):(d=t.nativeEvent.changedTouches[0].pageY,f=t.nativeEvent.changedTouches[1].pageY);var y=p-h,C=f-d,I=Math.sqrt(y*y+C*C);if(e.zoomCurrentDistance=Number(I.toFixed(1)),e.zoomLastDistance!==null){var v=(e.zoomCurrentDistance-e.zoomLastDistance)/200,g=e.scale+v;g<(e.props.minScale||0)&&(g=e.props.minScale||0),g>(e.props.maxScale||0)&&(g=e.props.maxScale||0);var b=e.scale;e.scale=g,e.animatedScale.setValue(e.scale);var A=e.scale-b;e.positionX-=e.centerDiffX*A/e.scale,e.positionY-=e.centerDiffY*A/e.scale,e.animatedPositionX.setValue(e.positionX),e.animatedPositionY.setValue(e.positionY)}e.zoomLastDistance=e.zoomCurrentDistance}e.imageDidMove("onPanResponderMove")}},onPanResponderRelease:function(t,o){if(e.longPressTimeout&&clearTimeout(e.longPressTimeout),!e.isDoubleClick&&!e.isLongPress){var i=Math.sqrt(o.dx*o.dx+o.dy*o.dy),a=t.nativeEvent,c=a.locationX,h=a.locationY,p=a.pageX,d=a.pageY;t.nativeEvent.changedTouches.length===1&&i<(e.props.clickDistance||0)?e.singleClickTimeout=setTimeout(function(){e.props.onClick&&e.props.onClick({locationX:c,locationY:h,pageX:p,pageY:d})},e.props.doubleClickInterval):(e.props.responderRelease&&e.props.responderRelease(o.vx,e.scale),e.panResponderReleaseResolve())}},onPanResponderTerminate:function(){}}),e.resetScale=function(){e.positionX=0,e.positionY=0,e.scale=1,e.animatedScale.setValue(1)},e.panResponderReleaseResolve=function(){if(e.props.enableSwipeDown&&e.props.swipeDownThreshold&&e.swipeDownOffset>e.props.swipeDownThreshold){e.props.onSwipeDown&&e.props.onSwipeDown();return}if(e.props.enableCenterFocus&&e.scale<1&&(e.scale=1,Q.Animated.timing(e.animatedScale,{toValue:e.scale,duration:100,useNativeDriver:!!e.props.useNativeDriver}).start()),e.props.imageWidth*e.scale<=e.props.cropWidth&&(e.positionX=0,Q.Animated.timing(e.animatedPositionX,{toValue:e.positionX,duration:100,useNativeDriver:!!e.props.useNativeDriver}).start()),e.props.imageHeight*e.scale<=e.props.cropHeight&&(e.positionY=0,Q.Animated.timing(e.animatedPositionY,{toValue:e.positionY,duration:100,useNativeDriver:!!e.props.useNativeDriver}).start()),e.props.imageHeight*e.scale>e.props.cropHeight){var t=(e.props.imageHeight*e.scale-e.props.cropHeight)/2/e.scale;e.positionY<-t?e.positionY=-t:e.positionY>t&&(e.positionY=t),Q.Animated.timing(e.animatedPositionY,{toValue:e.positionY,duration:100,useNativeDriver:!!e.props.useNativeDriver}).start()}if(e.props.imageWidth*e.scale>e.props.cropWidth){var o=(e.props.imageWidth*e.scale-e.props.cropWidth)/2/e.scale;e.positionX<-o?e.positionX=-o:e.positionX>o&&(e.positionX=o),Q.Animated.timing(e.animatedPositionX,{toValue:e.positionX,duration:100,useNativeDriver:!!e.props.useNativeDriver}).start()}e.props.enableCenterFocus&&e.scale===1&&(e.positionX=0,e.positionY=0,Q.Animated.timing(e.animatedPositionX,{toValue:e.positionX,duration:100,useNativeDriver:!!e.props.useNativeDriver}).start(),Q.Animated.timing(e.animatedPositionY,{toValue:e.positionY,duration:100,useNativeDriver:!!e.props.useNativeDriver}).start()),e.horizontalWholeOuterCounter=0,e.swipeDownOffset=0,e.imageDidMove("onPanResponderRelease")},e}return n.prototype.componentDidMount=function(){this.props.centerOn&&this.centerOn(this.props.centerOn)},n.prototype.componentDidUpdate=function(e){(this.props.centerOn&&!e.centerOn||this.props.centerOn&&e.centerOn&&this.didCenterOnChange(e.centerOn,this.props.centerOn))&&this.centerOn(this.props.centerOn)},n.prototype.imageDidMove=function(e){this.props.onMove&&this.props.onMove({type:e,positionX:this.positionX,positionY:this.positionY,scale:this.scale,zoomCurrentDistance:this.zoomCurrentDistance})},n.prototype.didCenterOnChange=function(e,t){return e.x!==t.x||e.y!==t.y||e.scale!==t.scale},n.prototype.centerOn=function(e){var t=this;this.positionX=e.x,this.positionY=e.y,this.scale=e.scale;var o=e.duration||300;Q.Animated.parallel([Q.Animated.timing(this.animatedScale,{toValue:this.scale,duration:o,useNativeDriver:!!this.props.useNativeDriver}),Q.Animated.timing(this.animatedPositionX,{toValue:this.positionX,duration:o,useNativeDriver:!!this.props.useNativeDriver}),Q.Animated.timing(this.animatedPositionY,{toValue:this.positionY,duration:o,useNativeDriver:!!this.props.useNativeDriver})]).start(function(){t.imageDidMove("centerOn")})},n.prototype.handleLayout=function(e){this.props.layoutChange&&this.props.layoutChange(e)},n.prototype.reset=function(){this.scale=1,this.animatedScale.setValue(this.scale),this.positionX=0,this.animatedPositionX.setValue(this.positionX),this.positionY=0,this.animatedPositionY.setValue(this.positionY)},n.prototype.render=function(){var e={transform:[{scale:this.animatedScale},{translateX:this.animatedPositionX},{translateY:this.animatedPositionY}]},t=Q.StyleSheet.flatten(this.props.style);return di.createElement(Q.View,{style:Mr(Mr(Mr({},Hv.default.container),t),{width:this.props.cropWidth,height:this.props.cropHeight}),...this.imagePanResponder.panHandlers},di.createElement(Q.Animated.View,{style:e,renderToHardwareTextureAndroid:this.props.useHardwareTextureAndroid},di.createElement(Q.View,{onLayout:this.handleLayout.bind(this),style:{width:this.props.imageWidth,height:this.props.imageHeight}},this.props.children)))},n.defaultProps=new Hf.ImageZoomProps,n}(di.Component);tn.default=Nv});var Bf=De(_t=>{"use strict";s();var Bv=_t&&_t.__createBinding||(Object.create?function(r,n,e,t){t===void 0&&(t=e),Object.defineProperty(r,t,{enumerable:!0,get:function(){return n[e]}})}:function(r,n,e,t){t===void 0&&(t=e),r[t]=n[e]}),Lv=_t&&_t.__exportStar||function(r,n){for(var e in r)e!=="default"&&!n.hasOwnProperty(e)&&Bv(n,r,e)};Object.defineProperty(_t,"__esModule",{value:!0});var zv=Nf();_t.default=zv.default;Lv(Na(),_t)});var Ba=De(pi=>{"use strict";s();Object.defineProperty(pi,"__esModule",{value:!0});pi.default=function(r,n,e){return{modalContainer:{backgroundColor:e,justifyContent:"center",alignItems:"center",overflow:"hidden"},watchOrigin:{position:"absolute",width:r,bottom:20,justifyContent:"center",alignItems:"center"},watchOriginTouchable:{paddingLeft:10,paddingRight:10,paddingTop:5,paddingBottom:5,borderRadius:30,borderColor:"white",borderWidth:.5,backgroundColor:"rgba(0, 0, 0, 0.1)"},watchOriginText:{color:"white",backgroundColor:"transparent"},imageStyle:{},container:{backgroundColor:e},moveBox:{flexDirection:"row",alignItems:"center"},menuContainer:{position:"absolute",width:r,height:n,left:0,bottom:0,zIndex:12},menuShadow:{position:"absolute",width:r,height:n,backgroundColor:"black",left:0,bottom:0,opacity:.2,zIndex:10},menuContent:{position:"absolute",width:r,left:0,bottom:0,zIndex:11},operateContainer:{justifyContent:"center",alignItems:"center",backgroundColor:"white",height:40,borderBottomColor:"#ccc",borderBottomWidth:1},operateText:{color:"#333"},loadingTouchable:{width:r,height:n},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center"},arrowLeftContainer:{position:"absolute",top:0,bottom:0,left:0,justifyContent:"center",zIndex:13},arrowRightContainer:{position:"absolute",top:0,bottom:0,right:0,justifyContent:"center",zIndex:13}}};pi.simpleStyle={count:{position:"absolute",left:0,right:0,top:38,zIndex:13,justifyContent:"center",alignItems:"center",backgroundColor:"transparent"},countText:{color:"white",fontSize:16,backgroundColor:"transparent",textShadowColor:"rgba(0, 0, 0, 0.3)",textShadowOffset:{width:0,height:.5},textShadowRadius:0}}});var Ua=De(fi=>{"use strict";s();Object.defineProperty(fi,"__esModule",{value:!0});var La=k(),za=Ve(),Lf=Ba(),Uv=function(){function r(){this.show=!1,this.imageUrls=[],this.flipThreshold=80,this.maxOverflow=300,this.index=0,this.failImageSource=void 0,this.backgroundColor="black",this.footerContainerStyle={},this.menuContext={saveToLocal:"save to the album",cancel:"cancel"},this.saveToLocalByLongPress=!0,this.enableImageZoom=!0,this.style={},this.enableSwipeDown=!1,this.enablePreload=!1,this.pageAnimateTime=100,this.useNativeDriver=!1,this.onLongPress=function(){},this.onClick=function(){},this.onDoubleClick=function(){},this.onSave=function(){},this.onMove=function(){},this.renderHeader=function(){return null},this.renderFooter=function(){return null},this.renderIndicator=function(n,e){return La.createElement(za.View,{style:Lf.simpleStyle.count},La.createElement(za.Text,{style:Lf.simpleStyle.countText},n+"/"+e))},this.renderImage=function(n){return La.createElement(za.Image,n)},this.renderArrowLeft=function(){return null},this.renderArrowRight=function(){return null},this.onShowModal=function(){},this.onCancel=function(){},this.onSwipeDown=function(){},this.loadingRender=function(){return null},this.onSaveToCamera=function(){},this.onChange=function(){}}return r}();fi.Props=Uv;var Yv=function(){function r(){this.show=!1,this.currentShowIndex=0,this.prevIndexProp=0,this.imageLoaded=!1,this.imageSizes=[],this.isShowMenu=!1}return r}();fi.State=Yv});var Yf=De(yt=>{"use strict";s();var Fv=yt&&yt.__extends||function(){var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,e){n.__proto__=e}||function(n,e){for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t])};return function(n,e){r(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}}(),nn=yt&&yt.__assign||Object.assign||function(r){for(var n,e=1,t=arguments.length;e<t;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])}return r},Kv=yt&&yt.__rest||function(r,n){var e={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&n.indexOf(t)<0&&(e[t]=r[t]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(r);o<t.length;o++)n.indexOf(t[o])<0&&(e[t[o]]=r[t[o]]);return e};Object.defineProperty(yt,"__esModule",{value:!0});var F=k(),D=Ve(),zf=Bf(),Uf=Ba(),Ya=Ua(),Wv=function(r){Fv(n,r);function n(){var e=r!==null&&r.apply(this,arguments)||this;return e.state=new Ya.State,e.fadeAnim=new D.Animated.Value(0),e.standardPositionX=0,e.positionXNumber=0,e.positionX=new D.Animated.Value(0),e.width=0,e.height=0,e.styles=Uf.default(0,0,"transparent"),e.hasLayout=!1,e.loadedIndex=new Map,e.handleLongPressWithIndex=new Map,e.imageRefs=[],e.resetImageByIndex=function(t){e.imageRefs[t]&&e.imageRefs[t].reset()},e.preloadImage=function(t){t<e.state.imageSizes.length&&e.loadImage(t+1)},e.handleHorizontalOuterRangeOffset=function(t){t===void 0&&(t=0),e.positionXNumber=e.standardPositionX+t,e.positionX.setValue(e.positionXNumber);var o=D.I18nManager.isRTL?-t:t;o<0?(e.state.currentShowIndex||0<e.props.imageUrls.length-1)&&e.loadImage((e.state.currentShowIndex||0)+1):o>0&&e.state.currentShowIndex&&e.loadImage((e.state.currentShowIndex||0)-1)},e.handleResponderRelease=function(t){t===void 0&&(t=0);var o=D.I18nManager.isRTL?-t:t,i=D.I18nManager.isRTL?e.positionXNumber-e.standardPositionX<-(e.props.flipThreshold||0):e.positionXNumber-e.standardPositionX>(e.props.flipThreshold||0),a=D.I18nManager.isRTL?e.positionXNumber-e.standardPositionX>(e.props.flipThreshold||0):e.positionXNumber-e.standardPositionX<-(e.props.flipThreshold||0);if(o>.7){e.goBack.call(e),e.state.currentShowIndex&&e.loadImage((e.state.currentShowIndex||0)-1);return}else if(o<-.7){e.goNext.call(e),(e.state.currentShowIndex||0<e.props.imageUrls.length-1)&&e.loadImage((e.state.currentShowIndex||0)+1);return}if(i)e.goBack.call(e);else if(a){e.goNext.call(e);return}else{e.resetPosition.call(e);return}},e.goBack=function(){if(e.state.currentShowIndex===0){e.resetPosition.call(e);return}e.positionXNumber=D.I18nManager.isRTL?e.standardPositionX-e.width:e.standardPositionX+e.width,e.standardPositionX=e.positionXNumber,D.Animated.timing(e.positionX,{toValue:e.positionXNumber,duration:e.props.pageAnimateTime,useNativeDriver:!!e.props.useNativeDriver}).start();var t=(e.state.currentShowIndex||0)-1;e.setState({currentShowIndex:t},function(){e.props.onChange&&e.props.onChange(e.state.currentShowIndex)})},e.goNext=function(){if(e.state.currentShowIndex===e.props.imageUrls.length-1){e.resetPosition.call(e);return}e.positionXNumber=D.I18nManager.isRTL?e.standardPositionX+e.width:e.standardPositionX-e.width,e.standardPositionX=e.positionXNumber,D.Animated.timing(e.positionX,{toValue:e.positionXNumber,duration:e.props.pageAnimateTime,useNativeDriver:!!e.props.useNativeDriver}).start();var t=(e.state.currentShowIndex||0)+1;e.setState({currentShowIndex:t},function(){e.props.onChange&&e.props.onChange(e.state.currentShowIndex)})},e.handleLongPress=function(t){e.props.saveToLocalByLongPress&&e.setState({isShowMenu:!0}),e.props.onLongPress&&e.props.onLongPress(t)},e.handleClick=function(){e.props.onClick&&e.props.onClick(e.handleCancel,e.state.currentShowIndex)},e.handleDoubleClick=function(){e.props.onDoubleClick&&e.props.onDoubleClick(e.handleCancel)},e.handleCancel=function(){e.hasLayout=!1,e.props.onCancel&&e.props.onCancel()},e.handleLayout=function(t){t.nativeEvent.layout.width!==e.width&&(e.hasLayout=!0,e.width=t.nativeEvent.layout.width,e.height=t.nativeEvent.layout.height,e.styles=Uf.default(e.width,e.height,e.props.backgroundColor||"transparent"),e.forceUpdate(),e.jumpToCurrentImage())},e.saveToLocal=function(){e.props.onSave?e.props.onSave(e.props.imageUrls[e.state.currentShowIndex||0].url):(D.CameraRoll.saveToCameraRoll(e.props.imageUrls[e.state.currentShowIndex||0].url),e.props.onSaveToCamera(e.state.currentShowIndex)),e.setState({isShowMenu:!1})},e.handleLeaveMenu=function(){e.setState({isShowMenu:!1})},e.handleSwipeDown=function(){e.props.onSwipeDown&&e.props.onSwipeDown(),e.handleCancel()},e}return n.prototype.componentDidMount=function(){this.init(this.props)},n.getDerivedStateFromProps=function(e,t){return e.index!==t.prevIndexProp?{currentShowIndex:e.index,prevIndexProp:e.index}:null},n.prototype.componentDidUpdate=function(e,t){e.index!==this.props.index&&(this.loadImage(this.props.index||0),this.jumpToCurrentImage(),D.Animated.timing(this.fadeAnim,{toValue:1,duration:200,useNativeDriver:!!this.props.useNativeDriver}).start())},n.prototype.init=function(e){var t=this;if(e.imageUrls.length===0)return this.fadeAnim.setValue(0),this.setState(new Ya.State);var o=[];e.imageUrls.forEach(function(i){o.push({width:i.width||0,height:i.height||0,status:"loading"})}),this.setState({currentShowIndex:e.index,prevIndexProp:e.index||0,imageSizes:o},function(){t.loadImage(e.index||0),t.jumpToCurrentImage(),D.Animated.timing(t.fadeAnim,{toValue:1,duration:200,useNativeDriver:!!e.useNativeDriver}).start()})},n.prototype.jumpToCurrentImage=function(){this.positionXNumber=this.width*(this.state.currentShowIndex||0)*(D.I18nManager.isRTL?1:-1),this.standardPositionX=this.positionXNumber,this.positionX.setValue(this.positionXNumber)},n.prototype.loadImage=function(e){var t=this;if(this.state.imageSizes[e]&&!this.loadedIndex.has(e)){this.loadedIndex.set(e,!0);var o=this.props.imageUrls[e],i=nn({},this.state.imageSizes[e]),a=function(){if(!(t.state.imageSizes[e]&&t.state.imageSizes[e].status!=="loading")){var p=t.state.imageSizes.slice();p[e]=i,t.setState({imageSizes:p})}};if(this.state.imageSizes[e].status!=="success"){if(this.state.imageSizes[e].width>0&&this.state.imageSizes[e].height>0){i.status="success",a();return}var c=!1,h=!1;if((!o.url||o.url.startsWith("file:"))&&(h=!0),o.width&&o.height){this.props.enablePreload&&h===!1&&D.Image.prefetch(o.url),i.width=o.width,i.height=o.height,i.status="success",a();return}D.Image.getSize(o.url,function(p,d){i.width=p,i.height=d,i.status="success",a()},function(){try{var p=D.Image.resolveAssetSource(o.props.source);i.width=p.width,i.height=p.height,i.status="success",a()}catch{i.status="fail",a()}})}}},n.prototype.resetPosition=function(){this.positionXNumber=this.standardPositionX,D.Animated.timing(this.positionX,{toValue:this.standardPositionX,duration:150,useNativeDriver:!!this.props.useNativeDriver}).start()},n.prototype.getContent=function(){var e=this,t=this.width,o=this.height,i=this.props.imageUrls.map(function(a,c){if((e.state.currentShowIndex||0)>c+1||(e.state.currentShowIndex||0)<c-1)return F.createElement(D.View,{key:c,style:{width:t,height:o}});e.handleLongPressWithIndex.has(c)||e.handleLongPressWithIndex.set(c,e.handleLongPress.bind(e,a));var h=e.state.imageSizes[c]&&e.state.imageSizes[c].width,p=e.state.imageSizes[c]&&e.state.imageSizes[c].height,d=e.state.imageSizes[c];if(!d||!d.status)return F.createElement(D.View,{key:c,style:{width:t,height:o}});if(h>t){var f=t/h;h*=f,p*=f}if(p>o){var y=o/p;h*=y,p*=y}var C=function(I){var v=I.children,g=Kv(I,["children"]);return F.createElement(zf.default,{cropWidth:e.width,cropHeight:e.height,maxOverflow:e.props.maxOverflow,horizontalOuterRangeOffset:e.handleHorizontalOuterRangeOffset,responderRelease:e.handleResponderRelease,onMove:e.props.onMove,onLongPress:e.handleLongPressWithIndex.get(c),onClick:e.handleClick,onDoubleClick:e.handleDoubleClick,enableSwipeDown:e.props.enableSwipeDown,swipeDownThreshold:e.props.swipeDownThreshold,onSwipeDown:e.handleSwipeDown,pinchToZoom:e.props.enableImageZoom,enableDoubleClickZoom:e.props.enableImageZoom,doubleClickInterval:e.props.doubleClickInterval,...g},v)};switch(d.status){case"loading":return F.createElement(C,{key:c,style:nn({},e.styles.modalContainer,e.styles.loadingContainer),imageWidth:t,imageHeight:o},F.createElement(D.View,{style:e.styles.loadingContainer},e.props.loadingRender()));case"success":return a.props||(a.props={}),a.props.style||(a.props.style={}),a.props.style=nn({},e.styles.imageStyle,a.props.style,{width:h,height:p}),typeof a.props.source=="number"||(a.props.source||(a.props.source={}),a.props.source=nn({uri:a.url},a.props.source)),e.props.enablePreload&&e.preloadImage(e.state.currentShowIndex||0),F.createElement(zf.default,{key:c,ref:function(I){return e.imageRefs[c]=I},cropWidth:e.width,cropHeight:e.height,maxOverflow:e.props.maxOverflow,horizontalOuterRangeOffset:e.handleHorizontalOuterRangeOffset,responderRelease:e.handleResponderRelease,onMove:e.props.onMove,onLongPress:e.handleLongPressWithIndex.get(c),onClick:e.handleClick,onDoubleClick:e.handleDoubleClick,imageWidth:h,imageHeight:p,enableSwipeDown:e.props.enableSwipeDown,swipeDownThreshold:e.props.swipeDownThreshold,onSwipeDown:e.handleSwipeDown,panToMove:!e.state.isShowMenu,pinchToZoom:e.props.enableImageZoom&&!e.state.isShowMenu,enableDoubleClickZoom:e.props.enableImageZoom&&!e.state.isShowMenu,doubleClickInterval:e.props.doubleClickInterval,minScale:e.props.minScale,maxScale:e.props.maxScale},e.props.renderImage(a.props));case"fail":return F.createElement(C,{key:c,style:e.styles.modalContainer,imageWidth:e.props.failImageSource?e.props.failImageSource.width:t,imageHeight:e.props.failImageSource?e.props.failImageSource.height:o},e.props.failImageSource&&e.props.renderImage({source:{uri:e.props.failImageSource.url},style:{width:e.props.failImageSource.width,height:e.props.failImageSource.height}}))}});return F.createElement(D.Animated.View,{style:{zIndex:9}},F.createElement(D.Animated.View,{style:nn({},this.styles.container,{opacity:this.fadeAnim})},this.props.renderHeader(this.state.currentShowIndex),F.createElement(D.View,{style:this.styles.arrowLeftContainer},F.createElement(D.TouchableWithoutFeedback,{onPress:this.goBack},F.createElement(D.View,null,this.props.renderArrowLeft()))),F.createElement(D.View,{style:this.styles.arrowRightContainer},F.createElement(D.TouchableWithoutFeedback,{onPress:this.goNext},F.createElement(D.View,null,this.props.renderArrowRight()))),F.createElement(D.Animated.View,{style:nn({},this.styles.moveBox,{transform:[{translateX:this.positionX}],width:this.width*this.props.imageUrls.length})},i),this.props.renderIndicator((this.state.currentShowIndex||0)+1,this.props.imageUrls.length),this.props.imageUrls[this.state.currentShowIndex||0]&&this.props.imageUrls[this.state.currentShowIndex||0].originSizeKb&&this.props.imageUrls[this.state.currentShowIndex||0].originUrl&&F.createElement(D.View,{style:this.styles.watchOrigin},F.createElement(D.TouchableOpacity,{style:this.styles.watchOriginTouchable},F.createElement(D.Text,{style:this.styles.watchOriginText},"\u67E5\u770B\u539F\u56FE(2M)"))),F.createElement(D.View,{style:[{bottom:0,position:"absolute",zIndex:9},this.props.footerContainerStyle]},this.props.renderFooter(this.state.currentShowIndex||0))))},n.prototype.getMenu=function(){return this.state.isShowMenu?this.props.menus?F.createElement(D.View,{style:this.styles.menuContainer},this.props.menus({cancel:this.handleLeaveMenu,saveToLocal:this.saveToLocal})):F.createElement(D.View,{style:this.styles.menuContainer},F.createElement(D.View,{style:this.styles.menuShadow}),F.createElement(D.View,{style:this.styles.menuContent},F.createElement(D.TouchableHighlight,{underlayColor:"#F2F2F2",onPress:this.saveToLocal,style:this.styles.operateContainer},F.createElement(D.Text,{style:this.styles.operateText},this.props.menuContext.saveToLocal)),F.createElement(D.TouchableHighlight,{underlayColor:"#F2F2F2",onPress:this.handleLeaveMenu,style:this.styles.operateContainer},F.createElement(D.Text,{style:this.styles.operateText},this.props.menuContext.cancel)))):null},n.prototype.render=function(){var e=null;return e=F.createElement(D.View,null,this.getContent(),this.getMenu()),F.createElement(D.View,{onLayout:this.handleLayout,style:nn({flex:1,overflow:"hidden"},this.props.style)},e)},n.defaultProps=new Ya.Props,n}(F.Component);yt.default=Wv});var Kf=De(Hr=>{"use strict";s();Object.defineProperty(Hr,"__esModule",{value:!0});var Ff=Yf();Hr.ImageViewer=Ff.default;var Vv=Ua();Hr.ImageViewerPropsDefine=Vv.Props;Hr.default=Ff.default});s();var ja=P(Ve());s();function Su(){return`https://${lt.services.content.host}`}s();var x=P(k());s();var yo=P(k()),vo=P(Xm()),Zm=2e3;function wu(){let[r,n]=yo.useState(!1);return yo.useEffect(()=>{let e=window.setTimeout(()=>(0,vo.unstable_runWithPriority)(vo.unstable_IdlePriority,()=>n(!0)),Zm);return()=>{clearTimeout(e)}},[]),r}s();var Cu=P(k());function Ru(r){let{enabled:n,children:e}=r;return Cu.createElement(Ss.Provider,{value:n},e)}s();var Kt=P(k()),wo=P(Ve());s();var bo=P(k()),So=P(Ve());var eh=qr.createResponsiveComponent(So.TouchableOpacity);function Pu(r){let[,n]=St(rh),{close:e}=pn(),{isMobile:t}=Jr(),o=r.closeable||t,i=()=>{r.onClose&&r.onClose(),e(r.id)},a=xs({mount:th,unmount:nh});return bo.createElement(So.View,{ref:a},bo.createElement(eh,{mobileStyle:n.toastMobile,desktopStyle:n.toastDesktop,onPress:()=>{r.onOpen&&r.onOpen(),o&&i()}},bo.createElement(Ts,{...r,onClose:o?i:void 0,style:n.alert,mainBackground:!0})))}var th={duration:bi.TRANSITION_DURATION_SHORT,frames:{0:{opacity:0,transform:[{translateY:100}]},1:{opacity:1,transform:[{translateY:0}]}}},nh={duration:bi.TRANSITION_DURATION_SHORT,frames:{0:{opacity:1,transform:[{translateY:0}]},1:{opacity:0,transform:[{translateY:100}]}}},rh=Wr.create({toastDesktop:{width:"auto",minWidth:420,maxWidth:720,marginBottom:J.small},toastMobile:{width:"100%",minWidth:0},alert:r=>({...r.shadows.pop,borderColor:r.colors.border.main})});function Iu(r){let n=ut(Gr),e=ut(Ns),t=Kt.useRef(null),o=ah[n];return Kt.createElement(Ze,{ref:t},Kt.createElement(qr.View,{style:[ih.toaster],mobileStyle:o.mobile,desktopStyle:o.desktop},Kt.createElement(Es,null,e.map(i=>Kt.createElement(Pu,{...i,key:i.id})))))}var ih=wo.StyleSheet.create({toaster:{position:"fixed",zIndex:200}}),ah={"bottom-right":wo.StyleSheet.create({desktop:{bottom:J.medium,right:J.medium},mobile:{bottom:J.medium,right:J.medium,left:J.medium}}),"bottom-right-with-bar":wo.StyleSheet.create({desktop:{bottom:J.xxlarge,right:J.medium},mobile:{bottom:J.xxlarge+J.xlarge+J.medium,right:J.medium,left:J.medium}})};s();var Ou=P(k());function ku(r){let n=Je(Gr);Ou.useEffect(()=>{r&&n(r)},[n,r])}s();var fr=P(k());function Au(){let r=ut(uc);return fr.createElement(fr.Fragment,null,r.map(n=>fr.createElement(sc,{...n})))}s();function xu(r,n){let e=[],t=0;for(;t<r.length;)e.push(r.slice(t,t+n)),t+=n;return e}function Eu(r){let n=r.reduce((o,i)=>o+i.length,0),e=new Uint8Array(n),t=0;return r.forEach(o=>{e.set(o,t),t+=o.length}),e}s();function Tu(r,n){let{pageId:e,rename:t=!1}=n;return{...structuredClone(r),id:e,title:t?to(`Copy of ${r.title}`):r.title,git:void 0,pages:r.type==="link"?void 0:[]}}s();function Du(r,n,e){return new URL(`/content/${n}/blobs/${e.blobId}/${e.name}`,r).toString()}s();s();function Pt(r,n,e={}){let t;if(e.into){let o=R.getIn(r,["pages",e.into]);if(!o||!no(o))throw new Error(`Cannot insert page into ${e.into}`);t=R.get(o,"pages")}else t=R.getIn(r,["rootPages"]);if(!t)throw new Error(`Cannot insert page into ${e.into}`);e.at!==void 0?R.insert(t,e.at,[n.id]):R.push(t,[n.id]),R.setIn(r,["pages",n.id],be(r)?tt(n):n)}function _u(r,n,e){let t=ro(r,e),o=t?R.get(t,"pages"):R.get(r,"rootPages"),i=R.findIndex(o,c=>c===e);if(i<0)return{at:i};let a=t?R.get(t,"id"):void 0;return n==="after"?{into:a,at:i+1}:{into:a,at:i}}function Mu(r,n,e){let t=_u(r,"before",e);if(!(t.at===void 0||t?.at<0))return Pt(r,n,t)}function Co(r,n,e){let t=_u(r,"after",e);if(!(t.at===void 0||t?.at<0))return Pt(r,n,t)}s();function $e(r,n,e){let t=R.getIn(r,["pages",n]);if(t)if(typeof e=="function"){e(t);return}else Object.entries(e).forEach(([o,i])=>{R.set(t,o,be(r)?tt(i):i)})}function Hu(r,n,e){$e(r,n,t=>{if(!Ii(t))return;let o=kc(ie(t));R.set(t,"layout",{...o,...e})})}function Nu(r,n,e){$e(r,n,{title:to(e)})}function Bu(r,n,e){$e(r,n,t=>{Ii(t)&&R.set(t,"description",Oc(e))})}function Di(r,n){let{originalPageId:e,parentPageId:t}=n,o=n.newPageId||hn(),i=R.getIn(r,["pages",e]);if(!i)return;let a=Tu(be(i)?ie(i):i,{pageId:o,rename:!t});t?Pt(r,a,{into:t}):Co(r,a,e);let c;if(no(i)){let h=R.get(i,"pages");c=R.map(h,p=>{let d=hn();return Di(r,{originalPageId:p,parentPageId:a.id,newPageId:d}),d})}return $e(r,a.id,{pages:c}),o}s();function Lu(r,n){if(R.getIn(r,["files",n.id]))throw new Error("File with same ID already exists in revision");let t=R.get(r,"files");R.set(t,n.id,n)}function zu(r,n){R.delIn(r,["files",n])}function Uu(r,n,e){let t=R.getIn(r,["files",n]);if(!t)throw new Error("File doesn't exist in revision");Object.entries(e).forEach(([o,i])=>{o==="downloadURL"&&i!==R.get(t,"downloadURL")&&!("blobId"in e)&&R.del(t,"blobId"),R.set(t,o,be(r)?tt(i):i)})}s();var nt=W("normalizeRevision");function Ro(r){let n=R.get(r,"id"),e=R.get(r,"contentId"),t=new Be("hive.normalizeRevision");return t.setLabels({contentId:e,revisionId:n}),t.wrapSync(()=>{let o=R.get(r,"pages"),i=R.get(r,"files"),a=R.get(r,"rootPages"),c=R.get(r,"conflicts"),h=R.values(R.get(r,"parents")),p=new Set(R.keys(o)),d;if(h.length>3)throw new Error(`Revision ${e}/${n} has more than 3 parents`);if(h.includes(n)){let g=h.filter(b=>b!==n);if(g.length===0)throw new Error(`Revision ${e}/${n} has no more parents after removing itself as parent`);R.set(r,"parents",g),nt.warning(`${e}/${n}: updated parents to remove itself as parent. New parents:`,g)}let f=R.get(r,"customFields");f?Yu(f):R.set(r,"customFields",{});let y=g=>{let b=[];if(g.forEach(A=>{I(A)&&b.push(A)}),b.length!==g.length)return b},C=g=>{let b=R.get(i,g);if(!b)return;if(!R.get(b,"downloadURL")){R.del(i,g),nt.warning(`${e}/${n}: no downloadURL for file ${g}`);return}},I=g=>{if(!p.has(g))return!1;p.delete(g);let b=R.get(o,g);if(!b)return!1;let A=R.get(b,"customFields");if(A&&Yu(A),R.get(b,"type")==="link")return sh(e,n,g,b),!0;let E=b;if(R.get(b,"type")==="document"){let B=b;R.get(B,"slug")&&ch(e,n,g,B),d===void 0&&(d=R.get(b,"id"))}let N=y(R.get(E,"pages"));return N&&(R.set(E,"pages",N),nt.warning(`${e}/${n}: updated children for page ${g}. New children pages:`,N)),!0},v=y(a);if(v&&(R.set(r,"rootPages",v),nt.warning(`${e}/${n}: normalized rootPages. New root pages:`,v)),p.size>0){let g=Array.from(p);R.push(a,g),nt.warning(`${e}/${n}: made pages with invalid parent into rootPages. Pages:`,g)}if(!d){let g=Ic();Pt(r,g),nt.warning(`${e}/${n}: created empty page document ${g.id} as none were found. `)}for(let g of R.keys(i))C(g);if(c!==void 0){let g=R.get(c,"pages"),b=R.keys(g),A=b.reduce((E,N)=>{let B=R.get(o,N);return!B||R.get(B,"type")==="link"||R.get(B,"type")==="group"?E.add(N):E},new Set);A.size>0&&(A.size===b.length?(R.del(r,"conflicts"),nt.warning(`${e}/${n}: normalized conflicts. All were invalid and have been removed.`)):(A.forEach(E=>{R.del(g,E)}),nt.warning(`${e}/${n}: normalized conflicts. New conflicts:`,c)))}})}function Yu(r){for(let[n,e]of R.entries(r)){let t=R.get(e,"value");typeof t!="string"&&typeof t!="number"&&typeof t!="boolean"&&!Array.isArray(ie(t))&&R.del(r,n)}}function sh(r,n,e,t){let o=R.get(t,"target");(typeof o!="object"||typeof R.get(o,"kind")!="string")&&(nt.warning(`${r}/${n}: normalized invalid link ${e}, with target ${JSON.stringify(ie(o))}`),R.set(t,"type","document"),R.set(t,"pages",[]),R.del(t,"target"))}function ch(r,n,e,t){let o=R.get(t,"slug");o&&!Xs(o)&&(nt.warning(`${r}/${n}: normalized invalid slug ${e}, with slug ${ie(o)}`),R.set(t,"slug",Qs(o)))}s();function Fu(r,n,e=void 0){$e(r,n,t=>{if(R.get(t,"type")!=="document")return;let i={ref:e,yPos:0};R.set(t,"cover",be(r)?tt(i):i)})}function Ku(r,n){$e(r,n,e=>{R.get(e,"type")==="document"&&R.del(e,"cover")})}function Wu(r,n,e){$e(r,n,t=>{if(R.get(t,"type")!=="document")return;let i=R.get(t,"cover");i&&R.set(i,"yPos",e)})}s();function Vu(r){R.get(r,"customFields")||R.set(r,"customFields",{})}function Ju(r,n){Vu(r),Gu(r,n)}function qu(r,n,e){let t=R.getIn(r,["pages",n]);t&&(Vu(t),Gu(t,e))}function Gu(r,n){Object.entries(n).forEach(([e,t])=>{R.getIn(r,["customFields",e])?R.setIn(r,["customFields",e,"value"],t.value):R.setIn(r,["customFields",e],be(r)?tt(t):t)})}s();function $u(r,n){let e=R.get(r,"edits");R.set(r,"edits",sr(e,Array.isArray(n)?n:[n]))}s();function ju(r,n,e){let t=R.getIn(r,["pages",n,"edits"]);if(!t)return;let o=Array.isArray(e)?sr(t,e):typeof e=="string"?sr(t,[e]):Pc(t,e);R.setIn(r,["pages",n,"edits"],o)}s();function Po(r){return r.getMap("data")}s();var Xu=Ue(r=>({id:r.get("id"),type:r.get("type"),contentId:r.get("contentId"),conflicts:ie(r.get("conflicts")),parents:r.get("parents").toArray(),mergedFrom:r.get("mergedFrom"),rolledBackBy:r.get("rolledBackBy"),git:ie(r.get("git")),rootPages:r.get("rootPages").toArray(),pages:lh(r.get("pages")),files:uh(r.get("files")),edits:ie(r.get("edits")),customFields:ie(r.get("customFields"))})),lh=Ue(r=>{let n={};return r.forEach((e,t)=>{n[t]=be(e)?Qu(e):ie(e)}),n}),uh=Ue(r=>{let n={};return r.forEach((e,t)=>{n[t]=be(e)?Qu(e):ie(e)}),n}),Qu=Ue(r=>ie(r));s();var Zu={insertPage:Pt,insertPageAfter:Co,insertPageBefore:Mu,removePage:xc,updatePage:$e,updatePageLayout:Hu,movePage:Ec,movePageAfter:Dc,movePageBefore:Tc,addPageCover:Fu,removePageCover:Ku,movePageCover:Wu,renamePage:Nu,setPageDescription:Bu,duplicatePage:Di,resolveConflict:Mc,insertFile:Lu,removeFile:zu,updateFile:Uu,getPageParent:ro,getUniquePageTitle:Hc,updateRevisionCustomFields:Ju,updatePageCustomFields:qu,markRevisionAsEdited:$u,markPageAsEdited:ju};function ed(r){let n={revision:r};for(let e in Zu)n[e]=(...t)=>Zu[e](r,...t);return n}s();var Ot={};jm(Ot,{AICompletionHistoryEntry:()=>xh,AICompletionReply:()=>Ah,AICompletionRequest:()=>kh,AckMessage:()=>hh,BlockRichTextCompletion:()=>Nh,BroadcastOperationMessage:()=>yh,BroadcastPresencesMessage:()=>gh,ContentOperation:()=>Ch,ContentOperationStatus:()=>Bh,DebugLog:()=>Rh,DebugLogUpdate:()=>Ph,DocumentCompletions:()=>_i,GenerateBlockCompletionReply:()=>Th,GenerateBlockCompletionRequest:()=>Eh,GenerateDiagramReply:()=>Hh,GenerateDiagramRequest:()=>Mh,GenerateDiagramSuggestionsReply:()=>_h,GenerateDiagramSuggestionsRequest:()=>Dh,InitMessage:()=>ph,Message:()=>It,Presence:()=>wh,PromptInitMessage:()=>dh,RPCError:()=>Sh,RPCReplyMessage:()=>bh,RPCRequestMessage:()=>vh,StopAICompletionReply:()=>Oh,StopAICompletionRequest:()=>Ih,StoredUpdate:()=>td,UpdateFormatVersion:()=>rt,UpdateMessage:()=>fh,UpdatePresenceMessage:()=>mh,default:()=>m});s();var H=P(Qm()),w=H.Reader,V=H.Writer,l=H.util,m=H.roots.default||(H.roots.default={}),dh=m.PromptInitMessage=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id=0,r.prototype.index=0,r.prototype.count=0,r.prototype.stateVector=l.newBuffer([]),r.prototype.version=0,r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(8).int32(e.id),e.index!=null&&Object.hasOwnProperty.call(e,"index")&&t.uint32(16).int32(e.index),e.count!=null&&Object.hasOwnProperty.call(e,"count")&&t.uint32(24).int32(e.count),t.uint32(34).bytes(e.stateVector),e.version!=null&&Object.hasOwnProperty.call(e,"version")&&t.uint32(40).int32(e.version),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.PromptInitMessage;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.id=e.int32();break}case 2:{i.index=e.int32();break}case 3:{i.count=e.int32();break}case 4:{i.stateVector=e.bytes();break}case 5:{i.version=e.int32();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});if(!i.hasOwnProperty("stateVector"))throw l.ProtocolError("missing required 'stateVector'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!l.isInteger(e.id))return"id: integer expected";if(e.index!=null&&e.hasOwnProperty("index")&&!l.isInteger(e.index))return"index: integer expected";if(e.count!=null&&e.hasOwnProperty("count")&&!l.isInteger(e.count))return"count: integer expected";if(!(e.stateVector&&typeof e.stateVector.length=="number"||l.isString(e.stateVector)))return"stateVector: buffer expected";if(e.version!=null&&e.hasOwnProperty("version"))switch(e.version){default:return"version: enum value expected";case 0:case 1:case 2:break}return null},r.fromObject=function(e){if(e instanceof m.PromptInitMessage)return e;let t=new m.PromptInitMessage;switch(e.id!=null&&(t.id=e.id|0),e.index!=null&&(t.index=e.index|0),e.count!=null&&(t.count=e.count|0),e.stateVector!=null&&(typeof e.stateVector=="string"?l.base64.decode(e.stateVector,t.stateVector=l.newBuffer(l.base64.length(e.stateVector)),0):e.stateVector.length>=0&&(t.stateVector=e.stateVector)),e.version){default:if(typeof e.version=="number"){t.version=e.version;break}break;case"UNSPECIFIED":case 0:t.version=0;break;case"V1":case 1:t.version=1;break;case"V2":case 2:t.version=2;break}return t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.id=0,o.index=0,o.count=0,t.bytes===String?o.stateVector="":(o.stateVector=[],t.bytes!==Array&&(o.stateVector=l.newBuffer(o.stateVector))),o.version=t.enums===String?"UNSPECIFIED":0),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),e.index!=null&&e.hasOwnProperty("index")&&(o.index=e.index),e.count!=null&&e.hasOwnProperty("count")&&(o.count=e.count),e.stateVector!=null&&e.hasOwnProperty("stateVector")&&(o.stateVector=t.bytes===String?l.base64.encode(e.stateVector,0,e.stateVector.length):t.bytes===Array?Array.prototype.slice.call(e.stateVector):e.stateVector),e.version!=null&&e.hasOwnProperty("version")&&(o.version=t.enums===String?m.UpdateFormatVersion[e.version]===void 0?e.version:m.UpdateFormatVersion[e.version]:e.version),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/PromptInitMessage"},r})(),ph=m.InitMessage=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id=0,r.prototype.index=0,r.prototype.count=0,r.prototype.update=l.newBuffer([]),r.prototype.version=0,r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(8).int32(e.id),e.index!=null&&Object.hasOwnProperty.call(e,"index")&&t.uint32(16).int32(e.index),e.count!=null&&Object.hasOwnProperty.call(e,"count")&&t.uint32(24).int32(e.count),t.uint32(34).bytes(e.update),e.version!=null&&Object.hasOwnProperty.call(e,"version")&&t.uint32(40).int32(e.version),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.InitMessage;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.id=e.int32();break}case 2:{i.index=e.int32();break}case 3:{i.count=e.int32();break}case 4:{i.update=e.bytes();break}case 5:{i.version=e.int32();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});if(!i.hasOwnProperty("update"))throw l.ProtocolError("missing required 'update'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!l.isInteger(e.id))return"id: integer expected";if(e.index!=null&&e.hasOwnProperty("index")&&!l.isInteger(e.index))return"index: integer expected";if(e.count!=null&&e.hasOwnProperty("count")&&!l.isInteger(e.count))return"count: integer expected";if(!(e.update&&typeof e.update.length=="number"||l.isString(e.update)))return"update: buffer expected";if(e.version!=null&&e.hasOwnProperty("version"))switch(e.version){default:return"version: enum value expected";case 0:case 1:case 2:break}return null},r.fromObject=function(e){if(e instanceof m.InitMessage)return e;let t=new m.InitMessage;switch(e.id!=null&&(t.id=e.id|0),e.index!=null&&(t.index=e.index|0),e.count!=null&&(t.count=e.count|0),e.update!=null&&(typeof e.update=="string"?l.base64.decode(e.update,t.update=l.newBuffer(l.base64.length(e.update)),0):e.update.length>=0&&(t.update=e.update)),e.version){default:if(typeof e.version=="number"){t.version=e.version;break}break;case"UNSPECIFIED":case 0:t.version=0;break;case"V1":case 1:t.version=1;break;case"V2":case 2:t.version=2;break}return t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.id=0,o.index=0,o.count=0,t.bytes===String?o.update="":(o.update=[],t.bytes!==Array&&(o.update=l.newBuffer(o.update))),o.version=t.enums===String?"UNSPECIFIED":0),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),e.index!=null&&e.hasOwnProperty("index")&&(o.index=e.index),e.count!=null&&e.hasOwnProperty("count")&&(o.count=e.count),e.update!=null&&e.hasOwnProperty("update")&&(o.update=t.bytes===String?l.base64.encode(e.update,0,e.update.length):t.bytes===Array?Array.prototype.slice.call(e.update):e.update),e.version!=null&&e.hasOwnProperty("version")&&(o.version=t.enums===String?m.UpdateFormatVersion[e.version]===void 0?e.version:m.UpdateFormatVersion[e.version]:e.version),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/InitMessage"},r})(),fh=m.UpdateMessage=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id=0,r.prototype.index=0,r.prototype.count=0,r.prototype.update=l.newBuffer([]),r.prototype.version=0,r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(8).int32(e.id),e.index!=null&&Object.hasOwnProperty.call(e,"index")&&t.uint32(16).int32(e.index),e.count!=null&&Object.hasOwnProperty.call(e,"count")&&t.uint32(24).int32(e.count),t.uint32(34).bytes(e.update),e.version!=null&&Object.hasOwnProperty.call(e,"version")&&t.uint32(40).int32(e.version),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.UpdateMessage;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.id=e.int32();break}case 2:{i.index=e.int32();break}case 3:{i.count=e.int32();break}case 4:{i.update=e.bytes();break}case 5:{i.version=e.int32();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});if(!i.hasOwnProperty("update"))throw l.ProtocolError("missing required 'update'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!l.isInteger(e.id))return"id: integer expected";if(e.index!=null&&e.hasOwnProperty("index")&&!l.isInteger(e.index))return"index: integer expected";if(e.count!=null&&e.hasOwnProperty("count")&&!l.isInteger(e.count))return"count: integer expected";if(!(e.update&&typeof e.update.length=="number"||l.isString(e.update)))return"update: buffer expected";if(e.version!=null&&e.hasOwnProperty("version"))switch(e.version){default:return"version: enum value expected";case 0:case 1:case 2:break}return null},r.fromObject=function(e){if(e instanceof m.UpdateMessage)return e;let t=new m.UpdateMessage;switch(e.id!=null&&(t.id=e.id|0),e.index!=null&&(t.index=e.index|0),e.count!=null&&(t.count=e.count|0),e.update!=null&&(typeof e.update=="string"?l.base64.decode(e.update,t.update=l.newBuffer(l.base64.length(e.update)),0):e.update.length>=0&&(t.update=e.update)),e.version){default:if(typeof e.version=="number"){t.version=e.version;break}break;case"UNSPECIFIED":case 0:t.version=0;break;case"V1":case 1:t.version=1;break;case"V2":case 2:t.version=2;break}return t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.id=0,o.index=0,o.count=0,t.bytes===String?o.update="":(o.update=[],t.bytes!==Array&&(o.update=l.newBuffer(o.update))),o.version=t.enums===String?"UNSPECIFIED":0),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),e.index!=null&&e.hasOwnProperty("index")&&(o.index=e.index),e.count!=null&&e.hasOwnProperty("count")&&(o.count=e.count),e.update!=null&&e.hasOwnProperty("update")&&(o.update=t.bytes===String?l.base64.encode(e.update,0,e.update.length):t.bytes===Array?Array.prototype.slice.call(e.update):e.update),e.version!=null&&e.hasOwnProperty("version")&&(o.version=t.enums===String?m.UpdateFormatVersion[e.version]===void 0?e.version:m.UpdateFormatVersion[e.version]:e.version),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/UpdateMessage"},r})(),td=m.StoredUpdate=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.update=l.newBuffer([]),r.prototype.version=0,r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(18).bytes(e.update),t.uint32(24).int32(e.version),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.StoredUpdate;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 2:{i.update=e.bytes();break}case 3:{i.version=e.int32();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("update"))throw l.ProtocolError("missing required 'update'",{instance:i});if(!i.hasOwnProperty("version"))throw l.ProtocolError("missing required 'version'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!(e.update&&typeof e.update.length=="number"||l.isString(e.update)))return"update: buffer expected";switch(e.version){default:return"version: enum value expected";case 0:case 1:case 2:break}return null},r.fromObject=function(e){if(e instanceof m.StoredUpdate)return e;let t=new m.StoredUpdate;switch(e.update!=null&&(typeof e.update=="string"?l.base64.decode(e.update,t.update=l.newBuffer(l.base64.length(e.update)),0):e.update.length>=0&&(t.update=e.update)),e.version){default:if(typeof e.version=="number"){t.version=e.version;break}break;case"UNSPECIFIED":case 0:t.version=0;break;case"V1":case 1:t.version=1;break;case"V2":case 2:t.version=2;break}return t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(t.bytes===String?o.update="":(o.update=[],t.bytes!==Array&&(o.update=l.newBuffer(o.update))),o.version=t.enums===String?"UNSPECIFIED":0),e.update!=null&&e.hasOwnProperty("update")&&(o.update=t.bytes===String?l.base64.encode(e.update,0,e.update.length):t.bytes===Array?Array.prototype.slice.call(e.update):e.update),e.version!=null&&e.hasOwnProperty("version")&&(o.version=t.enums===String?m.UpdateFormatVersion[e.version]===void 0?e.version:m.UpdateFormatVersion[e.version]:e.version),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/StoredUpdate"},r})(),mh=m.UpdatePresenceMessage=(()=>{function r(n){if(this.data={},this.positions={},n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id=0,r.prototype.data=l.emptyObject,r.prototype.positions=l.emptyObject,r.create=function(e){return new r(e)},r.encode=function(e,t){if(t||(t=V.create()),t.uint32(8).int32(e.id),e.data!=null&&Object.hasOwnProperty.call(e,"data"))for(let o=Object.keys(e.data),i=0;i<o.length;++i)t.uint32(18).fork().uint32(10).string(o[i]).uint32(18).string(e.data[o[i]]).ldelim();if(e.positions!=null&&Object.hasOwnProperty.call(e,"positions"))for(let o=Object.keys(e.positions),i=0;i<o.length;++i)t.uint32(26).fork().uint32(10).string(o[i]).uint32(18).bytes(e.positions[o[i]]).ldelim();return t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.UpdatePresenceMessage,a,c;for(;e.pos<o;){let h=e.uint32();switch(h>>>3){case 1:{i.id=e.int32();break}case 2:{i.data===l.emptyObject&&(i.data={});let p=e.uint32()+e.pos;for(a="",c="";e.pos<p;){let d=e.uint32();switch(d>>>3){case 1:a=e.string();break;case 2:c=e.string();break;default:e.skipType(d&7);break}}i.data[a]=c;break}case 3:{i.positions===l.emptyObject&&(i.positions={});let p=e.uint32()+e.pos;for(a="",c=[];e.pos<p;){let d=e.uint32();switch(d>>>3){case 1:a=e.string();break;case 2:c=e.bytes();break;default:e.skipType(d&7);break}}i.positions[a]=c;break}default:e.skipType(h&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!l.isInteger(e.id))return"id: integer expected";if(e.data!=null&&e.hasOwnProperty("data")){if(!l.isObject(e.data))return"data: object expected";let t=Object.keys(e.data);for(let o=0;o<t.length;++o)if(!l.isString(e.data[t[o]]))return"data: string{k:string} expected"}if(e.positions!=null&&e.hasOwnProperty("positions")){if(!l.isObject(e.positions))return"positions: object expected";let t=Object.keys(e.positions);for(let o=0;o<t.length;++o)if(!(e.positions[t[o]]&&typeof e.positions[t[o]].length=="number"||l.isString(e.positions[t[o]])))return"positions: buffer{k:string} expected"}return null},r.fromObject=function(e){if(e instanceof m.UpdatePresenceMessage)return e;let t=new m.UpdatePresenceMessage;if(e.id!=null&&(t.id=e.id|0),e.data){if(typeof e.data!="object")throw TypeError(".UpdatePresenceMessage.data: object expected");t.data={};for(let o=Object.keys(e.data),i=0;i<o.length;++i)t.data[o[i]]=String(e.data[o[i]])}if(e.positions){if(typeof e.positions!="object")throw TypeError(".UpdatePresenceMessage.positions: object expected");t.positions={};for(let o=Object.keys(e.positions),i=0;i<o.length;++i)typeof e.positions[o[i]]=="string"?l.base64.decode(e.positions[o[i]],t.positions[o[i]]=l.newBuffer(l.base64.length(e.positions[o[i]])),0):e.positions[o[i]].length>=0&&(t.positions[o[i]]=e.positions[o[i]])}return t},r.toObject=function(e,t){t||(t={});let o={};(t.objects||t.defaults)&&(o.data={},o.positions={}),t.defaults&&(o.id=0),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id);let i;if(e.data&&(i=Object.keys(e.data)).length){o.data={};for(let a=0;a<i.length;++a)o.data[i[a]]=e.data[i[a]]}if(e.positions&&(i=Object.keys(e.positions)).length){o.positions={};for(let a=0;a<i.length;++a)o.positions[i[a]]=t.bytes===String?l.base64.encode(e.positions[i[a]],0,e.positions[i[a]].length):t.bytes===Array?Array.prototype.slice.call(e.positions[i[a]]):e.positions[i[a]]}return o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/UpdatePresenceMessage"},r})(),hh=m.AckMessage=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id=0,r.prototype.message=0,r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(8).int32(e.id),t.uint32(16).int32(e.message),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.AckMessage;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.id=e.int32();break}case 2:{i.message=e.int32();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});if(!i.hasOwnProperty("message"))throw l.ProtocolError("missing required 'message'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":l.isInteger(e.id)?l.isInteger(e.message)?null:"message: integer expected":"id: integer expected"},r.fromObject=function(e){if(e instanceof m.AckMessage)return e;let t=new m.AckMessage;return e.id!=null&&(t.id=e.id|0),e.message!=null&&(t.message=e.message|0),t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.id=0,o.message=0),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),e.message!=null&&e.hasOwnProperty("message")&&(o.message=e.message),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/AckMessage"},r})(),gh=m.BroadcastPresencesMessage=(()=>{function r(n){if(this.presences={},n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id=0,r.prototype.presences=l.emptyObject,r.prototype.selfClientId="",r.create=function(e){return new r(e)},r.encode=function(e,t){if(t||(t=V.create()),t.uint32(8).int32(e.id),e.presences!=null&&Object.hasOwnProperty.call(e,"presences"))for(let o=Object.keys(e.presences),i=0;i<o.length;++i)t.uint32(18).fork().uint32(10).string(o[i]),m.Presence.encode(e.presences[o[i]],t.uint32(18).fork()).ldelim().ldelim();return t.uint32(26).string(e.selfClientId),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.BroadcastPresencesMessage,a,c;for(;e.pos<o;){let h=e.uint32();switch(h>>>3){case 1:{i.id=e.int32();break}case 2:{i.presences===l.emptyObject&&(i.presences={});let p=e.uint32()+e.pos;for(a="",c=null;e.pos<p;){let d=e.uint32();switch(d>>>3){case 1:a=e.string();break;case 2:c=m.Presence.decode(e,e.uint32());break;default:e.skipType(d&7);break}}i.presences[a]=c;break}case 3:{i.selfClientId=e.string();break}default:e.skipType(h&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});if(!i.hasOwnProperty("selfClientId"))throw l.ProtocolError("missing required 'selfClientId'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!l.isInteger(e.id))return"id: integer expected";if(e.presences!=null&&e.hasOwnProperty("presences")){if(!l.isObject(e.presences))return"presences: object expected";let t=Object.keys(e.presences);for(let o=0;o<t.length;++o){let i=m.Presence.verify(e.presences[t[o]]);if(i)return"presences."+i}}return l.isString(e.selfClientId)?null:"selfClientId: string expected"},r.fromObject=function(e){if(e instanceof m.BroadcastPresencesMessage)return e;let t=new m.BroadcastPresencesMessage;if(e.id!=null&&(t.id=e.id|0),e.presences){if(typeof e.presences!="object")throw TypeError(".BroadcastPresencesMessage.presences: object expected");t.presences={};for(let o=Object.keys(e.presences),i=0;i<o.length;++i){if(typeof e.presences[o[i]]!="object")throw TypeError(".BroadcastPresencesMessage.presences: object expected");t.presences[o[i]]=m.Presence.fromObject(e.presences[o[i]])}}return e.selfClientId!=null&&(t.selfClientId=String(e.selfClientId)),t},r.toObject=function(e,t){t||(t={});let o={};(t.objects||t.defaults)&&(o.presences={}),t.defaults&&(o.id=0,o.selfClientId=""),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id);let i;if(e.presences&&(i=Object.keys(e.presences)).length){o.presences={};for(let a=0;a<i.length;++a)o.presences[i[a]]=m.Presence.toObject(e.presences[i[a]],t)}return e.selfClientId!=null&&e.hasOwnProperty("selfClientId")&&(o.selfClientId=e.selfClientId),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/BroadcastPresencesMessage"},r})(),yh=m.BroadcastOperationMessage=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id=0,r.prototype.operation=null,r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(8).int32(e.id),m.ContentOperation.encode(e.operation,t.uint32(18).fork()).ldelim(),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.BroadcastOperationMessage;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.id=e.int32();break}case 2:{i.operation=m.ContentOperation.decode(e,e.uint32());break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});if(!i.hasOwnProperty("operation"))throw l.ProtocolError("missing required 'operation'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!l.isInteger(e.id))return"id: integer expected";{let t=m.ContentOperation.verify(e.operation);if(t)return"operation."+t}return null},r.fromObject=function(e){if(e instanceof m.BroadcastOperationMessage)return e;let t=new m.BroadcastOperationMessage;if(e.id!=null&&(t.id=e.id|0),e.operation!=null){if(typeof e.operation!="object")throw TypeError(".BroadcastOperationMessage.operation: object expected");t.operation=m.ContentOperation.fromObject(e.operation)}return t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.id=0,o.operation=null),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),e.operation!=null&&e.hasOwnProperty("operation")&&(o.operation=m.ContentOperation.toObject(e.operation,t)),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/BroadcastOperationMessage"},r})(),vh=m.RPCRequestMessage=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id=0,r.prototype.service="",r.prototype.method="",r.prototype.payload=l.newBuffer([]),r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(8).int32(e.id),t.uint32(18).string(e.service),t.uint32(26).string(e.method),t.uint32(34).bytes(e.payload),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.RPCRequestMessage;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.id=e.int32();break}case 2:{i.service=e.string();break}case 3:{i.method=e.string();break}case 4:{i.payload=e.bytes();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});if(!i.hasOwnProperty("service"))throw l.ProtocolError("missing required 'service'",{instance:i});if(!i.hasOwnProperty("method"))throw l.ProtocolError("missing required 'method'",{instance:i});if(!i.hasOwnProperty("payload"))throw l.ProtocolError("missing required 'payload'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":l.isInteger(e.id)?l.isString(e.service)?l.isString(e.method)?e.payload&&typeof e.payload.length=="number"||l.isString(e.payload)?null:"payload: buffer expected":"method: string expected":"service: string expected":"id: integer expected"},r.fromObject=function(e){if(e instanceof m.RPCRequestMessage)return e;let t=new m.RPCRequestMessage;return e.id!=null&&(t.id=e.id|0),e.service!=null&&(t.service=String(e.service)),e.method!=null&&(t.method=String(e.method)),e.payload!=null&&(typeof e.payload=="string"?l.base64.decode(e.payload,t.payload=l.newBuffer(l.base64.length(e.payload)),0):e.payload.length>=0&&(t.payload=e.payload)),t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.id=0,o.service="",o.method="",t.bytes===String?o.payload="":(o.payload=[],t.bytes!==Array&&(o.payload=l.newBuffer(o.payload)))),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),e.service!=null&&e.hasOwnProperty("service")&&(o.service=e.service),e.method!=null&&e.hasOwnProperty("method")&&(o.method=e.method),e.payload!=null&&e.hasOwnProperty("payload")&&(o.payload=t.bytes===String?l.base64.encode(e.payload,0,e.payload.length):t.bytes===Array?Array.prototype.slice.call(e.payload):e.payload),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RPCRequestMessage"},r})(),bh=m.RPCReplyMessage=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id=0,r.prototype.replyTo=0,r.prototype.payload=l.newBuffer([]),r.prototype.error=null,r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(8).int32(e.id),t.uint32(16).int32(e.replyTo),e.payload!=null&&Object.hasOwnProperty.call(e,"payload")&&t.uint32(26).bytes(e.payload),e.error!=null&&Object.hasOwnProperty.call(e,"error")&&m.RPCError.encode(e.error,t.uint32(34).fork()).ldelim(),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.RPCReplyMessage;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.id=e.int32();break}case 2:{i.replyTo=e.int32();break}case 3:{i.payload=e.bytes();break}case 4:{i.error=m.RPCError.decode(e,e.uint32());break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});if(!i.hasOwnProperty("replyTo"))throw l.ProtocolError("missing required 'replyTo'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!l.isInteger(e.id))return"id: integer expected";if(!l.isInteger(e.replyTo))return"replyTo: integer expected";if(e.payload!=null&&e.hasOwnProperty("payload")&&!(e.payload&&typeof e.payload.length=="number"||l.isString(e.payload)))return"payload: buffer expected";if(e.error!=null&&e.hasOwnProperty("error")){let t=m.RPCError.verify(e.error);if(t)return"error."+t}return null},r.fromObject=function(e){if(e instanceof m.RPCReplyMessage)return e;let t=new m.RPCReplyMessage;if(e.id!=null&&(t.id=e.id|0),e.replyTo!=null&&(t.replyTo=e.replyTo|0),e.payload!=null&&(typeof e.payload=="string"?l.base64.decode(e.payload,t.payload=l.newBuffer(l.base64.length(e.payload)),0):e.payload.length>=0&&(t.payload=e.payload)),e.error!=null){if(typeof e.error!="object")throw TypeError(".RPCReplyMessage.error: object expected");t.error=m.RPCError.fromObject(e.error)}return t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.id=0,o.replyTo=0,t.bytes===String?o.payload="":(o.payload=[],t.bytes!==Array&&(o.payload=l.newBuffer(o.payload))),o.error=null),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),e.replyTo!=null&&e.hasOwnProperty("replyTo")&&(o.replyTo=e.replyTo),e.payload!=null&&e.hasOwnProperty("payload")&&(o.payload=t.bytes===String?l.base64.encode(e.payload,0,e.payload.length):t.bytes===Array?Array.prototype.slice.call(e.payload):e.payload),e.error!=null&&e.hasOwnProperty("error")&&(o.error=m.RPCError.toObject(e.error,t)),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RPCReplyMessage"},r})(),Sh=m.RPCError=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.code=0,r.prototype.message="",r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(8).int32(e.code),t.uint32(18).string(e.message),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.RPCError;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.code=e.int32();break}case 2:{i.message=e.string();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("code"))throw l.ProtocolError("missing required 'code'",{instance:i});if(!i.hasOwnProperty("message"))throw l.ProtocolError("missing required 'message'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":l.isInteger(e.code)?l.isString(e.message)?null:"message: string expected":"code: integer expected"},r.fromObject=function(e){if(e instanceof m.RPCError)return e;let t=new m.RPCError;return e.code!=null&&(t.code=e.code|0),e.message!=null&&(t.message=String(e.message)),t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.code=0,o.message=""),e.code!=null&&e.hasOwnProperty("code")&&(o.code=e.code),e.message!=null&&e.hasOwnProperty("message")&&(o.message=e.message),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RPCError"},r})(),It=m.Message=(()=>{function r(e){if(e)for(let t=Object.keys(e),o=0;o<t.length;++o)e[t[o]]!=null&&(this[t[o]]=e[t[o]])}r.prototype.promptInit=null,r.prototype.init=null,r.prototype.update=null,r.prototype.updatePresence=null,r.prototype.broadcastPresences=null,r.prototype.broadcastOperation=null,r.prototype.ack=null,r.prototype.rpcRequest=null,r.prototype.rpcReply=null;let n;return Object.defineProperty(r.prototype,"message",{get:l.oneOfGetter(n=["promptInit","init","update","updatePresence","broadcastPresences","broadcastOperation","ack","rpcRequest","rpcReply"]),set:l.oneOfSetter(n)}),r.create=function(t){return new r(t)},r.encode=function(t,o){return o||(o=V.create()),t.promptInit!=null&&Object.hasOwnProperty.call(t,"promptInit")&&m.PromptInitMessage.encode(t.promptInit,o.uint32(10).fork()).ldelim(),t.init!=null&&Object.hasOwnProperty.call(t,"init")&&m.InitMessage.encode(t.init,o.uint32(18).fork()).ldelim(),t.update!=null&&Object.hasOwnProperty.call(t,"update")&&m.UpdateMessage.encode(t.update,o.uint32(26).fork()).ldelim(),t.updatePresence!=null&&Object.hasOwnProperty.call(t,"updatePresence")&&m.UpdatePresenceMessage.encode(t.updatePresence,o.uint32(34).fork()).ldelim(),t.broadcastPresences!=null&&Object.hasOwnProperty.call(t,"broadcastPresences")&&m.BroadcastPresencesMessage.encode(t.broadcastPresences,o.uint32(42).fork()).ldelim(),t.broadcastOperation!=null&&Object.hasOwnProperty.call(t,"broadcastOperation")&&m.BroadcastOperationMessage.encode(t.broadcastOperation,o.uint32(50).fork()).ldelim(),t.ack!=null&&Object.hasOwnProperty.call(t,"ack")&&m.AckMessage.encode(t.ack,o.uint32(58).fork()).ldelim(),t.rpcRequest!=null&&Object.hasOwnProperty.call(t,"rpcRequest")&&m.RPCRequestMessage.encode(t.rpcRequest,o.uint32(66).fork()).ldelim(),t.rpcReply!=null&&Object.hasOwnProperty.call(t,"rpcReply")&&m.RPCReplyMessage.encode(t.rpcReply,o.uint32(74).fork()).ldelim(),o},r.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},r.decode=function(t,o){t instanceof w||(t=w.create(t));let i=o===void 0?t.len:t.pos+o,a=new m.Message;for(;t.pos<i;){let c=t.uint32();switch(c>>>3){case 1:{a.promptInit=m.PromptInitMessage.decode(t,t.uint32());break}case 2:{a.init=m.InitMessage.decode(t,t.uint32());break}case 3:{a.update=m.UpdateMessage.decode(t,t.uint32());break}case 4:{a.updatePresence=m.UpdatePresenceMessage.decode(t,t.uint32());break}case 5:{a.broadcastPresences=m.BroadcastPresencesMessage.decode(t,t.uint32());break}case 6:{a.broadcastOperation=m.BroadcastOperationMessage.decode(t,t.uint32());break}case 7:{a.ack=m.AckMessage.decode(t,t.uint32());break}case 8:{a.rpcRequest=m.RPCRequestMessage.decode(t,t.uint32());break}case 9:{a.rpcReply=m.RPCReplyMessage.decode(t,t.uint32());break}default:t.skipType(c&7);break}}return a},r.decodeDelimited=function(t){return t instanceof w||(t=new w(t)),this.decode(t,t.uint32())},r.verify=function(t){if(typeof t!="object"||t===null)return"object expected";let o={};if(t.promptInit!=null&&t.hasOwnProperty("promptInit")){o.message=1;{let i=m.PromptInitMessage.verify(t.promptInit);if(i)return"promptInit."+i}}if(t.init!=null&&t.hasOwnProperty("init")){if(o.message===1)return"message: multiple values";o.message=1;{let i=m.InitMessage.verify(t.init);if(i)return"init."+i}}if(t.update!=null&&t.hasOwnProperty("update")){if(o.message===1)return"message: multiple values";o.message=1;{let i=m.UpdateMessage.verify(t.update);if(i)return"update."+i}}if(t.updatePresence!=null&&t.hasOwnProperty("updatePresence")){if(o.message===1)return"message: multiple values";o.message=1;{let i=m.UpdatePresenceMessage.verify(t.updatePresence);if(i)return"updatePresence."+i}}if(t.broadcastPresences!=null&&t.hasOwnProperty("broadcastPresences")){if(o.message===1)return"message: multiple values";o.message=1;{let i=m.BroadcastPresencesMessage.verify(t.broadcastPresences);if(i)return"broadcastPresences."+i}}if(t.broadcastOperation!=null&&t.hasOwnProperty("broadcastOperation")){if(o.message===1)return"message: multiple values";o.message=1;{let i=m.BroadcastOperationMessage.verify(t.broadcastOperation);if(i)return"broadcastOperation."+i}}if(t.ack!=null&&t.hasOwnProperty("ack")){if(o.message===1)return"message: multiple values";o.message=1;{let i=m.AckMessage.verify(t.ack);if(i)return"ack."+i}}if(t.rpcRequest!=null&&t.hasOwnProperty("rpcRequest")){if(o.message===1)return"message: multiple values";o.message=1;{let i=m.RPCRequestMessage.verify(t.rpcRequest);if(i)return"rpcRequest."+i}}if(t.rpcReply!=null&&t.hasOwnProperty("rpcReply")){if(o.message===1)return"message: multiple values";o.message=1;{let i=m.RPCReplyMessage.verify(t.rpcReply);if(i)return"rpcReply."+i}}return null},r.fromObject=function(t){if(t instanceof m.Message)return t;let o=new m.Message;if(t.promptInit!=null){if(typeof t.promptInit!="object")throw TypeError(".Message.promptInit: object expected");o.promptInit=m.PromptInitMessage.fromObject(t.promptInit)}if(t.init!=null){if(typeof t.init!="object")throw TypeError(".Message.init: object expected");o.init=m.InitMessage.fromObject(t.init)}if(t.update!=null){if(typeof t.update!="object")throw TypeError(".Message.update: object expected");o.update=m.UpdateMessage.fromObject(t.update)}if(t.updatePresence!=null){if(typeof t.updatePresence!="object")throw TypeError(".Message.updatePresence: object expected");o.updatePresence=m.UpdatePresenceMessage.fromObject(t.updatePresence)}if(t.broadcastPresences!=null){if(typeof t.broadcastPresences!="object")throw TypeError(".Message.broadcastPresences: object expected");o.broadcastPresences=m.BroadcastPresencesMessage.fromObject(t.broadcastPresences)}if(t.broadcastOperation!=null){if(typeof t.broadcastOperation!="object")throw TypeError(".Message.broadcastOperation: object expected");o.broadcastOperation=m.BroadcastOperationMessage.fromObject(t.broadcastOperation)}if(t.ack!=null){if(typeof t.ack!="object")throw TypeError(".Message.ack: object expected");o.ack=m.AckMessage.fromObject(t.ack)}if(t.rpcRequest!=null){if(typeof t.rpcRequest!="object")throw TypeError(".Message.rpcRequest: object expected");o.rpcRequest=m.RPCRequestMessage.fromObject(t.rpcRequest)}if(t.rpcReply!=null){if(typeof t.rpcReply!="object")throw TypeError(".Message.rpcReply: object expected");o.rpcReply=m.RPCReplyMessage.fromObject(t.rpcReply)}return o},r.toObject=function(t,o){o||(o={});let i={};return t.promptInit!=null&&t.hasOwnProperty("promptInit")&&(i.promptInit=m.PromptInitMessage.toObject(t.promptInit,o),o.oneofs&&(i.message="promptInit")),t.init!=null&&t.hasOwnProperty("init")&&(i.init=m.InitMessage.toObject(t.init,o),o.oneofs&&(i.message="init")),t.update!=null&&t.hasOwnProperty("update")&&(i.update=m.UpdateMessage.toObject(t.update,o),o.oneofs&&(i.message="update")),t.updatePresence!=null&&t.hasOwnProperty("updatePresence")&&(i.updatePresence=m.UpdatePresenceMessage.toObject(t.updatePresence,o),o.oneofs&&(i.message="updatePresence")),t.broadcastPresences!=null&&t.hasOwnProperty("broadcastPresences")&&(i.broadcastPresences=m.BroadcastPresencesMessage.toObject(t.broadcastPresences,o),o.oneofs&&(i.message="broadcastPresences")),t.broadcastOperation!=null&&t.hasOwnProperty("broadcastOperation")&&(i.broadcastOperation=m.BroadcastOperationMessage.toObject(t.broadcastOperation,o),o.oneofs&&(i.message="broadcastOperation")),t.ack!=null&&t.hasOwnProperty("ack")&&(i.ack=m.AckMessage.toObject(t.ack,o),o.oneofs&&(i.message="ack")),t.rpcRequest!=null&&t.hasOwnProperty("rpcRequest")&&(i.rpcRequest=m.RPCRequestMessage.toObject(t.rpcRequest,o),o.oneofs&&(i.message="rpcRequest")),t.rpcReply!=null&&t.hasOwnProperty("rpcReply")&&(i.rpcReply=m.RPCReplyMessage.toObject(t.rpcReply,o),o.oneofs&&(i.message="rpcReply")),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/Message"},r})(),wh=m.Presence=(()=>{function r(n){if(this.data={},this.positions={},n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.data=l.emptyObject,r.prototype.joinTimestamp=l.Long?l.Long.fromBits(0,0,!1):0,r.prototype.updateTimestamp=l.Long?l.Long.fromBits(0,0,!1):0,r.prototype.clientId="",r.prototype.positions=l.emptyObject,r.create=function(e){return new r(e)},r.encode=function(e,t){if(t||(t=V.create()),e.data!=null&&Object.hasOwnProperty.call(e,"data"))for(let o=Object.keys(e.data),i=0;i<o.length;++i)t.uint32(10).fork().uint32(10).string(o[i]).uint32(18).string(e.data[o[i]]).ldelim();if(t.uint32(16).int64(e.joinTimestamp),t.uint32(24).int64(e.updateTimestamp),t.uint32(34).string(e.clientId),e.positions!=null&&Object.hasOwnProperty.call(e,"positions"))for(let o=Object.keys(e.positions),i=0;i<o.length;++i)t.uint32(42).fork().uint32(10).string(o[i]).uint32(18).bytes(e.positions[o[i]]).ldelim();return t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.Presence,a,c;for(;e.pos<o;){let h=e.uint32();switch(h>>>3){case 1:{i.data===l.emptyObject&&(i.data={});let p=e.uint32()+e.pos;for(a="",c="";e.pos<p;){let d=e.uint32();switch(d>>>3){case 1:a=e.string();break;case 2:c=e.string();break;default:e.skipType(d&7);break}}i.data[a]=c;break}case 2:{i.joinTimestamp=e.int64();break}case 3:{i.updateTimestamp=e.int64();break}case 4:{i.clientId=e.string();break}case 5:{i.positions===l.emptyObject&&(i.positions={});let p=e.uint32()+e.pos;for(a="",c=[];e.pos<p;){let d=e.uint32();switch(d>>>3){case 1:a=e.string();break;case 2:c=e.bytes();break;default:e.skipType(d&7);break}}i.positions[a]=c;break}default:e.skipType(h&7);break}}if(!i.hasOwnProperty("joinTimestamp"))throw l.ProtocolError("missing required 'joinTimestamp'",{instance:i});if(!i.hasOwnProperty("updateTimestamp"))throw l.ProtocolError("missing required 'updateTimestamp'",{instance:i});if(!i.hasOwnProperty("clientId"))throw l.ProtocolError("missing required 'clientId'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.data!=null&&e.hasOwnProperty("data")){if(!l.isObject(e.data))return"data: object expected";let t=Object.keys(e.data);for(let o=0;o<t.length;++o)if(!l.isString(e.data[t[o]]))return"data: string{k:string} expected"}if(!l.isInteger(e.joinTimestamp)&&!(e.joinTimestamp&&l.isInteger(e.joinTimestamp.low)&&l.isInteger(e.joinTimestamp.high)))return"joinTimestamp: integer|Long expected";if(!l.isInteger(e.updateTimestamp)&&!(e.updateTimestamp&&l.isInteger(e.updateTimestamp.low)&&l.isInteger(e.updateTimestamp.high)))return"updateTimestamp: integer|Long expected";if(!l.isString(e.clientId))return"clientId: string expected";if(e.positions!=null&&e.hasOwnProperty("positions")){if(!l.isObject(e.positions))return"positions: object expected";let t=Object.keys(e.positions);for(let o=0;o<t.length;++o)if(!(e.positions[t[o]]&&typeof e.positions[t[o]].length=="number"||l.isString(e.positions[t[o]])))return"positions: buffer{k:string} expected"}return null},r.fromObject=function(e){if(e instanceof m.Presence)return e;let t=new m.Presence;if(e.data){if(typeof e.data!="object")throw TypeError(".Presence.data: object expected");t.data={};for(let o=Object.keys(e.data),i=0;i<o.length;++i)t.data[o[i]]=String(e.data[o[i]])}if(e.joinTimestamp!=null&&(l.Long?(t.joinTimestamp=l.Long.fromValue(e.joinTimestamp)).unsigned=!1:typeof e.joinTimestamp=="string"?t.joinTimestamp=parseInt(e.joinTimestamp,10):typeof e.joinTimestamp=="number"?t.joinTimestamp=e.joinTimestamp:typeof e.joinTimestamp=="object"&&(t.joinTimestamp=new l.LongBits(e.joinTimestamp.low>>>0,e.joinTimestamp.high>>>0).toNumber())),e.updateTimestamp!=null&&(l.Long?(t.updateTimestamp=l.Long.fromValue(e.updateTimestamp)).unsigned=!1:typeof e.updateTimestamp=="string"?t.updateTimestamp=parseInt(e.updateTimestamp,10):typeof e.updateTimestamp=="number"?t.updateTimestamp=e.updateTimestamp:typeof e.updateTimestamp=="object"&&(t.updateTimestamp=new l.LongBits(e.updateTimestamp.low>>>0,e.updateTimestamp.high>>>0).toNumber())),e.clientId!=null&&(t.clientId=String(e.clientId)),e.positions){if(typeof e.positions!="object")throw TypeError(".Presence.positions: object expected");t.positions={};for(let o=Object.keys(e.positions),i=0;i<o.length;++i)typeof e.positions[o[i]]=="string"?l.base64.decode(e.positions[o[i]],t.positions[o[i]]=l.newBuffer(l.base64.length(e.positions[o[i]])),0):e.positions[o[i]].length>=0&&(t.positions[o[i]]=e.positions[o[i]])}return t},r.toObject=function(e,t){t||(t={});let o={};if((t.objects||t.defaults)&&(o.data={},o.positions={}),t.defaults){if(l.Long){let a=new l.Long(0,0,!1);o.joinTimestamp=t.longs===String?a.toString():t.longs===Number?a.toNumber():a}else o.joinTimestamp=t.longs===String?"0":0;if(l.Long){let a=new l.Long(0,0,!1);o.updateTimestamp=t.longs===String?a.toString():t.longs===Number?a.toNumber():a}else o.updateTimestamp=t.longs===String?"0":0;o.clientId=""}let i;if(e.data&&(i=Object.keys(e.data)).length){o.data={};for(let a=0;a<i.length;++a)o.data[i[a]]=e.data[i[a]]}if(e.joinTimestamp!=null&&e.hasOwnProperty("joinTimestamp")&&(typeof e.joinTimestamp=="number"?o.joinTimestamp=t.longs===String?String(e.joinTimestamp):e.joinTimestamp:o.joinTimestamp=t.longs===String?l.Long.prototype.toString.call(e.joinTimestamp):t.longs===Number?new l.LongBits(e.joinTimestamp.low>>>0,e.joinTimestamp.high>>>0).toNumber():e.joinTimestamp),e.updateTimestamp!=null&&e.hasOwnProperty("updateTimestamp")&&(typeof e.updateTimestamp=="number"?o.updateTimestamp=t.longs===String?String(e.updateTimestamp):e.updateTimestamp:o.updateTimestamp=t.longs===String?l.Long.prototype.toString.call(e.updateTimestamp):t.longs===Number?new l.LongBits(e.updateTimestamp.low>>>0,e.updateTimestamp.high>>>0).toNumber():e.updateTimestamp),e.clientId!=null&&e.hasOwnProperty("clientId")&&(o.clientId=e.clientId),e.positions&&(i=Object.keys(e.positions)).length){o.positions={};for(let a=0;a<i.length;++a)o.positions[i[a]]=t.bytes===String?l.base64.encode(e.positions[i[a]],0,e.positions[i[a]].length):t.bytes===Array?Array.prototype.slice.call(e.positions[i[a]]):e.positions[i[a]]}return o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/Presence"},r})(),Ch=m.ContentOperation=(()=>{function r(n){if(this.payload={},n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id="",r.prototype.status=0,r.prototype.createdAt=l.Long?l.Long.fromBits(0,0,!1):0,r.prototype.updatedAt=l.Long?l.Long.fromBits(0,0,!1):0,r.prototype.updateId=0,r.prototype.expireAfter=0,r.prototype.cursor=0,r.prototype.target=0,r.prototype.payload=l.emptyObject,r.create=function(e){return new r(e)},r.encode=function(e,t){if(t||(t=V.create()),t.uint32(10).string(e.id),t.uint32(16).int32(e.status),t.uint32(24).int64(e.createdAt),t.uint32(32).int64(e.updatedAt),t.uint32(40).int32(e.updateId),t.uint32(48).int32(e.expireAfter),t.uint32(56).int32(e.cursor),t.uint32(64).int32(e.target),e.payload!=null&&Object.hasOwnProperty.call(e,"payload"))for(let o=Object.keys(e.payload),i=0;i<o.length;++i)t.uint32(74).fork().uint32(10).string(o[i]).uint32(18).string(e.payload[o[i]]).ldelim();return t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.ContentOperation,a,c;for(;e.pos<o;){let h=e.uint32();switch(h>>>3){case 1:{i.id=e.string();break}case 2:{i.status=e.int32();break}case 3:{i.createdAt=e.int64();break}case 4:{i.updatedAt=e.int64();break}case 5:{i.updateId=e.int32();break}case 6:{i.expireAfter=e.int32();break}case 7:{i.cursor=e.int32();break}case 8:{i.target=e.int32();break}case 9:{i.payload===l.emptyObject&&(i.payload={});let p=e.uint32()+e.pos;for(a="",c="";e.pos<p;){let d=e.uint32();switch(d>>>3){case 1:a=e.string();break;case 2:c=e.string();break;default:e.skipType(d&7);break}}i.payload[a]=c;break}default:e.skipType(h&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});if(!i.hasOwnProperty("status"))throw l.ProtocolError("missing required 'status'",{instance:i});if(!i.hasOwnProperty("createdAt"))throw l.ProtocolError("missing required 'createdAt'",{instance:i});if(!i.hasOwnProperty("updatedAt"))throw l.ProtocolError("missing required 'updatedAt'",{instance:i});if(!i.hasOwnProperty("updateId"))throw l.ProtocolError("missing required 'updateId'",{instance:i});if(!i.hasOwnProperty("expireAfter"))throw l.ProtocolError("missing required 'expireAfter'",{instance:i});if(!i.hasOwnProperty("cursor"))throw l.ProtocolError("missing required 'cursor'",{instance:i});if(!i.hasOwnProperty("target"))throw l.ProtocolError("missing required 'target'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!l.isString(e.id))return"id: string expected";switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:break}if(!l.isInteger(e.createdAt)&&!(e.createdAt&&l.isInteger(e.createdAt.low)&&l.isInteger(e.createdAt.high)))return"createdAt: integer|Long expected";if(!l.isInteger(e.updatedAt)&&!(e.updatedAt&&l.isInteger(e.updatedAt.low)&&l.isInteger(e.updatedAt.high)))return"updatedAt: integer|Long expected";if(!l.isInteger(e.updateId))return"updateId: integer expected";if(!l.isInteger(e.expireAfter))return"expireAfter: integer expected";if(!l.isInteger(e.cursor))return"cursor: integer expected";if(!l.isInteger(e.target))return"target: integer expected";if(e.payload!=null&&e.hasOwnProperty("payload")){if(!l.isObject(e.payload))return"payload: object expected";let t=Object.keys(e.payload);for(let o=0;o<t.length;++o)if(!l.isString(e.payload[t[o]]))return"payload: string{k:string} expected"}return null},r.fromObject=function(e){if(e instanceof m.ContentOperation)return e;let t=new m.ContentOperation;switch(e.id!=null&&(t.id=String(e.id)),e.status){default:if(typeof e.status=="number"){t.status=e.status;break}break;case"STARTING":case 0:t.status=0;break;case"RUNNING":case 1:t.status=1;break;case"SUCCESS":case 2:t.status=2;break;case"ERROR":case 3:t.status=3;break}if(e.createdAt!=null&&(l.Long?(t.createdAt=l.Long.fromValue(e.createdAt)).unsigned=!1:typeof e.createdAt=="string"?t.createdAt=parseInt(e.createdAt,10):typeof e.createdAt=="number"?t.createdAt=e.createdAt:typeof e.createdAt=="object"&&(t.createdAt=new l.LongBits(e.createdAt.low>>>0,e.createdAt.high>>>0).toNumber())),e.updatedAt!=null&&(l.Long?(t.updatedAt=l.Long.fromValue(e.updatedAt)).unsigned=!1:typeof e.updatedAt=="string"?t.updatedAt=parseInt(e.updatedAt,10):typeof e.updatedAt=="number"?t.updatedAt=e.updatedAt:typeof e.updatedAt=="object"&&(t.updatedAt=new l.LongBits(e.updatedAt.low>>>0,e.updatedAt.high>>>0).toNumber())),e.updateId!=null&&(t.updateId=e.updateId|0),e.expireAfter!=null&&(t.expireAfter=e.expireAfter|0),e.cursor!=null&&(t.cursor=e.cursor|0),e.target!=null&&(t.target=e.target|0),e.payload){if(typeof e.payload!="object")throw TypeError(".ContentOperation.payload: object expected");t.payload={};for(let o=Object.keys(e.payload),i=0;i<o.length;++i)t.payload[o[i]]=String(e.payload[o[i]])}return t},r.toObject=function(e,t){t||(t={});let o={};if((t.objects||t.defaults)&&(o.payload={}),t.defaults){if(o.id="",o.status=t.enums===String?"STARTING":0,l.Long){let a=new l.Long(0,0,!1);o.createdAt=t.longs===String?a.toString():t.longs===Number?a.toNumber():a}else o.createdAt=t.longs===String?"0":0;if(l.Long){let a=new l.Long(0,0,!1);o.updatedAt=t.longs===String?a.toString():t.longs===Number?a.toNumber():a}else o.updatedAt=t.longs===String?"0":0;o.updateId=0,o.expireAfter=0,o.cursor=0,o.target=0}e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),e.status!=null&&e.hasOwnProperty("status")&&(o.status=t.enums===String?m.ContentOperationStatus[e.status]===void 0?e.status:m.ContentOperationStatus[e.status]:e.status),e.createdAt!=null&&e.hasOwnProperty("createdAt")&&(typeof e.createdAt=="number"?o.createdAt=t.longs===String?String(e.createdAt):e.createdAt:o.createdAt=t.longs===String?l.Long.prototype.toString.call(e.createdAt):t.longs===Number?new l.LongBits(e.createdAt.low>>>0,e.createdAt.high>>>0).toNumber():e.createdAt),e.updatedAt!=null&&e.hasOwnProperty("updatedAt")&&(typeof e.updatedAt=="number"?o.updatedAt=t.longs===String?String(e.updatedAt):e.updatedAt:o.updatedAt=t.longs===String?l.Long.prototype.toString.call(e.updatedAt):t.longs===Number?new l.LongBits(e.updatedAt.low>>>0,e.updatedAt.high>>>0).toNumber():e.updatedAt),e.updateId!=null&&e.hasOwnProperty("updateId")&&(o.updateId=e.updateId),e.expireAfter!=null&&e.hasOwnProperty("expireAfter")&&(o.expireAfter=e.expireAfter),e.cursor!=null&&e.hasOwnProperty("cursor")&&(o.cursor=e.cursor),e.target!=null&&e.hasOwnProperty("target")&&(o.target=e.target);let i;if(e.payload&&(i=Object.keys(e.payload)).length){o.payload={};for(let a=0;a<i.length;++a)o.payload[i[a]]=e.payload[i[a]]}return o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/ContentOperation"},r})(),Rh=m.DebugLog=(()=>{function r(n){if(this.updates=[],n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.updates=l.emptyArray,r.create=function(e){return new r(e)},r.encode=function(e,t){if(t||(t=V.create()),e.updates!=null&&e.updates.length)for(let o=0;o<e.updates.length;++o)m.DebugLogUpdate.encode(e.updates[o],t.uint32(10).fork()).ldelim();return t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.DebugLog;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.updates&&i.updates.length||(i.updates=[]),i.updates.push(m.DebugLogUpdate.decode(e,e.uint32()));break}default:e.skipType(a&7);break}}return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.updates!=null&&e.hasOwnProperty("updates")){if(!Array.isArray(e.updates))return"updates: array expected";for(let t=0;t<e.updates.length;++t){let o=m.DebugLogUpdate.verify(e.updates[t]);if(o)return"updates."+o}}return null},r.fromObject=function(e){if(e instanceof m.DebugLog)return e;let t=new m.DebugLog;if(e.updates){if(!Array.isArray(e.updates))throw TypeError(".DebugLog.updates: array expected");t.updates=[];for(let o=0;o<e.updates.length;++o){if(typeof e.updates[o]!="object")throw TypeError(".DebugLog.updates: object expected");t.updates[o]=m.DebugLogUpdate.fromObject(e.updates[o])}}return t},r.toObject=function(e,t){t||(t={});let o={};if((t.arrays||t.defaults)&&(o.updates=[]),e.updates&&e.updates.length){o.updates=[];for(let i=0;i<e.updates.length;++i)o.updates[i]=m.DebugLogUpdate.toObject(e.updates[i],t)}return o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/DebugLog"},r})(),Ph=m.DebugLogUpdate=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.timestamp=l.Long?l.Long.fromBits(0,0,!1):0,r.prototype.update=l.newBuffer([]),r.prototype.origin="",r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(8).int64(e.timestamp),t.uint32(18).bytes(e.update),t.uint32(26).string(e.origin),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.DebugLogUpdate;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.timestamp=e.int64();break}case 2:{i.update=e.bytes();break}case 3:{i.origin=e.string();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("timestamp"))throw l.ProtocolError("missing required 'timestamp'",{instance:i});if(!i.hasOwnProperty("update"))throw l.ProtocolError("missing required 'update'",{instance:i});if(!i.hasOwnProperty("origin"))throw l.ProtocolError("missing required 'origin'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":!l.isInteger(e.timestamp)&&!(e.timestamp&&l.isInteger(e.timestamp.low)&&l.isInteger(e.timestamp.high))?"timestamp: integer|Long expected":e.update&&typeof e.update.length=="number"||l.isString(e.update)?l.isString(e.origin)?null:"origin: string expected":"update: buffer expected"},r.fromObject=function(e){if(e instanceof m.DebugLogUpdate)return e;let t=new m.DebugLogUpdate;return e.timestamp!=null&&(l.Long?(t.timestamp=l.Long.fromValue(e.timestamp)).unsigned=!1:typeof e.timestamp=="string"?t.timestamp=parseInt(e.timestamp,10):typeof e.timestamp=="number"?t.timestamp=e.timestamp:typeof e.timestamp=="object"&&(t.timestamp=new l.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber())),e.update!=null&&(typeof e.update=="string"?l.base64.decode(e.update,t.update=l.newBuffer(l.base64.length(e.update)),0):e.update.length>=0&&(t.update=e.update)),e.origin!=null&&(t.origin=String(e.origin)),t},r.toObject=function(e,t){t||(t={});let o={};if(t.defaults){if(l.Long){let i=new l.Long(0,0,!1);o.timestamp=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else o.timestamp=t.longs===String?"0":0;t.bytes===String?o.update="":(o.update=[],t.bytes!==Array&&(o.update=l.newBuffer(o.update))),o.origin=""}return e.timestamp!=null&&e.hasOwnProperty("timestamp")&&(typeof e.timestamp=="number"?o.timestamp=t.longs===String?String(e.timestamp):e.timestamp:o.timestamp=t.longs===String?l.Long.prototype.toString.call(e.timestamp):t.longs===Number?new l.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber():e.timestamp),e.update!=null&&e.hasOwnProperty("update")&&(o.update=t.bytes===String?l.base64.encode(e.update,0,e.update.length):t.bytes===Array?Array.prototype.slice.call(e.update):e.update),e.origin!=null&&e.hasOwnProperty("origin")&&(o.origin=e.origin),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/DebugLogUpdate"},r})(),_i=m.DocumentCompletions=(()=>{function r(n,e,t){H.rpc.Service.call(this,n,e,t)}return(r.prototype=Object.create(H.rpc.Service.prototype)).constructor=r,r.create=function(e,t,o){return new this(e,t,o)},Object.defineProperty(r.prototype.generateBlockCompletion=function n(e,t){return this.rpcCall(n,m.GenerateBlockCompletionRequest,m.GenerateBlockCompletionReply,e,t)},"name",{value:"generateBlockCompletion"}),Object.defineProperty(r.prototype.streamAICompletion=function n(e,t){return this.rpcCall(n,m.AICompletionRequest,m.AICompletionReply,e,t)},"name",{value:"streamAICompletion"}),Object.defineProperty(r.prototype.stopAICompletion=function n(e,t){return this.rpcCall(n,m.StopAICompletionRequest,m.StopAICompletionReply,e,t)},"name",{value:"stopAICompletion"}),Object.defineProperty(r.prototype.generateDiagramSuggestions=function n(e,t){return this.rpcCall(n,m.GenerateDiagramSuggestionsRequest,m.GenerateDiagramSuggestionsReply,e,t)},"name",{value:"generateDiagramSuggestions"}),Object.defineProperty(r.prototype.generateDiagram=function n(e,t){return this.rpcCall(n,m.GenerateDiagramRequest,m.GenerateDiagramReply,e,t)},"name",{value:"generateDiagram"}),r})(),Ih=m.StopAICompletionRequest=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.id="",r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(10).string(e.id),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.StopAICompletionRequest;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.id=e.string();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":l.isString(e.id)?null:"id: string expected"},r.fromObject=function(e){if(e instanceof m.StopAICompletionRequest)return e;let t=new m.StopAICompletionRequest;return e.id!=null&&(t.id=String(e.id)),t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.id=""),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/StopAICompletionRequest"},r})(),Oh=m.StopAICompletionReply=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.StopAICompletionReply;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){default:e.skipType(a&7);break}}return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":null},r.fromObject=function(e){return e instanceof m.StopAICompletionReply?e:new m.StopAICompletionReply},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/StopAICompletionReply"},r})(),kh=m.AICompletionRequest=(()=>{function r(n){if(this.history=[],n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.input="",r.prototype.prompt="",r.prototype.id="",r.prototype.history=l.emptyArray,r.create=function(e){return new r(e)},r.encode=function(e,t){if(t||(t=V.create()),t.uint32(10).string(e.input),t.uint32(18).string(e.prompt),t.uint32(26).string(e.id),e.history!=null&&e.history.length)for(let o=0;o<e.history.length;++o)m.AICompletionHistoryEntry.encode(e.history[o],t.uint32(34).fork()).ldelim();return t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.AICompletionRequest;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.input=e.string();break}case 2:{i.prompt=e.string();break}case 3:{i.id=e.string();break}case 4:{i.history&&i.history.length||(i.history=[]),i.history.push(m.AICompletionHistoryEntry.decode(e,e.uint32()));break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("input"))throw l.ProtocolError("missing required 'input'",{instance:i});if(!i.hasOwnProperty("prompt"))throw l.ProtocolError("missing required 'prompt'",{instance:i});if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!l.isString(e.input))return"input: string expected";if(!l.isString(e.prompt))return"prompt: string expected";if(!l.isString(e.id))return"id: string expected";if(e.history!=null&&e.hasOwnProperty("history")){if(!Array.isArray(e.history))return"history: array expected";for(let t=0;t<e.history.length;++t){let o=m.AICompletionHistoryEntry.verify(e.history[t]);if(o)return"history."+o}}return null},r.fromObject=function(e){if(e instanceof m.AICompletionRequest)return e;let t=new m.AICompletionRequest;if(e.input!=null&&(t.input=String(e.input)),e.prompt!=null&&(t.prompt=String(e.prompt)),e.id!=null&&(t.id=String(e.id)),e.history){if(!Array.isArray(e.history))throw TypeError(".AICompletionRequest.history: array expected");t.history=[];for(let o=0;o<e.history.length;++o){if(typeof e.history[o]!="object")throw TypeError(".AICompletionRequest.history: object expected");t.history[o]=m.AICompletionHistoryEntry.fromObject(e.history[o])}}return t},r.toObject=function(e,t){t||(t={});let o={};if((t.arrays||t.defaults)&&(o.history=[]),t.defaults&&(o.input="",o.prompt="",o.id=""),e.input!=null&&e.hasOwnProperty("input")&&(o.input=e.input),e.prompt!=null&&e.hasOwnProperty("prompt")&&(o.prompt=e.prompt),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),e.history&&e.history.length){o.history=[];for(let i=0;i<e.history.length;++i)o.history[i]=m.AICompletionHistoryEntry.toObject(e.history[i],t)}return o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/AICompletionRequest"},r})(),Ah=m.AICompletionReply=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.completion="",r.prototype.id="",r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(10).string(e.completion),t.uint32(18).string(e.id),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.AICompletionReply;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.completion=e.string();break}case 2:{i.id=e.string();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("completion"))throw l.ProtocolError("missing required 'completion'",{instance:i});if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":l.isString(e.completion)?l.isString(e.id)?null:"id: string expected":"completion: string expected"},r.fromObject=function(e){if(e instanceof m.AICompletionReply)return e;let t=new m.AICompletionReply;return e.completion!=null&&(t.completion=String(e.completion)),e.id!=null&&(t.id=String(e.id)),t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.completion="",o.id=""),e.completion!=null&&e.hasOwnProperty("completion")&&(o.completion=e.completion),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/AICompletionReply"},r})(),xh=m.AICompletionHistoryEntry=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.prompt="",r.prototype.answer="",r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(10).string(e.prompt),t.uint32(18).string(e.answer),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.AICompletionHistoryEntry;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.prompt=e.string();break}case 2:{i.answer=e.string();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("prompt"))throw l.ProtocolError("missing required 'prompt'",{instance:i});if(!i.hasOwnProperty("answer"))throw l.ProtocolError("missing required 'answer'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":l.isString(e.prompt)?l.isString(e.answer)?null:"answer: string expected":"prompt: string expected"},r.fromObject=function(e){if(e instanceof m.AICompletionHistoryEntry)return e;let t=new m.AICompletionHistoryEntry;return e.prompt!=null&&(t.prompt=String(e.prompt)),e.answer!=null&&(t.answer=String(e.answer)),t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.prompt="",o.answer=""),e.prompt!=null&&e.hasOwnProperty("prompt")&&(o.prompt=e.prompt),e.answer!=null&&e.hasOwnProperty("answer")&&(o.answer=e.answer),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/AICompletionHistoryEntry"},r})(),Eh=m.GenerateBlockCompletionRequest=(()=>{function r(n){if(this.history=[],n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.startKey="",r.prototype.endKey="",r.prototype.prompt="",r.prototype.id="",r.prototype.history=l.emptyArray,r.create=function(e){return new r(e)},r.encode=function(e,t){if(t||(t=V.create()),t.uint32(10).string(e.startKey),t.uint32(18).string(e.endKey),t.uint32(26).string(e.prompt),t.uint32(34).string(e.id),e.history!=null&&e.history.length)for(let o=0;o<e.history.length;++o)m.AICompletionHistoryEntry.encode(e.history[o],t.uint32(42).fork()).ldelim();return t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.GenerateBlockCompletionRequest;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.startKey=e.string();break}case 2:{i.endKey=e.string();break}case 3:{i.prompt=e.string();break}case 4:{i.id=e.string();break}case 5:{i.history&&i.history.length||(i.history=[]),i.history.push(m.AICompletionHistoryEntry.decode(e,e.uint32()));break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("startKey"))throw l.ProtocolError("missing required 'startKey'",{instance:i});if(!i.hasOwnProperty("endKey"))throw l.ProtocolError("missing required 'endKey'",{instance:i});if(!i.hasOwnProperty("prompt"))throw l.ProtocolError("missing required 'prompt'",{instance:i});if(!i.hasOwnProperty("id"))throw l.ProtocolError("missing required 'id'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(!l.isString(e.startKey))return"startKey: string expected";if(!l.isString(e.endKey))return"endKey: string expected";if(!l.isString(e.prompt))return"prompt: string expected";if(!l.isString(e.id))return"id: string expected";if(e.history!=null&&e.hasOwnProperty("history")){if(!Array.isArray(e.history))return"history: array expected";for(let t=0;t<e.history.length;++t){let o=m.AICompletionHistoryEntry.verify(e.history[t]);if(o)return"history."+o}}return null},r.fromObject=function(e){if(e instanceof m.GenerateBlockCompletionRequest)return e;let t=new m.GenerateBlockCompletionRequest;if(e.startKey!=null&&(t.startKey=String(e.startKey)),e.endKey!=null&&(t.endKey=String(e.endKey)),e.prompt!=null&&(t.prompt=String(e.prompt)),e.id!=null&&(t.id=String(e.id)),e.history){if(!Array.isArray(e.history))throw TypeError(".GenerateBlockCompletionRequest.history: array expected");t.history=[];for(let o=0;o<e.history.length;++o){if(typeof e.history[o]!="object")throw TypeError(".GenerateBlockCompletionRequest.history: object expected");t.history[o]=m.AICompletionHistoryEntry.fromObject(e.history[o])}}return t},r.toObject=function(e,t){t||(t={});let o={};if((t.arrays||t.defaults)&&(o.history=[]),t.defaults&&(o.startKey="",o.endKey="",o.prompt="",o.id=""),e.startKey!=null&&e.hasOwnProperty("startKey")&&(o.startKey=e.startKey),e.endKey!=null&&e.hasOwnProperty("endKey")&&(o.endKey=e.endKey),e.prompt!=null&&e.hasOwnProperty("prompt")&&(o.prompt=e.prompt),e.id!=null&&e.hasOwnProperty("id")&&(o.id=e.id),e.history&&e.history.length){o.history=[];for(let i=0;i<e.history.length;++i)o.history[i]=m.AICompletionHistoryEntry.toObject(e.history[i],t)}return o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/GenerateBlockCompletionRequest"},r})(),Th=m.GenerateBlockCompletionReply=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.GenerateBlockCompletionReply;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){default:e.skipType(a&7);break}}return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":null},r.fromObject=function(e){return e instanceof m.GenerateBlockCompletionReply?e:new m.GenerateBlockCompletionReply},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/GenerateBlockCompletionReply"},r})(),Dh=m.GenerateDiagramSuggestionsRequest=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.nodeKey="",r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(10).string(e.nodeKey),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.GenerateDiagramSuggestionsRequest;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.nodeKey=e.string();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("nodeKey"))throw l.ProtocolError("missing required 'nodeKey'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":l.isString(e.nodeKey)?null:"nodeKey: string expected"},r.fromObject=function(e){if(e instanceof m.GenerateDiagramSuggestionsRequest)return e;let t=new m.GenerateDiagramSuggestionsRequest;return e.nodeKey!=null&&(t.nodeKey=String(e.nodeKey)),t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.nodeKey=""),e.nodeKey!=null&&e.hasOwnProperty("nodeKey")&&(o.nodeKey=e.nodeKey),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/GenerateDiagramSuggestionsRequest"},r})(),_h=m.GenerateDiagramSuggestionsReply=(()=>{function r(n){if(this.suggestions=[],n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.suggestions=l.emptyArray,r.create=function(e){return new r(e)},r.encode=function(e,t){if(t||(t=V.create()),e.suggestions!=null&&e.suggestions.length)for(let o=0;o<e.suggestions.length;++o)t.uint32(10).string(e.suggestions[o]);return t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.GenerateDiagramSuggestionsReply;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.suggestions&&i.suggestions.length||(i.suggestions=[]),i.suggestions.push(e.string());break}default:e.skipType(a&7);break}}return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.suggestions!=null&&e.hasOwnProperty("suggestions")){if(!Array.isArray(e.suggestions))return"suggestions: array expected";for(let t=0;t<e.suggestions.length;++t)if(!l.isString(e.suggestions[t]))return"suggestions: string[] expected"}return null},r.fromObject=function(e){if(e instanceof m.GenerateDiagramSuggestionsReply)return e;let t=new m.GenerateDiagramSuggestionsReply;if(e.suggestions){if(!Array.isArray(e.suggestions))throw TypeError(".GenerateDiagramSuggestionsReply.suggestions: array expected");t.suggestions=[];for(let o=0;o<e.suggestions.length;++o)t.suggestions[o]=String(e.suggestions[o])}return t},r.toObject=function(e,t){t||(t={});let o={};if((t.arrays||t.defaults)&&(o.suggestions=[]),e.suggestions&&e.suggestions.length){o.suggestions=[];for(let i=0;i<e.suggestions.length;++i)o.suggestions[i]=e.suggestions[i]}return o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/GenerateDiagramSuggestionsReply"},r})(),Mh=m.GenerateDiagramRequest=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.nodeKey="",r.prototype.prompt="",r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(10).string(e.nodeKey),t.uint32(18).string(e.prompt),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.GenerateDiagramRequest;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.nodeKey=e.string();break}case 2:{i.prompt=e.string();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("nodeKey"))throw l.ProtocolError("missing required 'nodeKey'",{instance:i});if(!i.hasOwnProperty("prompt"))throw l.ProtocolError("missing required 'prompt'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":l.isString(e.nodeKey)?l.isString(e.prompt)?null:"prompt: string expected":"nodeKey: string expected"},r.fromObject=function(e){if(e instanceof m.GenerateDiagramRequest)return e;let t=new m.GenerateDiagramRequest;return e.nodeKey!=null&&(t.nodeKey=String(e.nodeKey)),e.prompt!=null&&(t.prompt=String(e.prompt)),t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.nodeKey="",o.prompt=""),e.nodeKey!=null&&e.hasOwnProperty("nodeKey")&&(o.nodeKey=e.nodeKey),e.prompt!=null&&e.hasOwnProperty("prompt")&&(o.prompt=e.prompt),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/GenerateDiagramRequest"},r})(),Hh=m.GenerateDiagramReply=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.mermaid="",r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),e.mermaid!=null&&Object.hasOwnProperty.call(e,"mermaid")&&t.uint32(10).string(e.mermaid),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.GenerateDiagramReply;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.mermaid=e.string();break}default:e.skipType(a&7);break}}return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":e.mermaid!=null&&e.hasOwnProperty("mermaid")&&!l.isString(e.mermaid)?"mermaid: string expected":null},r.fromObject=function(e){if(e instanceof m.GenerateDiagramReply)return e;let t=new m.GenerateDiagramReply;return e.mermaid!=null&&(t.mermaid=String(e.mermaid)),t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.mermaid=""),e.mermaid!=null&&e.hasOwnProperty("mermaid")&&(o.mermaid=e.mermaid),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/GenerateDiagramReply"},r})(),Nh=m.BlockRichTextCompletion=(()=>{function r(n){if(n)for(let e=Object.keys(n),t=0;t<e.length;++t)n[e[t]]!=null&&(this[e[t]]=n[e[t]])}return r.prototype.summary="",r.prototype.markdown="",r.create=function(e){return new r(e)},r.encode=function(e,t){return t||(t=V.create()),t.uint32(10).string(e.summary),t.uint32(18).string(e.markdown),t},r.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},r.decode=function(e,t){e instanceof w||(e=w.create(e));let o=t===void 0?e.len:e.pos+t,i=new m.BlockRichTextCompletion;for(;e.pos<o;){let a=e.uint32();switch(a>>>3){case 1:{i.summary=e.string();break}case 2:{i.markdown=e.string();break}default:e.skipType(a&7);break}}if(!i.hasOwnProperty("summary"))throw l.ProtocolError("missing required 'summary'",{instance:i});if(!i.hasOwnProperty("markdown"))throw l.ProtocolError("missing required 'markdown'",{instance:i});return i},r.decodeDelimited=function(e){return e instanceof w||(e=new w(e)),this.decode(e,e.uint32())},r.verify=function(e){return typeof e!="object"||e===null?"object expected":l.isString(e.summary)?l.isString(e.markdown)?null:"markdown: string expected":"summary: string expected"},r.fromObject=function(e){if(e instanceof m.BlockRichTextCompletion)return e;let t=new m.BlockRichTextCompletion;return e.summary!=null&&(t.summary=String(e.summary)),e.markdown!=null&&(t.markdown=String(e.markdown)),t},r.toObject=function(e,t){t||(t={});let o={};return t.defaults&&(o.summary="",o.markdown=""),e.summary!=null&&e.hasOwnProperty("summary")&&(o.summary=e.summary),e.markdown!=null&&e.hasOwnProperty("markdown")&&(o.markdown=e.markdown),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,H.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/BlockRichTextCompletion"},r})(),Bh=m.ContentOperationStatus=(()=>{let r={},n=Object.create(r);return n[r[0]="STARTING"]=0,n[r[1]="RUNNING"]=1,n[r[2]="SUCCESS"]=2,n[r[3]="ERROR"]=3,n})(),rt=m.UpdateFormatVersion=(()=>{let r={},n=Object.create(r);return n[r[0]="UNSPECIFIED"]=0,n[r[1]="V1"]=1,n[r[2]="V2"]=2,n})();s();var Lh=.9*1024*1024;function nd(r,n=0){let e=n;return{newMessageID:()=>(e+=1,e),write:t=>{let[o]=Object.keys(t);if(t.init){let i=t.init;Mi(i.update,(a,c,h)=>{r(Io({init:{...i,index:c,count:h,update:a}}),i.id,o)})}else if(t.update){let i=t.update;Mi(i.update,(a,c,h)=>{r(Io({update:{...i,index:c,count:h,update:a}}),i.id,o)})}else if(t.promptInit){let i=t.promptInit;Mi(i.stateVector,(a,c,h)=>{r(Io({promptInit:{...i,index:c,count:h,stateVector:a}}),i.id,o)})}else r(Io(t),t[o].id,o)}}}function Io(r){let n=It.verify(r);if(n)throw new Error(`ProtoBufObject message is not valid: ${n}`);let e=It.create(r);return It.encode(e).finish()}function Mi(r,n){xu(r,Lh).forEach((t,o,i)=>{n(t,o,i.length)})}s();function rd(r){let n=new Map,e=(t,o)=>{if(!t.id||t.index===void 0||t.count===void 0)return o(t);let i=n.get(t.id)||[];if(i.push(t),n.set(t.id,i),i.length===t.count){let a=Eu(i.sort((h,p)=>(h.index||0)-(p.index||0)).map(h=>"update"in h?h.update:h.stateVector)),c=o({...t,..."update"in t?{update:a}:{stateVector:a}});return n.delete(t.id),c}};return t=>zh(t,{promptInit:o=>e(o,i=>r.promptInit(i)),init:o=>e(o,i=>r.init(i)),update:o=>e(o,i=>r.update(i)),updatePresence:r.updatePresence,broadcastOperation:r.broadcastOperation,broadcastPresences:r.broadcastPresences,ack:r.ack,rpcReply:r.rpcReply,rpcRequest:r.rpcRequest})}function zh(r,n){let e=It.decode(r),t=It.toObject(e);if(t.promptInit)return n.promptInit(t.promptInit);if(t.init)return n.init(t.init);if(t.update)return n.update(t.update);if(t.updatePresence)return n.updatePresence(t.updatePresence);if(t.broadcastOperation)return n.broadcastOperation(t.broadcastOperation);if(t.broadcastPresences)return n.broadcastPresences(t.broadcastPresences);if(t.ack)return n.ack(t.ack);if(t.rpcRequest)return n.rpcRequest(t.rpcRequest);if(t.rpcReply)return n.rpcReply(t.rpcReply)}s();var Uh={DocumentCompletions:_i},Hi=W("hive:datasync:rpc");function od(r,n,e={}){let{timeout:t=3*60*1e3}=e,o=new Map,i=new Uh[r]((a,c,h)=>{let p=n.newMessageID(),d={id:p,service:r,method:a.name,payload:c},f=a.name.startsWith("stream"),y=!1,C=setTimeout(()=>{Hi.warning(`RPC request ${r}.${a.name} timed out (${t/1e3}s)`),h(new Error(`RPC request ${r}.${a.name} timed out`)),I()},t);function I(){y=!0,o.delete(p),clearTimeout(C)}let v=(g,b)=>{if(!y){if(g){h(g),I();return}if(f&&b!==null){h(null,b);return}h(null,b),I()}};o.set(p,v),Hi.info(`sending RPC request ${r}.${a.name}: ${p}`),n.write({rpcRequest:d})},!1,!1);return{onReplyMessage:a=>{let c=o.get(a.replyTo);if(!c)return!1;if(Hi.info(`received RPC reply for ${a.replyTo}`),a.error){let h=Lt.fromStatusCode(a.error.code,a.error.message);return c(h),!0}return c(null,a.payload??null),!0},service:i}}s();var nC=W("datasync:storage");function Ni(r,n,e,t){switch(n){case null:case void 0:case rt.UNSPECIFIED:case rt.V1:{let o=Array.isArray(e)?Rc(e):e;gc(r,o,t);break}case rt.V2:{let o=Array.isArray(e)?eo(e):e;Qr(r,o,t);break}default:te(n)}}s();var ad=Ue(r=>{let n=r.getAttribute("data");return Gs.create({key:r.getAttribute("key"),nodes:Oo(r),data:n?Bi(n):void 0})}),Oo=Ue(r=>fn.create(r.toArray().map(n=>{if(n instanceof ke)return sd(n);if(n instanceof q)return Yh(n);throw new Error(`Unknown node type: ${n}`)}))),Yh=Ue(r=>{let e=r.toDelta().map(t=>Ks.create({text:t.insert,marks:Fh(t.attributes||{})}));return Ws.create({key:r.getAttribute("key"),leaves:fn.create(e)})}),sd=Ue(r=>{let n=r.getAttribute("key");switch(r.nodeName){case"block":{let e=r,t=e.getAttribute("data"),o=e.getAttribute("fragments");return Vs.create({key:n,type:e.getAttribute("type"),isVoid:e.getAttribute("isVoid"),data:t?Bi(t):void 0,nodes:Oo(r),fragments:o?id(o):void 0})}case"inline":{let e=r,t=e.getAttribute("data"),o=e.getAttribute("fragments");return qs.create({key:n,type:e.getAttribute("type"),isVoid:e.getAttribute("isVoid"),data:t?Bi(t):void 0,nodes:Oo(r),fragments:o?id(o):void 0})}case"fragment":{let e=r;return Js.create({key:n,type:e.getAttribute("type"),fragment:e.getAttribute("fragment"),nodes:Oo(r)})}default:throw new Error(`Unknown object type: ${r.nodeName}`)}}),id=Ue(r=>Ys.create(r.toArray().map(n=>{if(!(n instanceof ke))throw new Error(`Unknown node type: ${n}`);let e=sd(n);return[e.fragmentKey,e]})));function Fh(r){return $r.create(Object.keys(r).map(n=>Fs.create({type:n,data:r[n]})))}var Bi=Ue(r=>mn.create(r.toJSON()));s();s();function cd(r,n){if(!r||r.size!==n.size)return!1;for(let[e,t]of r)if(!n.has(e)||!Li(t,n.get(e)))return!1;return!0}function Li(r,n){if(r instanceof Yt&&Array.isArray(n)){if(r.length!==n.length)return!1;for(let e=0;e<r.length;e++)if(!Li(r.get(e),n[e]))return!1;return!0}if(r instanceof Ye&&typeof n=="object"&&n!==null){let e=Object.keys(n);if(r.size!==e.length)return!1;for(let t=0;t<e.length;t++){let o=e[t];if(!Li(r.get(o),n[o]))return!1}return!0}return r===n}s();function kn(r){return r.get("data",ke)}function Wt(r){let n=r.object;switch(n){case"block":return Kh(r);case"inline":return Wh(r);case"text":return Jh(r);default:throw new Error(`Unknown node type: ${n}`)}}function zi(r,n){r.delete(0,r.length),r.insert(0,n.toArray().map(e=>Wt(e)))}function Kh(r,n=new ke(r.object)){return n.setAttribute("key",r.key),r.isVoid?n.setAttribute("isVoid",r.isVoid):n.removeAttribute("isVoid"),n.setAttribute("type",r.type),Ao(n,r.data),zi(n,r.nodes),ld(n,r.fragments),n}function Wh(r,n=new ke(r.object)){return n.setAttribute("key",r.key),r.isVoid?n.setAttribute("isVoid",r.isVoid):n.removeAttribute("isVoid"),n.setAttribute("type",r.type),Ao(n,r.data),zi(n,r.nodes),ld(n,r.fragments),n}function Vh(r,n=new ar){return n.delete(0,n.length),r.forEach(e=>{n.push([Ui(e)])}),n}function ld(r,n){if(n.size===0){r.removeAttribute("fragments");return}let e=r.getAttribute("fragments");e||(e=new ar,r.setAttribute("fragments",e)),Vh(n,e)}function Ui(r,n=new ke(r.object)){return n.setAttribute("key",r.key),r.type&&n.setAttribute("type",r.type),r.fragment&&n.setAttribute("fragment",r.fragment),zi(n,r.nodes),n}function Jh(r,n=new q){let e=0;return n.setAttribute("key",r.key),n.delete(0,n.length),r.leaves.forEach(t=>{n.insert(e,t.text,ko(t.marks)),e+=t.text.length}),n}function ko(r){if(r.size===0)return{};let n={};return r.forEach(e=>{n[e.type]=e.data.toObject()}),n}function Ao(r,n){if(n.size===0){r.hasAttribute("data")&&r.removeAttribute("data");return}let e=r.getAttribute("data");cd(e,n)||(e?e.clear():(e=new Ye,r.setAttribute("data",e)),n.forEach((t,o)=>{e.set(o,An(t))}))}function An(r){if(r==null||typeof r=="number"||typeof r=="string"||typeof r=="boolean")return r;if(Array.isArray(r)){let n=new Yt;return r.forEach(e=>{n.push([An(e)])}),n}else{let n=new Ye;return Object.keys(r).forEach(e=>{n.set(e,An(r[e]))}),n}}s();s();function pe(r,n){let e=r;for(let t=0;t<n.length;t++){let o=n[t];if(e instanceof q)throw new Error("Invalid path, expected a node with descendants");if(o<e.length)e=e.get(o);else{let i=e.getAttribute("fragments");i&&(e=i.get(o-e.length))}if(!e)throw new Error("Invalid path, expected a node")}return e}function Vt(r,n){let e=n.slice(0,-1),t=pe(r,e);if(t instanceof q)throw new Error("Invalid path, expected a node with descendants");let o=n[n.length-1];return{parent:t,index:o}}function mr(r,n){let e=r.getAttribute("data");e||(e=new Ye,r.setAttribute("data",e));let t=e;for(let o=0;o<n.length;o++){let i=n[o],a=t,c=a.get(i);if(c===void 0){let[h,p]=qh(n.slice(o+1));return a.set(i,h),p}else{if(!(c instanceof Ye))throw new Error(`Invalid data path (${n.slice(0,o+1).join(".")}), expected a map`);t=c}}return t}function qh(r){let n=new Ye,e=n;for(let t=0;t<r.length;t++){let o=new Ye;e.set(r[t],o),e=o}return[n,e]}function Yi(r,n){r.operations.forEach(([e,t,o])=>{Gh(n,e,t.document,o.document)})}function Gh(r,n,e,t){switch(n.type){case"insert_text":$h(r,e,n);break;case"remove_text":jh(r,e,n);break;case"add_mark":Xh(r,n);break;case"remove_mark":Qh(r,n);break;case"remove_node":Zh(r,n);break;case"insert_node":eg(r,n);break;case"set_node":og(r,n);break;case"move_node":tg(r,e,t,n);break;case"split_node":ng(r,e,n);break;case"merge_node":rg(r,e,n);break;case"insert_fragment":ig(r,n);break;case"remove_fragment":ag(r,n);break;case"set_data":sg(r,n);break;case"remove_data":cg(r,n);break;case"insert_array_data":lg(r,n);break;case"remove_array_data":ug(r,n);break;case"set_selection":break;default:throw new Error(`Unsupported operation type: ${n.type}`)}}function $h(r,n,e){let t=pe(r,[...e.path]);if(!(t instanceof q))throw new Error("Invalid operation path, expected a text node");t.insert(e.offset,e.text,ko(e.marks))}function jh(r,n,e){let t=pe(r,[...e.path]);if(!(t instanceof q))throw new Error("Invalid operation path, expected a text node");t.delete(e.offset,e.text.length)}function Xh(r,n){let e=pe(r,[...n.path]);if(!(e instanceof q))throw new Error("Invalid operation path, expected a text node");e.format(n.offset,n.length,ko($r.create([n.mark])))}function Qh(r,n){let e=pe(r,[...n.path]);if(!(e instanceof q))throw new Error("Invalid operation path, expected a text node");e.format(n.offset,n.length,{[n.mark.type]:null})}function Zh(r,n){let{parent:e,index:t}=Vt(r,[...n.path]);e.delete(t)}function eg(r,n){let{parent:e,index:t}=Vt(r,[...n.path]);e.insert(t,[Wt(n.node)])}function tg(r,n,e,t){let{parent:o,index:i}=Vt(r,[...t.path]),{parent:a,index:c}=Vt(r,[...t.newPath]),h=e.assertPath(t.path),p=n.assertNode(h.key),d=Wt(p);o.delete(i),a.insert(c,[d])}function ng(r,n,e){let{parent:t,index:o}=Vt(r,[...e.path]),i=n.assertNode(t.getAttribute("key"));if(i.object==="text")throw new Error("Invalid operation path, expected a node with descendants for split_node");let a=i.nodes.get(o);if(!a)throw new Error("Node not found in parent nodes");let c=i.nodes.get(o+1);if(!c)throw new Error("New node not found in parent nodes");t.delete(o),t.insert(o,[Wt(a),Wt(c)])}function rg(r,n,e){let{parent:t,index:o}=Vt(r,[...e.path]),i=n.assertNode(t.getAttribute("key"));if(i.object==="text")throw new Error("Invalid operation path, expected a node with descendants for merge_node");let a=i.nodes.get(o-1);if(!a)throw new Error("Merged node not found in parent nodes");t.delete(o-1,2),t.insert(o-1,[Wt(a)])}function og(r,n){let e=pe(r,[...n.path]);if(typeof n.properties!="string"){if("key"in n.properties&&n.properties.key!==void 0&&e.setAttribute("key",n.properties.key),"type"in n.properties&&n.properties.type!==void 0&&e.setAttribute("type",n.properties.type),"isVoid"in n.properties&&n.properties.isVoid!==void 0){if(e instanceof q)throw new Error("Should not set isVoid on a text");e.setAttribute("isVoid",n.properties.isVoid)}if("data"in n.properties&&n.properties.data!==void 0){if(e instanceof q)throw new Error("Should not set data on a text");Ao(e,mn.create(n.properties.data))}}}function ig(r,n){let e=pe(r,[...n.path]);if(e instanceof q)throw new Error("Expect a fragment node");let t=e,o=n.fragmentPath[n.fragmentPath.length-1]-1,i=Ui(n.node),a=t.getAttribute("fragments");a||(a=new ar,t.setAttribute("fragments",a)),a.insert(o,[i])}function ag(r,n){let e=pe(r,[...n.path]);if(e instanceof q)throw new Error("Expect a fragment node");let t=e,o=n.fragmentPath[n.fragmentPath.length-1]-1;t.getAttribute("fragments").delete(o)}function sg(r,n){let e=pe(r,[...n.path]);if(e instanceof q)throw new Error("Should not set data on a text");let t=An(n.data),o=mr(e,n.dataPath.slice(0,-1)),i=n.dataPath[n.dataPath.length-1];o.set(i,t)}function cg(r,n){let e=pe(r,[...n.path]);if(e instanceof q)throw new Error("Should not set data on a text");let t=mr(e,n.dataPath.slice(0,-1)),o=n.dataPath[n.dataPath.length-1];t.delete(o)}function lg(r,n){let e=pe(r,[...n.path]);if(e instanceof q)throw new Error("Should not set data on a text");let t=mr(e,n.dataPath.slice(0,-1)),o=n.dataPath[n.dataPath.length-1],i=t.get(o);if(!i||!(i instanceof Yt))return;let a=An(n.data);i.insert(n.dataIndex,[a])}function ug(r,n){let e=pe(r,[...n.path]);if(e instanceof q)throw new Error("Should not set data on a text");let t=mr(e,n.dataPath.slice(0,-1)),o=n.dataPath[n.dataPath.length-1],i=t.get(o);if(!i||!(i instanceof Yt))return;let a;for(;(a=i.toArray().findIndex(c=>c===n.data))!==-1;)i.delete(a)}s();function pd(r,n,e){let t=kn(n);return Si.isBlockRange(e)?{anchor:e.anchorBlock?dd(t,r,e.anchorBlock):void 0,focus:e.focusBlock?dd(t,r,e.focusBlock):void 0}:{anchor:e.anchorKey?ud(t,r,e.anchorKey,e.anchorOffset):void 0,focus:e.focusKey?ud(t,r,e.focusKey,e.focusOffset):void 0}}function fd(r,n){if(!(!n.anchor||!n.focus)){if(n.anchor.type instanceof q){if(!(n.focus.type instanceof q))return;let e=n.anchor.type.getAttribute("key"),t=n.focus.type.getAttribute("key");return nr.create({anchorKey:e,anchorOffset:n.anchor.index,focusKey:t,focusOffset:n.focus.index}).normalize(r)}if(n.anchor.type instanceof ke){if(!(n.focus.type instanceof ke))return;let e=n.anchor.type.getAttribute("key"),t=n.focus.type.getAttribute("key"),o=r.getDescendant(e),i=r.getDescendant(t);if(!o||!i||!o.isBlock()||!i.isBlock())return;let a=o.nodes.get(n.anchor.index),c=i.nodes.get(n.focus.index);return!a||!c?void 0:Si.create({anchorBlock:a.key,focusBlock:c?.key}).normalize(r)}}}function ud(r,n,e,t){let o=n.getPath(e);return o?{type:pe(r,o),index:t,assoc:0}:void 0}function dd(r,n,e){let t=n.getPath(e);return t?{type:pe(r,t.slice(0,-1)),index:t[t.length-1],assoc:0}:void 0}s();var dg=W("hive-core:normalizeYDocument");function md(r){let n=new Set,e=new Set;return hd(r,n,e),e.size>0&&dg.warning(`Found ${e.size} duplicated keys in Y document. This is a bug in Hive.`),e.size}function hd(r,n,e){gd(r,n,e);let t=r.getAttribute("fragments");t&&pg(t,n,e)}function pg(r,n,e){gd(r,n,e)}function gd(r,n,e){let t=0;r.forEach((o,i)=>{let a=o.getAttribute("key");if(n.has(a)){e.add(a),mc(r),r.delete(i-t),t++;return}n.add(a),!(o instanceof q)&&hd(o,n,e)})}s();var yd=P(Nc());function Fi(r,n){Ki(r.nodes,n)}function Ki(r,n){if(r.size!==n.length)throw new fe(`Nodes size mismatch: ${r.size} !== ${n.length}`);r.forEach((e,t)=>{let o=n.get(t);e.object==="inline"?mg(e,o):e.object==="block"?fg(e,o):hg(e,o)})}function fg(r,n){if(r.key!==n.getAttribute("key"))throw new fe(`Block key mismatch: ${r.key} !== ${n.getAttribute("key")}`);if(r.type!==n.getAttribute("type"))throw new fe(`Block type mismatch: ${r.type} !== ${n.getAttribute("type")}`);vd(r.data,n.getAttribute("data")),Ki(r.nodes,n)}function mg(r,n){if(r.key!==n.getAttribute("key"))throw new fe(`Inline key mismatch: ${r.key} !== ${n.getAttribute("key")}`);if(r.type!==n.getAttribute("type"))throw new fe(`Inline type mismatch: ${r.type} !== ${n.getAttribute("type")}`);if(r.nodes.size!==n.length)throw new fe(`Inline nodes size mismatch: ${r.nodes.size} !== ${n.length}`);vd(r.data,n.getAttribute("data")),Ki(r.nodes,n)}function hg(r,n){if(r.key!==n.getAttribute("key"))throw new fe(`Text key mismatch: ${r.key} !== ${n.getAttribute("key")}`)}function vd(r,n){if(!(r.size===0&&n===void 0)){if(!n)throw new fe(`Data mismatch: Slate data size is ${r.size} but yData is undefined`);if(r.size!==n.size)throw new fe(`Data size mismatch ${r.size} !== ${n.size}`);r.forEach((e,t)=>{let o=ie(n.get(t));if(!(0,yd.default)(e,o))throw new fe(`Data value ${t} mismatch`,JSON.stringify(e),JSON.stringify(o))})}}var fe=class extends Error{constructor(n,e,t){super(`YDocumentCheckFail: ${n}`),this.slateValue=e,this.yValue=t}};s();s();s();s();s();s();s();var ce=crypto;var ft=new TextEncoder,_e=new TextDecoder,CR=2**32;var bd=r=>{let n=atob(r),e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e},kt=r=>{let n=r;n instanceof Uint8Array&&(n=_e.decode(n)),n=n.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return bd(n)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};s();s();s();var xo=class extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(n){var e;super(n),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(e=Error.captureStackTrace)===null||e===void 0||e.call(Error,this,this.constructor)}};var Ae=class extends xo{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}};s();s();var Eo=ce.getRandomValues.bind(ce);s();s();s();s();s();s();s();s();function Cg(r){return typeof r=="object"&&r!==null}function Se(r){if(!Cg(r)||Object.prototype.toString.call(r)!=="[object Object]")return!1;if(Object.getPrototypeOf(r)===null)return!0;let n=r;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(r)===n}s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();var Ng=Symbol();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();s();var Ji=kt;s();function qi(r){if(typeof r!="string")throw new Ae("JWTs must use Compact JWS serialization, JWT must be a string");let{1:n,length:e}=r.split(".");if(e===5)throw new Ae("Only JWTs using Compact JWS serialization can be decoded");if(e!==3)throw new Ae("Invalid JWT");if(!n)throw new Ae("JWTs must contain a payload");let t;try{t=Ji(n)}catch{throw new Ae("Failed to base64url decode the payload")}let o;try{o=JSON.parse(_e.decode(t))}catch{throw new Ae("Failed to parse the decoded payload as JSON")}if(!Se(o))throw new Ae("Invalid JWT Claims Set");return o}s();s();s();s();s();s();function Ed(r){let n=qi(r);return{expiration:n.exp?n.exp*1e3:Date.now()+6*60*60*1e3,payload:{userId:n.userId,content:n.content}}}s();var sT=["read","write-branch","write","admin"];function Td(r,n){let e=r in n.content?n.content[r]:void 0;if(e)return e;let t=Gi(r,Object.keys(n.content));return t?n.content[t]:null}function Gi(r,n){let e;for(let t of n)Xg(t,r)&&(e=!e||t.length>e.length?t:e);return e}function _o(r){return r.endsWith("*")}function Xg(r,n){if(!_o(r))return!1;let e=r.replace(/\*$/,".*");return new RegExp(`^${e}$`).test(n)}s();var Xe=P(k());function yr(r){let{title:n,children:e,action:t,dismissable:o,style:i}=r,a=o?`@sidebar:alert:${o}`:null,[c,h]=Xe.useState(a?qe.get(a):!1);return c?null:Xe.createElement(O,{style:[u.flex.flex1,u.flex.column,u.flex.alignItemsStretch,u.background.colorBase,u.shadow.boxBase,u.border.none,u.border.radius400,u.padding.all300,u.padding.bottom400,i]},Xe.createElement(O,{style:[u.flex.alignItemsCenter,u.margin.bottom300]},Xe.createElement(T,{style:[u.flex.grow1,u.text.uiSmall,u.text.colorBase]},n),a?Xe.createElement(O,null,Xe.createElement(Y,{leadingIcon:S.X.CSS,label:"Close alert",iconOnly:!0,size:"small",kind:"blank",style:u.margin.left100,onPress:()=>{h(!0),qe.set(a,!0)}})):null),Xe.createElement(O,null,Xe.createElement(T,{style:[u.text.uiSmall,u.text.colorMuted]},e)),t?Xe.createElement(O,{style:[u.margin.top400,u.padding.right300]},t):null)}s();var Jt=P(k());function Dd(r){let{children:n,...e}=r;return Jt.createElement(Ps,null,Jt.createElement(Hs,null,Jt.createElement(Ls,null,Jt.createElement(cc,{...e}),Jt.createElement(Iu,null),Jt.createElement(Au,null),n)))}s();var $d=P(tr(),1),jd=P(Nd(),1);s();var Jd=P(tr(),1),qd=P(Vd(),1);var Fe=W("hive:socket");var Mo=class{constructor(n){this.state="closed";this.destroyed=!1;this.openBackoffDelay=1e3;this.pendingMessages=[];this.events=new Jd.EventEmitter;this.getSocketURL=n}async open(){if(this.assertNotDestroyed(),this.webSocket)throw new Error("WebSocket already opened");this.clearScheduledReconnection();let n=await this.getSocketURL();this.setState("connecting");let e=!1;return new Promise(t=>{Fe.info("Opening WebSocket:",n);let o=new qd.default.w3cwebsocket(n);this.webSocket=o;try{o.binaryType="arraybuffer"}catch{}o.onopen=()=>{if(this.destroyed){o.close();return}Fe.warning("WebSocket opened"),this.setState("open"),this.sendPendingMessages(),t()},o.onclose=i=>{if(e){let c=yy(i);Fe.error("WebSocket closed with error:",i.code,c),i.code!==1006&&Xn(new Error(`HiveSocket error [${i.code}]: ${c}`))}if(this.destroyed)return;let a=this.state;this.close("closed"),a==="connecting"&&Fe.error("Websocket closed before initial connection",i),a==="open"&&(Fe.warning("WebSocket unexpectedly closed, reconnecting:",i.code,i.reason),this.scheduleReconnection())},o.onerror=i=>{if(e=!0,this.destroyed)return;let a=this.state;this.close("errored"),a==="connecting"&&Fe.error("Websocket error with initial connection",i),Fe.error("WebSocket error, reconnecting:",i),this.scheduleReconnection()},o.onmessage=i=>{if(this.destroyed){o.close();return}let a=i.data;a instanceof ArrayBuffer&&this.events.emit("message",new Uint8Array(a))}})}close(n="closed"){this.assertNotDestroyed(),this.setState(n),this.openBackoffTimer&&(clearTimeout(this.openBackoffTimer),this.openBackoffTimer=void 0),this.webSocket&&(Fe.info("Closing WebSocket"),this.webSocket.close(),this.webSocket=void 0)}destroy(){this.close(),this.events.removeAllListeners(),this.destroyed=!0}scheduleReconnection(){this.openBackoffTimer||(this.webSocket&&this.close(),Fe.info("Scheduling reconnection in",this.openBackoffDelay,"ms"),this.openBackoffTimer=setTimeout(()=>{this.open().catch(n=>{if(this.destroyed)throw n;this.close("errored"),Fe.error("Failed to reopen socket",n),Fe.error("Retrying..."),this.scheduleReconnection()}),this.openBackoffDelay=Math.min(this.openBackoffDelay*2,3e4)},this.openBackoffDelay))}async forceScheduledReconnection(){if(!this.openBackoffTimer)throw new Error("No scheduled reconnection");await this.open()}clearScheduledReconnection(){this.openBackoffTimer&&(clearTimeout(this.openBackoffTimer),this.openBackoffTimer=void 0)}listen(n,e){return this.assertNotDestroyed(),this.events.addListener(n,e),()=>{this.events.removeListener(n,e)}}send(n){if(this.assertNotDestroyed(),this.state!=="open"||!this.webSocket){this.pendingMessages.push(n);return}this.webSocket.send(n)}sendPendingMessages(){let n=this.webSocket;this.state!=="open"||!n||(this.pendingMessages.forEach(e=>n.send(e)),this.pendingMessages=[])}setState(n){this.state!==n&&(Fe.info("socket changing state from",this.state,"to",n),this.state=n,this.events.emit("state",n))}assertNotDestroyed(){if(this.destroyed)throw new Error("socket is destroyed")}};function yy(r){return r.code===1e3?"Normal closure, meaning that the purpose for which the connection was established has been fulfilled.":r.code===1001?'An endpoint is "going away", such as a server going down or a browser having navigated away from a page.':r.code===1002?"An endpoint is terminating the connection due to a protocol error":r.code===1003?"An endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message).":r.code===1004?"Reserved. The specific meaning might be defined in the future.":r.code===1005?"No status code was actually present.":r.code===1006?"The connection was closed abnormally, e.g., without sending or receiving a Close control frame":r.code===1007?"An endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [https://www.rfc-editor.org/rfc/rfc3629] data within a text message).":r.code===1008?'An endpoint is terminating the connection because it has received a message that "violates its policy". This reason is given either if there is no other sutible reason, or if there is a need to hide specific details about the policy.':r.code===1009?"An endpoint is terminating the connection because it has received a message that is too big for it to process.":r.code===1010?`An endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake. <br /> Specifically, the extensions that are needed are: ${r.reason}`:r.code===1011?"A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.":r.code===1015?"The connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified).":"Unknown reason"}var X=W("hive:datasync"),Gd=3e4;var En=class{constructor(n,e,t={}){this.state="closed";this.operation=null;this.clientId=null;this.socket=null;this.encoder=null;this.currentPresence=null;this.beforeTransactionPresence=null;this.destroyed=!1;this.events=new $d.EventEmitter;this.batchUpdates=[];this.rpcClients=[];this.updateLog=[];this.messageResolvers=new Map;let{YType:o=Ye,readOnly:i=!1}=t;if(typeof globalThis.window>"u")throw new Error("HiveDataSyncClient can only be used in the browser, or in node process when running tests");this.guid=e,this.client=n,this.doc=new hc({guid:e}),this.presences=[],this.YType=o,this.#e=i;let a=this.doc.get("data",o);this.undoManager=new Cc(a,{trackedOrigins:new Set(["local"])}),this.undoManager.on("stack-item-added",c=>{c.stackItem.meta.set("positionsBefore",this.beforeTransactionPresence?.positions),c.stackItem.meta.set("positions",this.currentPresence?.positions)}),this.undoManager.on("stack-item-updated",c=>{c.stackItem.meta.set("positions",this.currentPresence?.positions)}),this.undoManager.on("stack-item-popped",c=>{let h=c.type==="undo"?this.undoManager.redoStack:this.undoManager.undoStack,p=h[h.length-1];p&&(p.meta.set("positions",c.stackItem.meta.get("positionsBefore")),p.meta.set("positionsBefore",c.stackItem.meta.get("positions")));let d=c.stackItem.meta.get("positionsBefore");d&&this.events.emit("restorePositions",d)}),this.doc.on("updateV2",(c,h)=>{this.pushUpdateToLog(c,h),h!=="remote"&&(this.dangerouslyPaused?this.dangerouslyPaused.push(c):this.batchUpdate(c)),X.info("call update listeners"),this.events.emit("update",h)}),this.doc.on("sync",()=>{this.doc.isSynced&&X.info(`doc "${this.doc.guid}" is synced`),this.updateState()})}#e;updateState(){let n="closed";if(this.socket)switch(this.socket.state){case"connecting":n="connecting";break;case"open":this.doc.isSynced?n="open":n="connecting";break;case"errored":n="errored";break}n!==this.state&&(this.state=n,this.events.emit("state",n))}get presence(){return this.currentPresence||null}get readOnly(){return this.#e??!1}async setReadOnly(n){if(this.#e===n)return[];let e;return n&&(this.flushBatchUpdates(),e=this.waitForSync()),this.#e=n,this.events.emit("readOnly",n),e??[]}get clock(){let n=this.doc.get("data",this.YType);return fc(n)}open(n,e,t,o={}){if(this.assertNotDestroyed(),this.socket)switch(this.socket.state){case"open":case"connecting":return this.doc.isLoaded?void 0:this.doc.whenLoaded;case"errored":return Promise.reject(new Error("Connection failed to establish with the server"));case"closed":{let p=this.socket;this.socket=null,p.destroy();break}default:te(this.socket.state)}X.info("opening datasync socket",e,t,o);let i=this.client.getSocket(n,e,t,o);this.socket=i;let a=rd({promptInit:p=>{this.sendInit(p.stateVector)},init:({update:p,version:d})=>{Ni(this.doc,d,p,"remote"),this.doc.emit("sync",[!0])},update:({id:p,update:d,version:f})=>{X.info(`received update ${p} from client (size: ${d.byteLength})`),Ni(this.doc,f,d,"remote")},updatePresence:()=>{},broadcastOperation:p=>{this.operation={...p.operation,payload:p.operation.payload||{},createdAt:Number(p.operation.createdAt),updatedAt:Number(p.operation.updatedAt)},this.events.emit("operation",this.operation)},broadcastPresences:p=>{X.info("received broadcast presences message");let d=this.clientId;this.clientId=p.selfClientId,d!==p.selfClientId&&(X.info("client id changed to",p.selfClientId),this.events.emit("clientId",p.selfClientId)),this.presences=Object.values(p.presences||{}).map(f=>({clientId:f.clientId,joinTimestamp:Number(f.joinTimestamp),updateTimestamp:Number(f.updateTimestamp),data:f.data||{},positions:Object.fromEntries(Object.entries(f.positions||{}).map(([y,C])=>[y,Sc(C)]))})).sort((f,y)=>f.joinTimestamp-y.joinTimestamp),this.events.emit("presences")},ack:p=>{this.ackMessage(p.message)},rpcRequest:p=>{},rpcReply:p=>{for(let d of this.rpcClients)if(d.onReplyMessage(p))return}});this.encoder=nd((p,d,f)=>{this.messageResolvers.has(d)&&this.messageResolvers.get(d).resolve("message resent before ack");let y={isResolved:!1};y.promise=new Promise(C=>{y.resolve=I=>{if(!y.isResolved)if(y.isResolved=!0,clearTimeout(y.timeoutId),this.messageResolvers.delete(d),I){let v=new Xi(I,{guid:this.guid,messageId:d,clientId:this.clientId||"",messageType:f});X.warning(v.toString()),C(v)}else X.debug(`ack message ${d}`),C(void 0)}}),y.timeoutId=setTimeout(()=>{y.resolve(`timed out waiting for ack after ${Gd/1e3}s`)},Gd),this.messageResolvers.set(d,y),i.send(p)}),i.listen("state",p=>{this.updateState(),p==="open"?(this.sendPromptInit(),this.sendPresence()):this.doc.emit("sync",[!1])}),i.listen("message",p=>{Promise.resolve(a(p)).catch(d=>{X.error("failed to decode message",d),Xn(d)})});let c=new Be(`hive:datasync:open:${e}`);if(c.setLabels(t),c.wrapPromise(i.open()).catch(p=>{X.error("failed to open datasync socket",p),Xn(p)}),this.doc.isLoaded){X.info(`doc "${this.doc.guid}" is already loaded`);return}X.info(`waiting for doc "${this.doc.guid}" to be loaded`);let h=new Be(`hive:datasync:sync:${e}`);return h.setLabels(t),h.wrapPromise(this.doc.whenLoaded.then(()=>{X.info(`doc "${this.doc.guid}" is loaded`)}))}close(){if(this.assertNotDestroyed(),!this.socket){X.info("closing datasync, but socket is already closed");return}X.info("closing datasync socket"),this.socket.destroy(),this.socket=null,this.encoder=null}destroy(){this.close(),this.batchDebounceFlush?.cancel(),this.undoManager.destroy(),this.doc.destroy(),this.events.removeAllListeners(),this.destroyed=!0}listen(n,e){return this.assertNotDestroyed(),this.events.addListener(n,e),()=>{this.events.removeListener(n,e)}}async waitForSync(){if(this.assertNotDestroyed(),this.messageResolvers.size===0)return[];let n=Array.from(this.messageResolvers.keys()),e=n.map(o=>this.messageResolvers.get(o).promise);X.info(`waiting for sync of ${n.length} messages`);let t=(await Promise.all(e)).filter(ue);return X.info(`waiting for sync finished, there were ${t.length} errors from ${n.length} messages`),t}transact(n){return this.assertNotDestroyed(),X.info("start transaction on document"),this.beforeTransactionPresence=this.currentPresence,this.doc.transact(()=>n(this.doc),"local")}setPresence(n){this.assertNotDestroyed(),X.info("set presence",n),this.currentPresence={data:n.data||this.currentPresence?.data||{},positions:Object.fromEntries(Object.entries(n.positions||{}).map(([e,t])=>t?[e,vc(t.type,t.index,t.assoc)]:null).filter(ue))},this.sendPresence()}undo(){this.undoManager.undo()}redo(){this.undoManager.redo()}stopCapturing(){this.undoManager.stopCapturing()}hasBatchingEnabled(){return!!this.batchDebounceFlush}hasBatchedUpdates(){return this.batchUpdates.length>0}hasUnsyncedUpdates(){return this.messageResolvers.size>0}resetBatchingInterval(n,e=n*5){n?(this.batchDebounceFlush?.cancel(),this.batchDebounceFlush=(0,jd.default)(()=>{this.flushBatchUpdates()},n,{maxWait:e})):(this.flushBatchUpdates(),this.batchDebounceFlush=void 0)}disableBatching(){this.resetBatchingInterval(0)}flushBatchUpdates(){if(this.readOnly||(this.batchDebounceFlush?.cancel(),this.batchUpdates.length===0))return;let n=this.batchUpdates;this.batchUpdates=[];let e=eo(n);this.sendUpdate(e)}sendPresence(){!this.encoder||!this.currentPresence||(X.info("sending presence to server"),this.encoder.write({updatePresence:{id:this.encoder.newMessageID(),data:this.currentPresence.data,positions:Object.fromEntries(Object.entries(this.currentPresence.positions).map(([n,e])=>[n,bc(e)]))}}))}sendPromptInit(){this.encoder&&(X.info("sending prompt to init to server"),this.encoder.write({promptInit:{id:this.encoder.newMessageID(),stateVector:yc(this.doc),version:rt.V2}}))}sendInit(n){!this.encoder||this.readOnly||(X.info("sending init to server"),this.encoder.write({init:{id:this.encoder.newMessageID(),update:Zr(this.doc,n),version:rt.V2}}))}batchUpdate(n){if(!this.readOnly){if(!this.batchDebounceFlush){this.sendUpdate(n);return}this.batchUpdates.push(n),this.batchDebounceFlush()}}sendUpdate(n){if(!this.encoder||this.readOnly)return;let e=this.encoder.newMessageID();X.info(`sending update ${e} to server (size: ${n.byteLength})`),this.encoder.write({update:{id:e,update:n,version:rt.V2}})}ackMessage(n){let e=this.messageResolvers.get(n);e&&e.resolve()}assertNotDestroyed(){if(this.destroyed)throw new Error("datasync is destroyed")}dangerouslyPauseSync(){throw new Error("dangerouslyPauseSync should only be used for testing")}async dangerouslyResumeSync(){throw new Error("dangerouslyPauseSync should only be used for testing")}useRPC(n){let e=od(n,{newMessageID:()=>(Qn(this.encoder),this.encoder.newMessageID()),write:t=>{Qn(this.encoder),this.encoder.write(t)}});return this.rpcClients.push(e),[e.service,()=>{this.rpcClients.splice(this.rpcClients.indexOf(e),1)}]}pushUpdateToLog(n,e){this.updateLog.push({timestamp:Date.now(),update:n,origin:typeof e=="object"?JSON.stringify(e):String(e)})}getUpdateLog(){return Ot.DebugLog.encode({updates:this.updateLog.map(e=>({timestamp:e.timestamp,update:e.update,origin:e.origin}))}).finish()}},Xi=class extends Error{constructor(n,e){super(n),this.guid=e.guid,this.messageId=e.messageId,this.clientId=e.clientId,this.messageType=e.messageType}toString(){return`MessageSyncError: ${this.message} guid=${this.guid} messageType=${this.messageType} messageId=${this.messageId} clientId=${this.clientId}`}};s();var Xd=P(tr(),1);var br=class{constructor(n,e,t,o={}){this.events=new Xd.default;this.manager=n,this.contentId=t.contentId,this.branchId=t.branchId,this.dataSync=new En(n.client,e,{readOnly:o.readOnly}),this._change=ed(Po(this.dataSync.doc)),this.dataSync.listen("update",()=>{this.dataSync.doc.transact(()=>{Ro(Po(this.dataSync.doc))},"local"),this.#e=Xu(Po(this.dataSync.doc)),this.events.emit("update")})}#e;get revision(){return this.#e}get presences(){return this.dataSync.presences}keepAlive(){return this.manager.keepAlive(this)}open(n={}){return this.dataSync.presence||this.dataSync.setPresence({data:n}),this.dataSync.open(this.contentId,"/branches/:branchId/datasync",{branchId:this.branchId},this.manager.clientId?{clientId:this.manager.clientId}:{})}close(){this.manager.close(this)}destroy(){this.dataSync.destroy()}waitForSync(){return this.dataSync.waitForSync()}listen(n,e){return n==="update"?(this.events.addListener(n,e),()=>{this.events.removeListener(n,e)}):this.dataSync.listen(n,e)}openPage(n){let e=this.dataSync.presence;this.manager.touch(this),e&&this.dataSync.setPresence({data:{...e.data,pageId:n}})}syncChange(n){return this.manager.touch(this),this.dataSync.transact(t=>n(this._change))}async change(n){if(this.dataSync.readOnly)throw new Error("can't apply change when dataSync is in read-only mode");let e=this.syncChange(n);return await this.waitForSync(),e}};s();var Zd=P(tr(),1);var vy=W("hive:branch-document"),Sr=class{constructor(n,e,t,o={}){this.events=new Zd.EventEmitter;this.manager=n,this.contentId=t.contentId,this.branchId=t.branchId,this.pageId=t.pageId,this.singleEditBatchingInterval=o.singleEditBatchingInterval??1500,this.#e=wi.create(),this.dataSync=new En(n.client,e,{YType:ke,readOnly:o.readOnly}),this.dataSync.resetBatchingInterval(this.singleEditBatchingInterval),this.dataSync.listen("restorePositions",a=>{let c=this.createSelectionFromRelatives(this.value.document,a);c=c?c.normalize(this.value.document):nr.create(),this.#e.selection.isFocused&&(c=c.focus()),this.#e=this.#e.merge({selection:c}),this.events.emit("value")}),this.dataSync.listen("update",a=>{a==="local"||this.createSlateValue(),this.events.emit("value")}),this.dataSync.listen("presences",()=>{this.dataSync.presences.length>0?this.dataSync.hasBatchingEnabled()&&this.dataSync.disableBatching():this.dataSync.hasBatchingEnabled()||this.dataSync.resetBatchingInterval(this.singleEditBatchingInterval),this.updateSelections()}),this.dataSync.listen("state",a=>{a==="open"&&this.updateSelections()});let[i]=this.dataSync.useRPC("DocumentCompletions");this.completions=i}#e;async*streamRPCMethod(n,e,t){let[o,i]=this.dataSync.useRPC(n),a=[],c,h,p=new Promise((b,A)=>{c=b,h=A}),d=!1;function f(b){a.push(b),c(),p=new Promise((A,E)=>{c=A,h=E})}function y(b){if(typeof b!="object"||!b||!("id"in b)||!("completion"in b)||typeof b.id!="string")throw new Error("Invalid response")}function C(b,A){y(b),f(b)}function I(){i(),d=!0,c()}function v(b){vy.error("Error while streaming RPC result",b),i(),h(b)}o.on("data",C),o.on("end",I),o.on("error",v);let g=o[e];if(typeof g!="function")throw new Error(`Invalid method name: ${String(e)}`);for(g.bind(o)(t).catch(()=>{});!d;)await p,yield*a,a=[]}streamAICompletion(n){return this.streamRPCMethod("DocumentCompletions","streamAICompletion",n)}get value(){return this.#e}createSlateValue(){let n=kn(this.dataSync.doc);this.dataSync.doc.transact(()=>md(n),"local");let e=ad(n);this.dataSync.doc.transact(()=>{let t=this.value.selection,o=Zs[e.data.get("schemaType")||"document"],i=wi.create({document:e},{normalize:!1}).setSchema(o);if(i.document!==e)throw new Error("Document should not be modified by creation of Value");let a=i.change({save:!1}).normalize();if(a.value.document!==i.document){i=i.merge({document:a.value.document}),Yi(a,n);let h=vi();try{Fi(a.value.document,n)}catch(p){if(!(p instanceof fe))throw p;let d=h();throw this.dataSync.destroy(),sn.annotateError(p,{tags:{error_category:"hive-document-init"},extra:{durationMs:d,contentId:this.contentId,branchId:this.branchId,pageId:this.pageId},attachments:[{name:"normalization.json",body:Qi(p,a)},{name:"updates.bin",body:this.dataSync.getUpdateLog()}]})}}let c=this.dataSync.presence?this.createSelectionFromRelatives(i.document,this.dataSync.presence.positions):void 0;c&&(c=c.normalize(e)),c&&t.isFocused&&(c=c.focus()),i=i.merge({selection:c??nr.create()}),this.#e=i},"local")}keepAlive(){return this.manager.keepAlive(this)}open(n={}){return this.dataSync.presence||this.dataSync.setPresence({data:n}),this.dataSync.open(this.contentId,"/branches/:branchId/pages/:pageId/document/datasync",{branchId:this.branchId,pageId:this.pageId},this.manager.clientId?{clientId:this.manager.clientId}:{})}close(){this.manager.close(this)}destroy(){this.dataSync.destroy()}waitForSync(){return this.dataSync.waitForSync()}listen(n,e){return this.events.addListener(n,e),()=>{this.events.removeListener(n,e)}}applyChange(n){if(this.dataSync.readOnly)throw new Error("can't apply change when dataSync is in read-only mode");this.manager.touch(this);let e=this.value;if(e!==n.initialValue){let t=new fe("Slate change.initialValue does not match the value of HiveBranchDocument. This could indicate a nested .change() call, or a datasync inconsistency issue.");throw this.dataSync.destroy(),sn.annotateError(t,{tags:{error_category:"hive-document-initial-value"},extra:{contentId:this.contentId,branchId:this.branchId,pageId:this.pageId},attachments:[{name:"change.json",body:Qi(t,n)},{name:"updates.bin",body:this.dataSync.getUpdateLog()}]})}if(this.#e=n.value,e.document!==n.value.document){let t=vi();this.dataSync.transact(o=>{Yi(n,kn(o));try{Fi(n.value.document,kn(o))}catch(i){if(!(i instanceof fe))throw i;let a=t();throw this.#e=e,this.dataSync.destroy(),sn.annotateError(i,{tags:{error_category:"hive-document-change"},extra:{durationMs:a,contentId:this.contentId,branchId:this.branchId,pageId:this.pageId},attachments:[{name:"change.json",body:Qi(i,n)},{name:"updates.bin",body:this.dataSync.getUpdateLog()}]})}}),this.updateSelections()}else this.events.emit("value");if(n.value.selection!==e.selection){let t=n.value.selection;this.dataSync.setPresence({data:{...this.dataSync.presence?.data||{}},positions:pd(n.value.document,this.dataSync.doc,t)})}n.value.selection.isBlurred&&this.dataSync.flushBatchUpdates()}async change(n){let e=this.value.change();n(e),this.applyChange(e),await this.waitForSync()}updateSelections(){this.dataSync.state!=="open"?this.selections=fn.create():this.selections=fn.create(this.dataSync.presences.map(n=>{let e=this.createSelectionFromRelatives(this.value.document,n.positions);return e?e.merge({data:mn.create({clientId:n.clientId,...n.data})}):null}).filter(ue)),this.events.emit("selections")}undo(){return this.dataSync.undo()}redo(){return this.dataSync.redo()}createSelectionFromRelatives(n,e){let t=this.dataSync.doc;return fd(n,{anchor:e.anchor&&Pi(e.anchor,t)||void 0,focus:e.focus&&Pi(e.focus,t)||void 0})}};function Qi(r,n){return JSON.stringify({initialValue:rr(n.initialValue),...r.slateValue?{slateValue:r.slateValue}:{},...r.yValue?{yValue:r.yValue}:{},operations:n.operations.map(([e])=>rr(e)),flags:Object.keys(n.flags).length>0?n.flags:void 0})}s();var Ho=class{constructor(n,e={}){this.browserCache=e.browserCache,this.cache=zt({getKey:t=>t,getValue:async t=>{if(_o(t))throw new Error("content permissions patterns must be cached before access");let o=await n(t),i=Array.isArray(o)?o:[o],a;if(i.forEach(c=>{let h=Ed(c),p={token:c,metadata:h};Object.keys(h.payload.content).forEach(d=>{Td(t,h.payload)&&(a=p),t!==d&&this.cache.write(d,p)})}),!a)throw new Lt.Forbidden(`No authentication for content "${t}"`);return a},ttl:t=>t.metadata.expiration-(Date.now()+5*60*1e3),effects:this.browserCache?[this.browserCache.effect]:[]})}async getParsedToken(n){if(this.cache.getCacheState(n))return this.cache.readAsync(n);let e=Array.from(this.cache.keys()).filter(o=>{let i=this.cache.getCacheState(o);return i&&i.state!=="failed"}),t=Gi(n,e);if(t){let o=await this.cache.readAsync(t);return this.cache.write(n,o),o}return this.cache.readAsync(n)}async getToken(n){if(_o(n))throw new Error("HiveAuthTokenManager.getToken called with a glob pattern, only absolute ids are allowed.");let{token:e}=await this.getParsedToken(n);return e}async clearCache(){this.cache.clearAll(),this.browserCache&&await this.browserCache.clearCache()}};s();s();s();var wr=Symbol("HiveDataSyncCacheOrigin"),No=class{};var by="hive-docs",Et=W("hive:browsercache"),Sy=100,Bo=class extends No{constructor(){super();this.updateCountByGuid=new Map;this.db=new vs(by),this.db.version(1).stores({updates:"++id,guid,at,state"})}get updates(){return this.db.table("updates")}async clear(){await this.db.delete()}registerDoc(e){let t=()=>{let o=(a,c)=>{c!==wr&&this.pushUpdate(e,a).catch(h=>{Et.error(`error pushing update for ${e.guid}`,h)})},i=()=>{e.off("updateV2",o),e.off("destroy",i)};e.on("updateV2",o),e.on("destroy",i),this.fetchUpdates(e).catch(a=>{Et.error(`error fetching updates for ${e.guid}`,a)})};this.db.isOpen()?t():(this.db.on("ready",t),this.db.open().catch(o=>{Et.error("error opening IndexedDB",o)}))}async fetchUpdates(e){let t=await this.updates.where("guid").equals(e.guid).toArray();if(!t.length){Et.info(`no updates found for ${e.guid}`);return}Et.info(`fetched ${t.length} updates for ${e.guid}`);let o=0;wc(e,()=>{for(let i of t)e.transact(()=>{o+=i.value.byteLength,Qr(e,i.value,wr)},wr)},wr,!1),Et.info(`loaded ${t.length} updates (${o} bytes) for ${e.guid}`),e.emit("load",[]),this.updateCountByGuid.set(e.guid,t.length)}async pushUpdate(e,t){let o=this.updateCountByGuid.get(e.guid)??0;if(o>=Sy){await this.resetDoc(e);return}Et.info(`push update for ${e.guid} (${t.byteLength} bytes, ${o+1} updates)`);let i=Date.now();await this.updates.add({guid:e.guid,value:t,at:i,state:!1}),this.updateCountByGuid.set(e.guid,(this.updateCountByGuid.get(e.guid)??0)+1)}async resetDoc(e){let t=Zr(e);Et.info(`reset cache for ${e.guid} with ${t.byteLength} bytes`),await this.db.transaction("rw",this.updates,async o=>{await this.updates.where("guid").equals(e.guid).delete();let i=Date.now();await this.updates.add({guid:e.guid,value:t,at:i,state:!0})}),this.updateCountByGuid.set(e.guid,0)}};var ep=W("hive:datasync-manager"),Zi=2,Lo=class{constructor(n,e={}){this.syncs=new Map;this.ids=new WeakMap;this.gcClock=0;this.cache=new Bo;this.client=n,this.ttl=e.ttl??1e3*60*5}async clearCache(){await this.cache.clear()}close(n){let e=this.ids.get(n);if(!e)throw new Error("Unknown sync client");let t=this.syncs.get(e);if(!t)throw new Error("Expected sync client to be registered");t.sync.destroy(),this.syncs.delete(e),this.ids.delete(n)}closeAll(){this.stopGarbageCollect(),[...this.syncs.values()].map(n=>n.sync.close()),this.syncs=new Map,this.ids=new WeakMap}touch(n){let e=this.ids.get(n);if(!e)return!1;let t=this.syncs.get(e);if(!t)throw new Error("Expected sync client to be registered");return t.clock=this.gcClock,!0}keepAlive(n){this.touch(n);let e=setInterval(()=>{this.touch(n)||t()},this.ttl/2),t=()=>{e&&clearInterval(e),e=void 0};return t}async withReadOnlyDataSyncs(n,e){let t=[],o=new WeakMap;for(let{sync:i}of this.syncs.values())!i.dataSync.readOnly&&e(i)&&(o.set(i,i.dataSync.readOnly),t.push(i.dataSync.setReadOnly(!0)));try{let i=(await Promise.all(t)).flat();if(i.length)throw sn.annotateError(new Error("Cannot set data-syncs to read-only"),{tags:{error_category:"data-sync-flush"},attachments:[{name:"logs.txt",body:i.map(a=>a.toString()).join(`
`)}]});return await n()}finally{for(let{sync:i}of this.syncs.values())o.has(i)&&await i.dataSync.setReadOnly(o.get(i))}}branch(n,e,t){let o=this.getSync(`content/${n}/branches/${e}/datasync`,(i,a)=>new br(this,i,{contentId:n,branchId:e},{readOnly:a?.readOnly}),t);if(o&&!(o instanceof br))throw new Error(`Expected HiveBranchRevision, got ${o.constructor.name}`);return o}pageDocument(n,e,t,o){let i=this.getSync(`content/${n}/branches/${e}/pages/${t}/document/datasync`,(a,c)=>new Sr(this,a,{contentId:n,branchId:e,pageId:t},c),o);if(i&&!(i instanceof Sr))throw new Error(`Expected HiveBranchDocument, got ${i.constructor.name}`);return i}getSync(n,e,t){let o=this.syncs.get(n);if(o)return t?.readOnly&&o.sync.dataSync.setReadOnly(t.readOnly),o.sync;if(t?.autoInit===!1)return;let i=e(n,t);return this.syncs.set(n,{sync:i,clock:this.gcClock}),this.ids.set(i,n),i.dataSync.listen("clientId",a=>{this.clientId=a}),ep.info(`initialize sync for "${n}"`),this.startGarbageCollect(),i}garbageCollect(){this.gcClock+=1;for(let[n,{sync:e,clock:t}]of this.syncs.entries())if(t<this.gcClock-Zi){let o=(this.gcClock-t)*(this.ttl/Zi);ep.info(`garbage collection "${n}", last active ~${o}ms ago`),this.close(e)}this.syncs.size===0&&this.stopGarbageCollect()}startGarbageCollect(){this.gcInterval||(this.gcInterval=setInterval(()=>this.garbageCollect(),this.ttl/Zi))}stopGarbageCollect(){this.gcInterval&&(clearInterval(this.gcInterval),this.gcInterval=void 0)}};s();var zo=class{constructor(n){this.branchesCache=zt({getKey:n=>`${n.contentId}:${n.branchId}`,getValue:async n=>{try{return await this.client.getBranch(n.contentId,n.branchId)}catch(e){if(e.statusCode===404)return;throw e}}});this.revisionsCache=zt({getKey:n=>`${n.contentId}:${n.revisionId}:${n.metadata}`,getValue:async n=>{try{return await this.client.getRevision(n.contentId,n.revisionId,{metadata:n.metadata})}catch(e){if(e.statusCode===404)return;throw e}}});this.branchesHistoryCache=zt({getKey:n=>`${n.contentId}:${n.branchId}:${n.initialRevisionId}:${n.size}:${n.git??!1}`,getValue:async n=>await this.client.getBranchHistory(n.contentId,n.branchId,{page:n.initialRevisionId,limit:n.size,...n.git!==void 0?{git:n.git}:{}})});this.documentsCache=zt({getKey:n=>`${n.contentId}:${n.documentId}`,getValue:async n=>{try{return await this.client.getDocument(n.contentId,n.documentId)}catch(e){if(e.statusCode===404)return;throw e}},toJS:n=>n!==void 0?rr(n):"undefined",fromJS:n=>n!=="undefined"?$s(n):void 0});this.client=n}getBranchHistory(n,e,t){return un(this.branchesHistoryCache.readCacheState({contentId:n,branchId:e,initialRevisionId:t.page,size:t.limit,...t.git!==void 0?{git:t.git}:{}}))}getBranchRevision(n,e){let t=this.client.sync.branch(n,e,{autoInit:!1});return t?t.revision:dn(un(this.branchesCache.readCacheState({contentId:n,branchId:e})),o=>{if(o)return this.getRevision(n,o.revision)})}getBranchPageDocument(n,e,t){let o=this.client.sync.pageDocument(n,e,t,{autoInit:!1});return o?o.value.document:dn(un(this.branchesCache.readCacheState({contentId:n,branchId:e})),i=>{if(i)return dn(this.getRevision(n,i.revision),a=>{if(a){let c=a.pages[t];return c?.type!=="document"?void 0:c.document?this.getDocument(n,c.document):tc(c.id).document}})})}getRevision(n,e,t={metadata:!0}){if(!t.metadata){let o=this.revisionsCache.getCacheState({contentId:n,revisionId:e,metadata:!0});if(o&&o.result)return o.result}return un(this.revisionsCache.readCacheState({contentId:n,revisionId:e,metadata:t.metadata}))}hasRevision(n,e){let t=this.revisionsCache.getCacheState({contentId:n,revisionId:e,metadata:!0});return!!t&&t.result!==void 0}assertRevision(n,e,t){return dn(this.getRevision(n,e,t),o=>{if(!o)throw new Error(`Revision ${e} not found in content ${n}`);return o})}getDocument(n,e){return un(this.documentsCache.readCacheState({contentId:n,documentId:e}))}assertDocument(n,e){return dn(this.getDocument(n,e),t=>{if(!t)throw new Error(`Document ${e} not found in content ${n}`);return t})}toJSON(){return{documents:this.documentsCache.toJS(),revisions:this.revisionsCache.toJS(),branches:this.branchesCache.toJS()}}fromJSON(n){n.documents&&this.documentsCache.fromJS(n.documents),n.revisions&&this.revisionsCache.fromJS(n.revisions),n.branches&&this.branchesCache.fromJS(n.branches)}};s();s();var tp={},np=globalThis.fetch,rp=Headers;s();var op=P(tr(),1);var Uo=class{constructor(n,e,t,o,i){this.id=void 0;this.state=null;this.events=new op.default;this.client=n,this.contentId=e,this.path=t,this.pathParams=o,i&&(this.id=i)}async start(n={}){if(this.id)throw new Error("Operation already started");let t=await(await this.client.request(this.contentId,this.path,{path:this.pathParams},{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(n)})).json();return this.setState(t),t}async update(n){if(!this.id)throw new Error("Operation not started or HiveContentOperation() is called without an existing operation ID");let t=await(await this.client.request(this.contentId,this.path,{path:this.pathParams},{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({...n,id:this.id})})).json();return this.setState(t),t}async markAsSucceeded(){return this.update({status:2})}setState(n){this.id=n.id,this.state=n,this.events.emit("update",n)}listen(n){return this.events.on("update",n),()=>{this.events.off("update",n)}}};var wy=W("hive:client"),ip=typeof globalThis.window<"u"||!1,Yo=class{constructor(n,e,t={}){this.isRunningAtEdge=ip;let o;this.getEndpoint=typeof n=="string"?()=>Promise.resolve(n):async()=>(o||(o=await n()),o),this.auth=new Ho(e,{browserCache:t.tokensBrowserCache}),this.store=new zo(this),this.sync=new Lo(this),this.clientId=hn(),t.locationHint&&(this.isRunningAtEdge=t.locationHint)}close(){this.sync.closeAll()}async clearAuthCache(){await Promise.all([this.auth.clearCache(),this.sync.clearCache()]),this.close()}getSocket(n,e,t,o){if(!this.isRunningAtEdge||!ip)throw new Error("HiveClient#getSocket can only be called from the edge");let i=async()=>{let a=ap(n,e,t),c=await this.auth.getToken(n),h=await this.getEndpoint(),p=new URL(a,h);if(p.protocol=p.protocol.replace("http","ws"),o)for(let[d,f]of Object.entries(o))p.searchParams.set(d,f);return p.searchParams.set("authToken",c),p.toString()};return new Mo(i)}async getBranch(n,e){return await(await this.request(n,"/branches/:branchId",{path:{branchId:e}})).json()}async getBranchRevision(n,e,t){return await(await this.request(n,"/branches/:branchId/save",{path:{branchId:e},query:t?{mask:t.join(",")}:{}},{method:"POST"})).json()}async saveBranch(n,e){return this.sync.withReadOnlyDataSyncs(async()=>({revisionId:(await this.getBranchRevision(n,e,["id"])).id}),t=>t.contentId===n)}async getBranchHistory(n,e,t={}){let{limit:o=10,page:i,git:a,refresh:c}=t;return await(await this.request(n,"/branches/:branchId/history",{path:{branchId:e},query:{limit:o.toString(),...i?{page:i}:{},...a!==void 0?{git:`${a}`}:{},...c!==void 0?{refresh:`${c}`}:{}}})).json()}async getRevision(n,e,t={}){let{mask:o,metadata:i=!0}=t,c=await(await this.request(n,"/revisions/:revisionId",{path:{revisionId:e},query:{...o?{mask:o.join(",")}:{},...i===!1?{metadata:"false"}:{}}})).json();return o||Ro(c),c}getRevisionInfo(n,e){return this.getRevision(n,e,{mask:pc})}async mergeBranch(n,e,t){if(!this.isRunningAtEdge)throw new Error("HiveClient#mergeBranch can only be called from the edge");return await(await this.request(n,"/branches/:branchId/merge",{path:{branchId:e}},{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:t?JSON.stringify({strategy:t}):void 0})).json()}async rollbackBranch(n,e,t){await this.request(n,"/branches/:branchId/rollback",{path:{branchId:e}},{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)})}async updateBranch(n,e){return await(await this.request(n,"/branches/:branchId/update",{path:{branchId:e}},{method:"POST"})).json()}async checkoutBranch(n,e,t,o={}){return(await this.request(n,"/branches/:branchId/checkout",{path:{branchId:e}},{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...Cy(o.operationId)},body:JSON.stringify(t)})).json()}async getDocument(n,e){let o=await(await this.request(n,"/documents/:documentId",{path:{documentId:e}},{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}})).arrayBuffer(),i=Ci(new Uint8Array(o)),a=new Be("HiveClient:getDocument.normalizeDocumentToLatestSchema");return a.label("contentId",n),a.label("documentId",e),a.wrapSync(()=>Ri(i))}async getPageDocument(n,e,t){if(!this.isRunningAtEdge)throw new Error("HiveClient#getPageDocument can only be called from the edge");let i=await(await this.request(n,"/branches/:branchId/pages/:pageId/document",{path:{branchId:e,pageId:t}})).arrayBuffer(),a=Ci(new Uint8Array(i)),c=new Be("HiveClient:getPageDocument.normalizeDocumentToLatestSchema");return c.label("contentId",n),c.label("pageId",t),c.wrapSync(()=>Ri(a))}async createDocument(n,e,t={}){let o=js(t.skipNormalization?e:ec(e),{preserveKeys:!0});return await(await this.request(n,"/documents",{query:t.documentId?{documentId:t.documentId}:{}},{method:"POST",headers:{Accept:"application/json","Content-Type":"application/octet-stream"},body:o})).json()}async createRevision(n,e){return await(await this.request(n,"/revisions",{},{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)})).json()}getContentOperation(n,e,t,o){return new Uo(this,n,e,t,o)}getBranchContentOperation(n,e,t){return this.getContentOperation(n,"/branches/:branchId/operation",{branchId:e},t)}async createFileBlob(n,e,t){let o=await this.request(n,"/blobs",{query:{name:e.name}},{method:"POST",headers:{Accept:"application/json","Content-Type":e.contentType},body:t}),{blobId:i}=await o.json();return{blobId:i,downloadURL:Du(await this.getEndpoint(),n,{blobId:i,name:e.name})}}async updateRevisionMetadata(n,e,t){return await(await this.request(n,"/revisions/:revisionId",{path:{revisionId:e}},{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)})).json()}async duplicateContent(n,e){return(await this.request(n.contentId,"/branches/:branchId/duplicate",{path:{branchId:n.branchId}},{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({origin:e,page:n.pageId})})).json()}async triggerAlarm(n,e={force:!1}){n.pageId?await this.request(n.contentId,"/branches/:branchId/pages/:pageId/document/alarm",{path:{branchId:n.branchId,pageId:n.pageId},query:{force:String(e.force)}},{method:"POST"}):await this.request(n.contentId,"/branches/:branchId/alarm",{path:{branchId:n.branchId},query:{force:String(e.force)}},{method:"POST"})}async request(n,e,t,o={},i={}){let{retries:a=3}=i,{path:c={},query:h={}}=t,p=hn(),d=new Be(`hive:request:${(o.method||"GET").toLowerCase()}:${e}`);return d.label("contentId",n),d.setLabels({requestId:p,clientId:this.clientId,locationHint:this.isRunningAtEdge,...t}),d.wrap(async()=>{let f=ap(n,e,c),y=await this.auth.getToken(n),C=await this.getEndpoint(),I=new URL(f,C);I.search=new URLSearchParams(h).toString();let v=new rp(o.headers||{});v.set("Authorization",`Bearer ${y}`),v.set("X-Request-Id",p),v.set("X-Client-Id",this.clientId),typeof this.isRunningAtEdge=="string"&&v.set("X-Hive-Location-Hint",this.isRunningAtEdge);let g=await sp(async()=>{let E=new AbortController,N=setTimeout(()=>{E.abort()},1e3*30),B=await np(I.toString(),{...tp,...o,headers:v,signal:E.signal});return clearTimeout(N),B},a),b=g.headers.get("cf-ray");if(d.label("rayId",b),!g.ok)try{let E="";try{E=(await g.clone().json()).error.message}catch{E=`Unexpected text response: ${await g.text()}`}throw Lt.fromStatusCode(g.status,E)}catch(E){throw E.statusCode?E:new Error(`Unexpected response with status code ${g.status}: ${E.message}`)}let A=new Be("HiveClient.cloneResponse");return A.label("contentId",n),A.setLabels({requestId:p,...t}),A.wrap(async()=>g.clone())})}};function ap(r,n,e){for(let[t,o]of Object.entries(e))n=n.replace(`:${t}`,o);return`content/${r}${n}`}function Cy(r){return r?{"X-Content-Operation-Id":r}:{}}async function sp(r,n=3,e=500){if(n<=0)return r();try{let t=await r();if(Math.floor(t.status/100)===5)throw Lt.fromStatusCode(t.status,t.statusText);return t}catch(t){if(wy.warning("retry because of error",t,{attemptsLeft:n,delay:e}),n>0)return await new Promise(o=>setTimeout(o,e)),sp(r,n-1,e*2);throw t}}s();var cp=P(Nc());function lp(r,n){return r.type!==n.type?!1:(0,cp.default)(r,n)}s();var Fo=P(k());var up=W("auth"),dp=hs(()=>new Be("auth.initialize").wrap(async()=>{let n=jc(),t=new URLSearchParams(window.location.search).get("auth_token")||void 0;if(t){window.history.replaceState({},"",window.location.pathname);try{up.info("authenticating with custom token before subscribing to auth"),await Gc(n,t),n.currentUser&&await qc(n.currentUser,!0)}catch(o){up.critical("Error during auth with custom token",o)}}return await new Promise((o,i)=>{let a=$c(n,()=>{a(),o()},i)}),{}}));async function pp(){await dp.readAsync({})}function fp(r){let{children:n}=r;return dp.read({}),Fo.createElement(Fo.Fragment,null,n)}s();var Ko=P(k());function mp(r){let{children:n}=r,e=Ko.useMemo(()=>{if(r.client)return r.client;let t=new Yo(r.endpoint,r.fetchContentAuthToken,{tokensBrowserCache:r.tokensBrowserCache});return r.store&&t.store.fromJSON(r.store),t},[r.client,r.endpoint,r.fetchContentAuthToken,r.store]);return Ko.createElement(ol.Provider,{value:e},n)}s();var Gt=W("history");function hp(){let r=ul(),n=[],e=!1,t,o=()=>{let a=n.shift();return a?(a(),!1):!0},i=a=>{e?n.push(a):a()};return{get location(){return r.location},listen:a=>r.listen(c=>{a({location:c.location,action:c.action})}),push:a=>{let{state:c,...h}=a;i(()=>{Gt.info("push",h,c),r.push(h,c)})},replace:a=>{let{state:c,...h}=a;i(()=>{Gt.info("replace",h,c),r.replace(h,c)})},go:a=>{i(()=>{Gt.info("go",a),r.go(a)})},transaction:a=>{if(e)a();else{let c=r.listen(()=>{o()&&c()});e=!0,a(),e=!1,o()&&c()}},block:(a,c)=>{if(t)throw new Error("History is already blocked");t=a;let h,p=()=>{Gt.info("stop blocking history"),h&&(h(),h=void 0)},d=()=>{Gt.info("start blocking history"),h=r.block(f=>{let y=()=>{Gt.info("unblock history transaction"),p(),f.retry(),d()},C=a(r.location,f.location);if(Gt.info(`history blocked=${C}`),!C){y();return}c({location:f.location,unblock:y})})};return d(),()=>{p(),t=void 0}},isBlocked:a=>t?t(r.location,a):!1}}s();var Tn=P(k()),gp=P(Ms());function yp(r){let{history:n,children:e}=r,t=Tn.useMemo(()=>n||hp(),[n]),o=Tn.useMemo(()=>({getCurrentValue:()=>t.location,subscribe:a=>t.listen(a)}),[t]),i=(0,gp.useSubscription)(o);return Tn.createElement(dl.Provider,{value:t},Tn.createElement(pl.Provider,{value:i},e))}s();var ne=P(k()),Dn=P(Ve());s();var vp=P(k()),bp=vp.default.lazy(()=>import("/public/dist/chunks/ImpersonateAccessBanner-KI3VWYFB.min.js"));function wp(r){let{Screen:n,fallback:e}=r,t=wn(),o=rl();return ne.createElement(ne.Fragment,null,o.impersonator?ne.createElement(bp,null):null,ne.createElement(Ru,{enabled:!t.overlay},ne.createElement(Sp,{screen:t.screen,fallback:e,Screen:n,isCurrent:!t.overlay,isOverlay:!1})),ne.createElement(jr,null,t.overlay?ne.createElement(Ze,null,ne.createElement(Dn.View,{style:[Dn.StyleSheet.absoluteFill,Ry.isOverlay]},ne.createElement(Dn.View,{style:[dt.flex1]},ne.createElement(Sp,{screen:t.overlay,fallback:e,Screen:n,isCurrent:!0,isOverlay:!0})))):null))}var Ry=Dn.StyleSheet.create({isOverlay:{zIndex:100}}),Sp=ne.memo(function(n){let{screen:e,fallback:t,isOverlay:o,isCurrent:i,Screen:a}=n,c=is(i);return ne.createElement(hl.Provider,{value:c},ne.createElement(ml.Provider,{value:i},ne.createElement(ne.Suspense,{fallback:t},ne.createElement(a,{screen:e,isCurrent:i,isOverlay:o}))))},(r,n)=>r.isCurrent===n.isCurrent&&r.isOverlay===n.isOverlay&&r.Screen===n.Screen&&lp(r.screen,n.screen));s();var ea=P(k());var Py=W("app:customerio");function Cp(){Oy(),Iy(lt.customerio)}function Iy(r){let n=wu();ws(e=>{if(r&&n){let{siteId:t,orgId:o,region:i="US"}=r;e.writeAsync({type:"script",id:"cio-tracker",src:i==="US"?"https://assets.customer.io/assets/track.js":"https://assets.customer.io/assets/track-eu.js",dataset:{"site-id":t,"use-array-params":"true","in-app-org-id":o,"use-in-app":"true"}})}})}function Oy(){let r=nl();ea.useEffect(()=>{if(window._cio=window._cio||[],!("pageHasLoaded"in window._cio)){let n=function(t){return function(...o){window._cio.push([t].concat(Array.prototype.slice.call(o,0)))}},e=["load","identify","sidentify","track","page"];for(let t=0;t<e.length;t++)window._cio[e[t]]=n(e[t])}},[]),ea.useEffect(()=>{if(r){Py.info(`identify user as "${r.uid}"${r.email?` (email: ${r.email})`:""} with customer.io`);let n=r.metadata.creationTime?Math.floor(new Date(r.metadata.creationTime).getTime()/1e3):void 0;window._cio.identify({id:r.uid,email:r.email,created_at:n})}},[r])}s();var Rp=P(Ms()),ky={getCurrentValue:()=>typeof navigator<"u"&&typeof navigator.onLine=="boolean"?navigator.onLine:!0,subscribe:r=>(window.addEventListener("online",r),window.addEventListener("offline",r),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",r)})};function Pp(){return(0,Rp.useSubscription)(ky)}s();var Ip=P(k());var Ay=bs("hive-tokens");async function xy(r){let n=await Xc(),{data:e}=await n.hive.generateHiveAccessToken({contentIds:[r]});return Object.values(e.contents)}function Op(r){return Ip.createElement(mp,{endpoint:Su(),fetchContentAuthToken:xy,tokensBrowserCache:Ay},r.children)}s();s();var kp=r=>{let{activatorEvent:n,draggingNodeRect:e,transform:t}=r;if(e&&n){let o=_l(n);if(!o)return t;let i=o.x-e.left,a=o.y-e.top;return{...t,x:t.x+i-e.width/2,y:t.y+a-e.height/2}}return t};var ot=P(k());s();var Cr=P(k());var Ap={cardWrapper:"Mg"};function xp(r){let{item:n}=r;return Cr.createElement(O,{style:[u.padding.horizontal400,u.padding.vertical200,u.background.colorPrimary,u.border.radiusThemeMedium,u.cursor.grabbing,Ap.cardWrapper]},n.previewIcon?Cr.createElement(O,{style:[u.margin.right400]},Cr.createElement(S[n.previewIcon].CSS,{style:[u.text.colorPrimaryTextInside,u.size.icon400]})):null,Cr.createElement(T,{style:[u.text.uiAction,u.text.colorPrimaryTextInside]},n.previewLabel||"Drop to insert"))}function Ep(r){let[n,e]=ot.useState(null),t=ki(Hl,{activationConstraint:{distance:10}}),o=ki(Nl,{activationConstraint:{distance:10}}),i=ot.useCallback(({active:c})=>{window.document.body.classList.add("dragging"),e(c.data.current)},[]),a=ot.useCallback(()=>{window.document.body.classList.remove("dragging"),e(null)},[]);return ot.createElement(Bl,{sensors:[t,o],onDragStart:i,onDragEnd:a,onDragCancel:a,collisionDetection:Ml},r.children,ot.createElement(Ze,null,ot.createElement(Ll,{modifiers:[kp],dropAnimation:null},n?ot.createElement(xp,{item:n}):null)))}s();var Rr=P(k());function Wo(r){let{children:n,fallback:e,name:t}=r;return Ct(t)?Rr.default.createElement(Rr.default.Fragment,null,n):Rr.default.createElement(Rr.default.Fragment,null,e)}s();var we=P(k());s();s();var _r=P(k());s();var it=P(k());s();var me=P(k());s();var $t="right-scroll-bar-position",jt="width-before-scroll-bar",ta="with-scroll-bars-hidden",na="--removed-body-scroll-bar-size";s();s();function Tp(r,n){return typeof r=="function"?r(n):r&&(r.current=n),r}s();var Dp=P(k());function _p(r,n){var e=(0,Dp.useState)(function(){return{value:r,callback:n,facade:{get current(){return e.value},set current(t){var o=e.value;o!==t&&(e.value=t,e.callback(t,o))}}}})[0];return e.callback=n,e.facade}s();function Pr(r,n){return _p(n||null,function(e){return r.forEach(function(t){return Tp(t,e)})})}s();s();s();function Mp(r){return r}function Hp(r,n){n===void 0&&(n=Mp);var e=[],t=!1,o={read:function(){if(t)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return e.length?e[e.length-1]:r},useMedium:function(i){var a=n(i,t);return e.push(a),function(){e=e.filter(function(c){return c!==a})}},assignSyncMedium:function(i){for(t=!0;e.length;){var a=e;e=[],a.forEach(i)}e={push:function(c){return i(c)},filter:function(){return e}}},assignMedium:function(i){t=!0;var a=[];if(e.length){var c=e;e=[],c.forEach(i),a=e}var h=function(){var d=a;a=[],d.forEach(i)},p=function(){return Promise.resolve().then(h)};p(),e={push:function(d){a.push(d),p()},filter:function(d){return a=a.filter(d),e}}}};return o}function Ir(r,n){return n===void 0&&(n=Mp),Hp(r,n)}function Xt(r){r===void 0&&(r={});var n=Hp(null);return n.options=se({async:!0,ssr:!1},r),n}s();var Np=P(k()),Bp=function(r){var n=r.sideCar,e=Ut(r,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var t=n.read();if(!t)throw new Error("Sidecar medium not found");return Np.createElement(t,se({},e))};Bp.isSideCarExport=!0;function Qt(r,n){return r.useMedium(n),Bp}var Vo=Xt();var ra=function(){},Jo=me.forwardRef(function(r,n){var e=me.useRef(null),t=me.useState({onScrollCapture:ra,onWheelCapture:ra,onTouchMoveCapture:ra}),o=t[0],i=t[1],a=r.forwardProps,c=r.children,h=r.className,p=r.removeScrollBar,d=r.enabled,f=r.shards,y=r.sideCar,C=r.noIsolation,I=r.inert,v=r.allowPinchZoom,g=r.as,b=g===void 0?"div":g,A=Ut(r,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),E=y,N=Pr([e,n]),B=se(se({},A),o);return me.createElement(me.Fragment,null,d&&me.createElement(E,{sideCar:Vo,removeScrollBar:p,shards:f,noIsolation:C,inert:I,setCallbacks:i,allowPinchZoom:!!v,lockRef:e}),a?me.cloneElement(me.Children.only(c),se(se({},B),{ref:N})):me.createElement(b,se({},B,{className:h,ref:N}),c))});Jo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Jo.classNames={fullWidth:jt,zeroRight:$t};s();s();var G=P(k());s();var Or="data-focus-lock",qo="data-focus-lock-disabled",Lp="data-no-focus-lock",zp="data-autofocus-inside",Up="data-no-autofocus";var Kp=P(k());s();var _n=P(k());var Mn={width:"1px",height:"0px",padding:0,overflow:"hidden",position:"fixed",top:"1px",left:"1px"},Yp=function(n){var e=n.children;return _n.createElement(_n.Fragment,null,_n.createElement("div",{key:"guard-first","data-focus-guard":!0,"data-focus-auto-guard":!0,style:Mn}),e,e&&_n.createElement("div",{key:"guard-last","data-focus-guard":!0,"data-focus-auto-guard":!0,style:Mn}))};Yp.propTypes={};Yp.defaultProps={children:null};s();var Go=Ir({},function(r){var n=r.target,e=r.currentTarget;return{target:n,currentTarget:e}}),$o=Ir(),Fp=Ir(),jo=Xt({async:!0});var Dy=[],oa=G.forwardRef(function(n,e){var t,o=G.useState(),i=o[0],a=o[1],c=G.useRef(),h=G.useRef(!1),p=G.useRef(null),d=n.children,f=n.disabled,y=n.noFocusGuards,C=n.persistentFocus,I=n.crossFrame,v=n.autoFocus,g=n.allowTextSelection,b=n.group,A=n.className,E=n.whiteList,N=n.hasPositiveIndices,B=n.shards,K=B===void 0?Dy:B,ee=n.as,ae=ee===void 0?"div":ee,Te=n.lockProps,on=Te===void 0?{}:Te,Gn=n.sideCar,vt=n.returnFocus,Lr=n.focusOptions,an=n.onActivation,Nt=n.onDeactivation,gi=G.useState({}),$n=gi[0],Ym=G.useCallback(function(){p.current=p.current||document&&document.activeElement,c.current&&an&&an(c.current),h.current=!0},[an]),Fm=G.useCallback(function(){h.current=!1,Nt&&Nt(c.current)},[Nt]);(0,Kp.useEffect)(function(){f||(p.current=null)},[]);var Km=G.useCallback(function(Bt){var jn=p.current;if(jn&&jn.focus){var yi=typeof vt=="function"?vt(jn):vt;if(yi){var Qa=typeof yi=="object"?yi:void 0;p.current=null,Bt?Promise.resolve().then(function(){return jn.focus(Qa)}):jn.focus(Qa)}}},[vt]),Wm=G.useCallback(function(Bt){h.current&&Go.useMedium(Bt)},[]),Vm=$o.useMedium,Jm=G.useCallback(function(Bt){c.current!==Bt&&(c.current=Bt,a(Bt))},[]),qm=Oi((t={},t[qo]=f&&"disabled",t[Or]=b,t),on),Xa=y!==!0,Gm=Xa&&y!=="tail",$m=Pr([e,Jm]);return G.createElement(G.Fragment,null,Xa&&[G.createElement("div",{key:"guard-first","data-focus-guard":!0,tabIndex:f?-1:0,style:Mn}),N?G.createElement("div",{key:"guard-nearest","data-focus-guard":!0,tabIndex:f?-1:1,style:Mn}):null],!f&&G.createElement(Gn,{id:$n,sideCar:jo,observed:i,disabled:f,persistentFocus:C,crossFrame:I,autoFocus:v,whiteList:E,shards:K,onActivation:Ym,onDeactivation:Fm,returnFocus:Km,focusOptions:Lr}),G.createElement(ae,Oi({ref:$m},qm,{className:A,onBlur:Vm,onFocus:Wm}),d),Gm&&G.createElement("div",{"data-focus-guard":!0,tabIndex:f?-1:0,style:Mn}))});oa.propTypes={};oa.defaultProps={children:void 0,disabled:!1,returnFocus:!1,focusOptions:void 0,noFocusGuards:!1,autoFocus:!0,persistentFocus:!1,crossFrame:!0,hasPositiveIndices:void 0,allowTextSelection:void 0,group:void 0,className:void 0,whiteList:void 0,shards:void 0,as:"div",lockProps:{},onActivation:void 0,onDeactivation:void 0};var Wp=oa;s();function ia(r){var n=window,e=n.setImmediate;typeof e<"u"?e(r):setTimeout(r,1)}var Vp=Wp;s();var Xo=Xt(),Qo="data-focus-on-hidden";var Jp=it.forwardRef(function(r,n){var e=it.useState(!1),t=e[0],o=e[1],i=r.children,a=r.autoFocus,c=r.shards,h=r.enabled,p=h===void 0?!0:h,d=r.scrollLock,f=d===void 0?!0:d,y=r.focusLock,C=y===void 0?!0:y,I=r.returnFocus,v=I===void 0?!0:I,g=r.inert,b=r.allowPinchZoom,A=r.sideCar,E=r.className,N=r.shouldIgnore,B=r.style,K=r.as,ee=Ut(r,["children","autoFocus","shards","enabled","scrollLock","focusLock","returnFocus","inert","allowPinchZoom","sideCar","className","shouldIgnore","style","as"]),ae=A,Te=t.onActivation,on=t.onDeactivation,Gn=Ut(t,["onActivation","onDeactivation"]),vt=se(se({},Gn),{sideCar:A,shards:c,allowPinchZoom:b,as:K,inert:g,style:B,enabled:p&&f});return it.createElement(it.Fragment,null,it.createElement(Vp,{ref:n,sideCar:A,disabled:!(t&&p&&C),returnFocus:v,autoFocus:a,shards:c,onActivation:Te,onDeactivation:on,className:E,whiteList:N,lockProps:vt,as:Jo},i),p&&it.createElement(ae,se({},ee,{sideCar:Xo,setLockProps:o,shards:c})))});s();s();s();var ff=P(k());s();s();s();function kr(r,n){return kr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,o){return t.__proto__=o,t},kr(r,n)}function aa(r,n){r.prototype=Object.create(n.prototype),r.prototype.constructor=r,kr(r,n)}var Zo=P(k());function _y(r,n){function e(t){return t.displayName||t.name||"Component"}return function(o){var i=[],a;function c(){a=r(i.map(function(p){return p.props})),n(a)}var h=function(p){aa(d,p);function d(){return p.apply(this,arguments)||this}d.peek=function(){return a};var f=d.prototype;return f.componentDidMount=function(){i.push(this),c()},f.componentDidUpdate=function(){c()},f.componentWillUnmount=function(){var C=i.indexOf(this);i.splice(C,1),c()},f.render=function(){return Zo.default.createElement(o,this.props)},d}(Zo.PureComponent);return Cs(h,"displayName","SideEffect("+e(o)+")"),h}}var qp=_y;s();s();s();s();var he=function(r){for(var n=Array(r.length),e=0;e<r.length;++e)n[e]=r[e];return n},Ar=function(r){return Array.isArray(r)?r:[r]};s();var My=function(r){if(r.nodeType!==Node.ELEMENT_NODE)return!1;var n=window.getComputedStyle(r,null);return!n||!n.getPropertyValue?!1:n.getPropertyValue("display")==="none"||n.getPropertyValue("visibility")==="hidden"},Gp=function(r){return r.parentNode&&r.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE?r.parentNode.host:r.parentNode},$p=function(r){return r===document||r&&r.nodeType===Node.DOCUMENT_NODE},Hy=function(r,n){return!r||$p(r)||!My(r)&&n(Gp(r))},sa=function(r,n){var e=r.get(n);if(e!==void 0)return e;var t=Hy(n,sa.bind(void 0,r));return r.set(n,t),t},Ny=function(r,n){return r&&!$p(r)?Ly(r)?n(Gp(r)):!1:!0},ca=function(r,n){var e=r.get(n);if(e!==void 0)return e;var t=Ny(n,ca.bind(void 0,r));return r.set(n,t),t},la=function(r){return r.dataset},By=function(r){return r.tagName==="BUTTON"},jp=function(r){return r.tagName==="INPUT"},ua=function(r){return jp(r)&&r.type==="radio"},Xp=function(r){return!((jp(r)||By(r))&&(r.type==="hidden"||r.disabled))},Ly=function(r){var n=r.getAttribute(Up);return![!0,"true",""].includes(n)},xr=function(r){var n;return!!(r&&(!((n=la(r))===null||n===void 0)&&n.focusGuard))},Hn=function(r){return!xr(r)},Qp=function(r){return!!r};s();var zy=function(r,n){var e=r.tabIndex-n.tabIndex,t=r.index-n.index;if(e){if(!r.tabIndex)return 1;if(!n.tabIndex)return-1}return e||t},da=function(r,n,e){return he(r).map(function(t,o){return{node:t,index:o,tabIndex:e&&t.tabIndex===-1?(t.dataset||{}).focusGuard?0:-1:t.tabIndex}}).filter(function(t){return!n||t.tabIndex>=0}).sort(zy)};s();s();var Zp=["button:enabled","select:enabled","textarea:enabled","input:enabled","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]","[tabindex]","[contenteditable]","[autofocus]"];var pa=Zp.join(","),Uy="".concat(pa,", [data-focus-guard]"),ef=function(r,n){var e;return he(((e=r.shadowRoot)===null||e===void 0?void 0:e.children)||r.children).reduce(function(t,o){return t.concat(o.matches(n?Uy:pa)?[o]:[],ef(o))},[])},ei=function(r,n){return r.reduce(function(e,t){return e.concat(ef(t,n),t.parentNode?he(t.parentNode.querySelectorAll(pa)).filter(function(o){return o===t}):[])},[])},tf=function(r){var n=r.querySelectorAll("[".concat(zp,"]"));return he(n).map(function(e){return ei([e])}).reduce(function(e,t){return e.concat(t)},[])};var fa=function(r,n){return he(r).filter(function(e){return sa(n,e)}).filter(function(e){return Xp(e)})},ma=function(r,n){return n===void 0&&(n=new Map),he(r).filter(function(e){return ca(n,e)})},Er=function(r,n,e){return da(fa(ei(r,e),n),!0,e)},ha=function(r,n){return da(fa(ei(r),n),!1)},nf=function(r,n){return fa(tf(r),n)},Tt=function(r,n){return r.shadowRoot?Tt(r.shadowRoot,n):Object.getPrototypeOf(r).contains!==void 0&&Object.getPrototypeOf(r).contains.call(r,n)?!0:he(r.children).some(function(e){return Tt(e,n)})};s();var Yy=function(r){for(var n=new Set,e=r.length,t=0;t<e;t+=1)for(var o=t+1;o<e;o+=1){var i=r[t].compareDocumentPosition(r[o]);(i&Node.DOCUMENT_POSITION_CONTAINED_BY)>0&&n.add(o),(i&Node.DOCUMENT_POSITION_CONTAINS)>0&&n.add(t)}return r.filter(function(a,c){return!n.has(c)})},rf=function(r){return r.parentNode?rf(r.parentNode):r},Nn=function(r){var n=Ar(r);return n.filter(Boolean).reduce(function(e,t){var o=t.getAttribute(Or);return e.push.apply(e,o?Yy(he(rf(t).querySelectorAll("[".concat(Or,'="').concat(o,'"]:not([').concat(qo,'="disabled"])')))):[t]),e},[])};s();var of=function(r){return r.activeElement?r.activeElement.shadowRoot?of(r.activeElement.shadowRoot):r.activeElement:void 0},Bn=function(){return document.activeElement?document.activeElement.shadowRoot?of(document.activeElement.shadowRoot):document.activeElement:void 0};var Fy=function(r){return r===document.activeElement},Ky=function(r){return!!he(r.querySelectorAll("iframe")).some(function(n){return Fy(n)})},ti=function(r){var n=document&&Bn();return!n||n.dataset&&n.dataset.focusGuard?!1:Nn(r).some(function(e){return Tt(e,n)||Ky(e)})};s();var ga=function(){var r=document&&Bn();return r?he(document.querySelectorAll("[".concat(Lp,"]"))).some(function(n){return Tt(n,r)}):!1};s();s();s();var Wy=function(r,n){return n.filter(ua).filter(function(e){return e.name===r.name}).filter(function(e){return e.checked})[0]||r},ni=function(r,n){return ua(r)&&r.name?Wy(r,n):r},af=function(r){var n=new Set;return r.forEach(function(e){return n.add(ni(e,r))}),r.filter(function(e){return n.has(e)})};s();var ya=function(r){return r[0]&&r.length>1?ni(r[0],r):r[0]},va=function(r,n){return r.length>1?r.indexOf(ni(r[n],r)):n};var ba="NEW_FOCUS",sf=function(r,n,e,t){var o=r.length,i=r[0],a=r[o-1],c=xr(e);if(!(e&&r.indexOf(e)>=0)){var h=e!==void 0?n.indexOf(e):-1,p=t?n.indexOf(t):h,d=t?r.indexOf(t):-1,f=h-p,y=n.indexOf(i),C=n.indexOf(a),I=af(n),v=e!==void 0?I.indexOf(e):-1,g=v-(t?I.indexOf(t):h),b=va(r,0),A=va(r,o-1);if(h===-1||d===-1)return ba;if(!f&&d>=0)return d;if(h<=y&&c&&Math.abs(f)>1)return A;if(h>=C&&c&&Math.abs(f)>1)return b;if(f&&Math.abs(g)>1)return d;if(h<=y)return A;if(h>C)return b;if(f)return Math.abs(f)>1?d:(o+d+f)%o}};s();var Vy=function(r){return function(n){var e,t=(e=la(n))===null||e===void 0?void 0:e.autofocus;return n.autofocus||t!==void 0&&t!=="false"||r.indexOf(n)>=0}},cf=function(r,n,e){var t=r.map(function(i){var a=i.node;return a}),o=ma(t.filter(Vy(e)));return o&&o.length?ya(o):ya(ma(n))};s();var wa=function(r,n){return n===void 0&&(n=[]),n.push(r),r.parentNode&&wa(r.parentNode.host||r.parentNode,n),n},Sa=function(r,n){for(var e=wa(r),t=wa(n),o=0;o<e.length;o+=1){var i=e[o];if(t.indexOf(i)>=0)return i}return!1},ri=function(r,n,e){var t=Ar(r),o=Ar(n),i=t[0],a=!1;return o.filter(Boolean).forEach(function(c){a=Sa(a||c,c)||a,e.filter(Boolean).forEach(function(h){var p=Sa(i,h);p&&(!a||Tt(p,a)?a=p:a=Sa(p,a))})}),a},lf=function(r,n){return r.reduce(function(e,t){return e.concat(nf(t,n))},[])};var Jy=function(r,n){var e=new Map;return n.forEach(function(t){return e.set(t.node,t)}),r.map(function(t){return e.get(t)}).filter(Qp)},uf=function(r,n){var e=document&&Bn(),t=Nn(r).filter(Hn),o=ri(e||r,r,t),i=new Map,a=ha(t,i),c=Er(t,i).filter(function(y){var C=y.node;return Hn(C)});if(!(!c[0]&&(c=a,!c[0]))){var h=ha([o],i).map(function(y){var C=y.node;return C}),p=Jy(h,c),d=p.map(function(y){var C=y.node;return C}),f=sf(d,h,e,n);return f===ba?{node:cf(a,d,lf(t,i))}:f===void 0?f:p[f]}};s();var Ca=function(r){var n=Nn(r).filter(Hn),e=ri(r,r,n),t=new Map,o=Er([e],t,!0),i=Er(n,t).filter(function(a){var c=a.node;return Hn(c)}).map(function(a){var c=a.node;return c});return o.map(function(a){var c=a.node,h=a.index;return{node:c,index:h,lockItem:i.indexOf(c)>=0,guard:xr(c)}})};s();var qy=function(r,n){"focus"in r&&r.focus(n),"contentWindow"in r&&r.contentWindow&&r.contentWindow.focus()},Ra=0,Pa=!1,df=function(r,n,e){e===void 0&&(e={});var t=uf(r,n);if(!Pa&&t){if(Ra>2){console.error("FocusLock: focus-fighting detected. Only one focus management system could be active. See https://github.com/theKashey/focus-lock/#focus-fighting"),Pa=!0,setTimeout(function(){Pa=!1},1);return}Ra++,qy(t.node,e.focusOptions),Ra--}};var Ia=df;var Gy=function(){return document&&document.activeElement===document.body},$y=function(){return Gy()||ga()},zn=null,Ln=null,Un=null,Tr=!1,jy=function(){return!0},Xy=function(n){return(zn.whiteList||jy)(n)},Qy=function(n,e){Un={observerNode:n,portaledElement:e}},Zy=function(n){return Un&&Un.portaledElement===n};function pf(r,n,e,t){var o=null,i=r;do{var a=t[i];if(a.guard)a.node.dataset.focusAutoGuard&&(o=a);else if(a.lockItem){if(i!==r)return;o=null}else break}while((i+=e)!==n);o&&(o.node.tabIndex=0)}var ev=function(n){return n&&"current"in n?n.current:n},tv=function(n){return n?!!Tr:Tr==="meanwhile"},nv=function r(n,e,t){return e&&(e.host===n&&(!e.activeElement||t.contains(e.activeElement))||e.parentNode&&r(n,e.parentNode,t))},rv=function(n,e){return e.some(function(t){return nv(n,t,t)})},oi=function(){var n=!1;if(zn){var e=zn,t=e.observed,o=e.persistentFocus,i=e.autoFocus,a=e.shards,c=e.crossFrame,h=e.focusOptions,p=t||Un&&Un.portaledElement,d=document&&document.activeElement;if(p){var f=[p].concat(a.map(ev).filter(Boolean));if((!d||Xy(d))&&(o||tv(c)||!$y()||!Ln&&i)&&(p&&!(ti(f)||d&&rv(d,f)||Zy(d,p))&&(document&&!Ln&&d&&!i?(d.blur&&d.blur(),document.body.focus()):(n=Ia(f,Ln,{focusOptions:h}),Un={})),Tr=!1,Ln=document&&document.activeElement),document){var y=document&&document.activeElement,C=Ca(f),I=C.map(function(v){var g=v.node;return g}).indexOf(y);I>-1&&(C.filter(function(v){var g=v.guard,b=v.node;return g&&b.dataset.focusAutoGuard}).forEach(function(v){var g=v.node;return g.removeAttribute("tabIndex")}),pf(I,C.length,1,C),pf(I,-1,-1,C))}}}return n},mf=function(n){oi()&&n&&(n.stopPropagation(),n.preventDefault())},ii=function(){return ia(oi)},hf=function(n){var e=n.target,t=n.currentTarget;t.contains(e)||Qy(t,e)},ov=function(){return null},iv=function(n){var e=n.children;return ff.createElement("div",{onBlur:ii,onFocus:hf},e)};iv.propTypes={};var gf=function(){Tr="just",setTimeout(function(){Tr="meanwhile"},0)},av=function(){document.addEventListener("focusin",mf),document.addEventListener("focusout",ii),window.addEventListener("blur",gf)},sv=function(){document.removeEventListener("focusin",mf),document.removeEventListener("focusout",ii),window.removeEventListener("blur",gf)};function cv(r){return r.filter(function(n){var e=n.disabled;return!e})}function lv(r){var n=r.slice(-1)[0];n&&!zn&&av();var e=zn,t=e&&n&&n.id===e.id;zn=n,e&&!t&&(e.onDeactivation(),r.filter(function(o){var i=o.id;return i===e.id}).length||e.returnFocus(!n)),n?(Ln=null,(!t||e.observed!==n.observed)&&n.onActivation(),oi(!0),ia(oi)):(sv(),Ln=null)}Go.assignSyncMedium(hf);$o.assignMedium(ii);Fp.assignMedium(function(r){return r({moveFocusInside:Ia,focusInside:ti})});var yf=qp(cv,lv)(ov);var jN=Qt(jo,yf);s();s();var $=P(k());s();s();var ai=P(k());s();s();s();var Sf=P(k());s();s();var vf;var bf=function(){if(vf)return vf;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function uv(){if(!document)return null;var r=document.createElement("style");r.type="text/css";var n=bf();return n&&r.setAttribute("nonce",n),r}function dv(r,n){r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n))}function pv(r){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(r)}var Oa=function(){var r=0,n=null;return{add:function(e){r==0&&(n=uv())&&(dv(n,e),pv(n)),r++},remove:function(){r--,!r&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}};var ka=function(){var r=Oa();return function(n,e){Sf.useEffect(function(){return r.add(n),function(){r.remove()}},[n&&e])}};var Zt=function(){var r=ka(),n=function(e){var t=e.styles,o=e.dynamic;return r(t,o),null};return n};s();var fv={left:0,top:0,right:0,gap:0},Aa=function(r){return parseInt(r||"",10)||0},mv=function(r){var n=window.getComputedStyle(document.body),e=n[r==="padding"?"paddingLeft":"marginLeft"],t=n[r==="padding"?"paddingTop":"marginTop"],o=n[r==="padding"?"paddingRight":"marginRight"];return[Aa(e),Aa(t),Aa(o)]},xa=function(r){if(r===void 0&&(r="margin"),typeof window>"u")return fv;var n=mv(r),e=document.documentElement.clientWidth,t=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,t-e+n[2]-n[0])}};var hv=Zt(),gv=function(r,n,e,t){var o=r.left,i=r.top,a=r.right,c=r.gap;return e===void 0&&(e="margin"),`
.`.concat(ta,` {
overflow: hidden `).concat(t,`;
padding-right: `).concat(c,"px ").concat(t,`;
}
body {
overflow: hidden `).concat(t,`;
overscroll-behavior: contain;
`).concat([n&&"position: relative ".concat(t,";"),e==="margin"&&`
padding-left: `.concat(o,`px;
padding-top: `).concat(i,`px;
padding-right: `).concat(a,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(c,"px ").concat(t,`;
`),e==="padding"&&"padding-right: ".concat(c,"px ").concat(t,";")].filter(Boolean).join(""),`
}
.`).concat($t,` {
right: `).concat(c,"px ").concat(t,`;
}
.`).concat(jt,` {
margin-right: `).concat(c,"px ").concat(t,`;
}
.`).concat($t," .").concat($t,` {
right: 0 `).concat(t,`;
}
.`).concat(jt," .").concat(jt,` {
margin-right: 0 `).concat(t,`;
}
body {
`).concat(na,": ").concat(c,`px;
}
`)},Ea=function(r){var n=r.noRelative,e=r.noImportant,t=r.gapMode,o=t===void 0?"margin":t,i=ai.useMemo(function(){return xa(o)},[o]);return ai.createElement(hv,{styles:gv(i,!n,o,e?"":"!important")})};s();var Ta=!1;if(typeof window<"u")try{Dr=Object.defineProperty({},"passive",{get:function(){return Ta=!0,!0}}),window.addEventListener("test",Dr,Dr),window.removeEventListener("test",Dr,Dr)}catch{Ta=!1}var Dr,en=Ta?{passive:!1}:!1;s();var yv=function(r){return r.tagName==="TEXTAREA"},wf=function(r,n){var e=window.getComputedStyle(r);return e[n]!=="hidden"&&!(e.overflowY===e.overflowX&&!yv(r)&&e[n]==="visible")},vv=function(r){return wf(r,"overflowY")},bv=function(r){return wf(r,"overflowX")},Da=function(r,n){var e=n;do{typeof ShadowRoot<"u"&&e instanceof ShadowRoot&&(e=e.host);var t=Cf(r,e);if(t){var o=Rf(r,e),i=o[1],a=o[2];if(i>a)return!0}e=e.parentNode}while(e&&e!==document.body);return!1},Sv=function(r){var n=r.scrollTop,e=r.scrollHeight,t=r.clientHeight;return[n,e,t]},wv=function(r){var n=r.scrollLeft,e=r.scrollWidth,t=r.clientWidth;return[n,e,t]},Cf=function(r,n){return r==="v"?vv(n):bv(n)},Rf=function(r,n){return r==="v"?Sv(n):wv(n)},Cv=function(r,n){return r==="h"&&n==="rtl"?-1:1},Pf=function(r,n,e,t,o){var i=Cv(r,window.getComputedStyle(n).direction),a=i*t,c=e.target,h=n.contains(c),p=!1,d=a>0,f=0,y=0;do{var C=Rf(r,c),I=C[0],v=C[1],g=C[2],b=v-g-i*I;(I||b)&&Cf(r,c)&&(f+=b,y+=I),c=c.parentNode}while(!h&&c!==document.body||h&&(n.contains(c)||n===c));return(d&&(o&&f===0||!o&&a>f)||!d&&(o&&y===0||!o&&-a>y))&&(p=!0),p};var si=function(r){return"changedTouches"in r?[r.changedTouches[0].clientX,r.changedTouches[0].clientY]:[0,0]},If=function(r){return[r.deltaX,r.deltaY]},Of=function(r){return r&&"current"in r?r.current:r},Rv=function(r,n){return r[0]===n[0]&&r[1]===n[1]},Pv=function(r){return`
.block-interactivity-`.concat(r,` {pointer-events: none;}
.allow-interactivity-`).concat(r,` {pointer-events: all;}
`)},Iv=0,Yn=[];function kf(r){var n=$.useRef([]),e=$.useRef([0,0]),t=$.useRef(),o=$.useState(Iv++)[0],i=$.useState(function(){return Zt()})[0],a=$.useRef(r);$.useEffect(function(){a.current=r},[r]),$.useEffect(function(){if(r.inert){document.body.classList.add("block-interactivity-".concat(o));var v=rc([r.lockRef.current],(r.shards||[]).map(Of),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[r.inert,r.lockRef.current,r.shards]);var c=$.useCallback(function(v,g){if("touches"in v&&v.touches.length===2)return!a.current.allowPinchZoom;var b=si(v),A=e.current,E="deltaX"in v?v.deltaX:A[0]-b[0],N="deltaY"in v?v.deltaY:A[1]-b[1],B,K=v.target,ee=Math.abs(E)>Math.abs(N)?"h":"v";if("touches"in v&&ee==="h"&&K.type==="range")return!1;var ae=Da(ee,K);if(!ae)return!0;if(ae?B=ee:(B=ee==="v"?"h":"v",ae=Da(ee,K)),!ae)return!1;if(!t.current&&"changedTouches"in v&&(E||N)&&(t.current=B),!B)return!0;var Te=t.current||B;return Pf(Te,g,v,Te==="h"?E:N,!0)},[]),h=$.useCallback(function(v){var g=v;if(!(!Yn.length||Yn[Yn.length-1]!==i)){var b="deltaY"in g?If(g):si(g),A=n.current.filter(function(B){return B.name===g.type&&B.target===g.target&&Rv(B.delta,b)})[0];if(A&&A.should){g.cancelable&&g.preventDefault();return}if(!A){var E=(a.current.shards||[]).map(Of).filter(Boolean).filter(function(B){return B.contains(g.target)}),N=E.length>0?c(g,E[0]):!a.current.noIsolation;N&&g.cancelable&&g.preventDefault()}}},[]),p=$.useCallback(function(v,g,b,A){var E={name:v,delta:g,target:b,should:A};n.current.push(E),setTimeout(function(){n.current=n.current.filter(function(N){return N!==E})},1)},[]),d=$.useCallback(function(v){e.current=si(v),t.current=void 0},[]),f=$.useCallback(function(v){p(v.type,If(v),v.target,c(v,r.lockRef.current))},[]),y=$.useCallback(function(v){p(v.type,si(v),v.target,c(v,r.lockRef.current))},[]);$.useEffect(function(){return Yn.push(i),r.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:y}),document.addEventListener("wheel",h,en),document.addEventListener("touchmove",h,en),document.addEventListener("touchstart",d,en),function(){Yn=Yn.filter(function(v){return v!==i}),document.removeEventListener("wheel",h,en),document.removeEventListener("touchmove",h,en),document.removeEventListener("touchstart",d,en)}},[]);var C=r.removeScrollBar,I=r.inert;return $.createElement($.Fragment,null,I?$.createElement(i,{styles:Pv(o)}):null,C?$.createElement(Ea,{gapMode:"margin"}):null)}var Y1=Qt(Vo,kf);s();var ui=P(k());s();var Ov=function(r){if(typeof document>"u")return null;var n=Array.isArray(r)?r[0]:r;return n.ownerDocument.body},Fn=new WeakMap,ci=new WeakMap,li={},_a=0,kv=function(r,n,e,t){var o=Array.isArray(r)?r:[r];li[e]||(li[e]=new WeakMap);var i=li[e],a=[],c=new Set,h=new Set(o),p=function(f){!f||c.has(f)||(c.add(f),p(f.parentNode))};o.forEach(p);var d=function(f){!f||h.has(f)||Array.prototype.forEach.call(f.children,function(y){if(c.has(y))d(y);else{var C=y.getAttribute(t),I=C!==null&&C!=="false",v=(Fn.get(y)||0)+1,g=(i.get(y)||0)+1;Fn.set(y,v),i.set(y,g),a.push(y),v===1&&I&&ci.set(y,!0),g===1&&y.setAttribute(e,"true"),I||y.setAttribute(t,"true")}})};return d(n),c.clear(),_a++,function(){a.forEach(function(f){var y=Fn.get(f)-1,C=i.get(f)-1;Fn.set(f,y),i.set(f,C),y||(ci.has(f)||f.removeAttribute(t),ci.delete(f)),C||f.removeAttribute(e)}),_a--,_a||(Fn=new WeakMap,Fn=new WeakMap,ci=new WeakMap,li={})}},Af=function(r,n,e){e===void 0&&(e="data-aria-hidden");var t=Array.from(Array.isArray(r)?r:[r]),o=n||Ov(r);return o?(t.push.apply(t,Array.from(o.querySelectorAll("[aria-live]"))),kv(t,o,e,"aria-hidden")):function(){return null}};s();var xf=P(k());var Av=Zt(),xv=`
[`+Qo+`] {
pointer-events: none !important;
}
`,Ef=function(){return xf.createElement(Av,{styles:xv})};var Dt=P(k()),Tf=function(r){return"current"in r?r.current:r};function Df(r){var n=r.setLockProps,e=r.onEscapeKey,t=r.onClickOutside,o=r.shards,i=r.onActivation,a=r.onDeactivation,c=r.noIsolation,h=(0,Dt.useState)(void 0),p=h[0],d=h[1],f=(0,Dt.useRef)(null),y=(0,Dt.useRef)(0);return ui.useEffect(function(){var C=function(b){b.defaultPrevented||(b.code==="Escape"||b.key==="Escape"||b.keyCode===27)&&e&&e(b)},I=function(b){b.defaultPrevented||b.target===f.current||b instanceof MouseEvent&&b.button!==0||o&&o.map(Tf).some(function(A){return A&&A.contains(b.target)||A===b.target})||t&&t(b)},v=function(b){I(b),y.current=b.touches.length},g=function(b){y.current=b.touches.length};if(p)return document.addEventListener("keydown",C),document.addEventListener("mousedown",I),document.addEventListener("touchstart",v),document.addEventListener("touchend",g),function(){document.removeEventListener("keydown",C),document.removeEventListener("mousedown",I),document.removeEventListener("touchstart",v),document.removeEventListener("touchend",g)}},[p,t,e]),(0,Dt.useEffect)(function(){if(p)return i&&i(p),function(){a&&a()}},[!!p]),(0,Dt.useEffect)(function(){var C=function(){return null},I=!1,v=function(b){c||(C=Af(nc([b],(o||[]).map(Tf)),document.body,Qo)),d(function(){return b})},g=function(){C(),I||d(null)};return n({onMouseDown:function(b){f.current=b.target},onTouchStart:function(b){f.current=b.target},onActivation:v,onDeactivation:g}),function(){I=!0,n(!1)}},[]),ui.createElement(Ef,null)}var _f=Qt(Xo,Df);var Ev=function(r){return _r.createElement(_f,se({},r))},Ma=_r.forwardRef(function(r,n){return _r.createElement(Jp,se({},r,{ref:n,sideCar:Ev}))});var at=P(Ve()),Wf=P(Kf());function Vf(r){let n=we.useRef(null),[e,t]=Oe(wl),{medias:o,currentIndex:i}=e,a=()=>{t({medias:[],currentIndex:0})},c=()=>{t(d=>({...d,currentIndex:Math.max(d.currentIndex-1,0)}))},h=()=>{t(d=>({...d,currentIndex:Math.min(d.currentIndex+1,d.medias.length-1)}))},p=d=>{t(f=>({...f,currentIndex:d}))};return zs({opened:o.length>0,closeOnClick:!1,closeOnOutsideClick:!1,closeOnScroll:!1,closeOnEsc:!0,onClose:a},n),mo(o.length?{Left:()=>c(),Right:()=>h()}:{},"all"),o.length?we.createElement(Ze,{ref:n},we.createElement(Ma,null,we.createElement(at.View,{style:Wn.imagesZoonPortal},we.createElement(Wf.default,{imageUrls:o.map(d=>({url:d.url})),index:i,renderIndicator:d=>we.createElement(at.View,{style:Wn.indactor},we.createElement(at.View,{style:Wn.indicatorElement}),we.createElement(at.View,{style:[Wn.indicatorElement,dt.alignItemsCenter,dt.justifyCenter]},we.createElement(at.Text,{style:Wn.indicatorText},`${d}/${o.length}`)),we.createElement(at.View,{style:[Wn.indicatorElement,dt.alignItemsEnd,dt.justifyCenter]},we.createElement(Vr,{icon:S.X,defaultTextStyle:{color:Zn.WHITE},onPress:()=>a()}))),renderArrowLeft:()=>we.createElement(Vr,{icon:S.ChevronLeft,defaultTextStyle:{color:Zn.WHITE},onPress:()=>c()}),renderArrowRight:()=>we.createElement(Vr,{icon:S.ChevronRight,defaultTextStyle:{color:Zn.WHITE},onPress:()=>h()}),onChange:d=>p(d||0),onCancel:()=>a(),enableSwipeDown:!0})))):null}var Wn=at.StyleSheet.create({imagesZoonPortal:{position:"fixed",top:0,left:0,right:0,bottom:0},indactor:{height:48,position:"absolute",left:0,top:0,right:0,display:"flex",flexDirection:"row",zIndex:20},indicatorElement:{flex:1},indicatorText:{color:Zn.WHITE}});s();var Jf=P(k());var Jv=5,qf=cn({key:"recentSearches",default:[],effects:[qe.recoilEffect("@recoil/recentSearches",[])]});function Gf(){return ut(qf)}function $f(r){let n=Je(qf);Jf.useEffect(()=>{if(!r)return;let e=setTimeout(()=>{n(t=>t.includes(r)?t:[r,...t.slice(0,Jv-1)])},3e3);return()=>clearTimeout(e)},[r])}s();var jf=P(k());function Xf(r,n){let{space:e,organization:t}=n;jf.useEffect(()=>{if(!r)return;let o=setTimeout(()=>{let i={type:"search_type",query:r};e?U(bn(e,i)):t?U(dr(t,i)):U(i)},700);return()=>{clearTimeout(o)}},[r])}s();var Ce=P(k());s();var j=P(k());s();var _=P(k());var Qe={loadingDelayedText:"Au",loadingDelayedTextVisible:"Fu",fullResponse:"Cu",prompts:"Bu",prompt:"uo",icon:"Wp",actions:"Eu",relatedQueries:"Du",blankSlateNoAiAnswer:"Su",buttons:"Mu"};s();var Me=P(k());s();var Mt=P(k());function Qf(r){let{answer:n,singleSpace:e,organization:t}=r,{navigate:o}=Z(),i=il(),a=Mt.useMemo(()=>Gv(i,n,e,t),[i,n,e,t]),c=Mt.useCallback(d=>{switch(U({type:"ai_search_open_source"}),d.type){case"space":o({screen:{type:"space",space:d.space.key,organization:d.space.organization,page:"",query:void 0}});break;case"page":o({screen:{type:"space",space:d.space.key,organization:d.space.organization,page:d.path,query:void 0}});break;case"snippet":o({screen:{type:"snippet",snippet:d.snippet.id,organization:d.organization,query:void 0}});break;case"entity":d.targetURL&&Xr(d.targetURL);break;default:te(d)}},[o]),h=Mt.useCallback(d=>{switch(d.type){case"space":return{icon:de(or,{code:lr(d.space)}),title:d.space.title||yn,action:"Go to space"};case"page":return{icon:S.Page.CSS,title:d.page.title,nested:!e,action:"Go to page"};case"snippet":let f=xl(d.snippet);return{title:po(d.snippet),icon:f.object==="user"?de(ho,{user:f.id,size:Yr.sm}):S.Snippet.CSS,action:"Go to snippet"};case"entity":return{icon:S.ArrowCurveDownRight.CSS,title:d.title,body:d.body,action:"Open"};default:te(d)}},[e]),p=Mt.useCallback(d=>{if(d?.type==="entityType")return{icon:d.integration?de(go,{integrationId:d.integration,bordered:!1}):S.Database.CSS,title:d.title}},[]);return Mt.createElement(gn,{data:a,getKey:jv,renderItem:h,renderGroup:p,getGroupKey:Xv,groupItem:Qv,onOpen:c})}function Gv(r,n,e,t){let o=new Map,i=[];Al(n.sources,c=>{switch(c.type){case"entity":let{entityType:h,entityId:p,integration:d}=c;if(!t)return null;let f=ur(Ge("getEntity",{organizationId:t,entityType:h,entityId:p},{nullOnError:!0}));if(!f)return null;let y=f.entityType.includes(`${d}:`)?f.entityType.split(`${d}:`)[1]:f.entityType;i.push({type:"entity",id:f.entityId,title:f.properties.title,body:f.properties.description,targetURL:f.properties.url,groups:[{type:"entityType",entityType:f.entityType,title:Rs(y),integration:d}]});break;case"capture":let{captureId:C}=c;if(!t)return null;let I=ur(Ge("getSnippet",{organizationId:t,snippetId:C},{nullOnError:!0}));if(!I)return null;i.push({type:"snippet",snippet:I,organization:t});break;case"page":let v=$v(c.space,c.page,r);if(!v)return null;let g=Ac(v.revision,v.page.id),b={type:"page",space:v.space,page:v.page,ancestors:g,path:_c(v.revision,v.page.id)};if(e){i.push(b);break}i.some(E=>E.type==="space"&&E.space.key===v.space.key)||i.push({type:"space",space:v.space}),o.set(v.space.key,(o.get(v.space.key)||[]).concat(b));break;default:te(c)}});let a=[];for(let c of i)c&&(a.push(c),c.type==="space"&&(o.get(c.space.key)||[]).forEach(p=>{a.push(p)}));return a}function $v(r,n,e){let t=al([Fc(r)])[0]?.result;if(!t)return;let o=gs(e.store.getRevision(r,t.revision,{metadata:!1}));if(!o)return;let i=o.pages[n];if(!(!i||i.type!=="document"))return{space:t,page:i,revision:o}}function jv(r){switch(r.type){case"space":return`space:${r.space.key}`;case"page":return`page:${r.space.key}/${r.page.id}`;case"snippet":return`snippet:${r.snippet.id}`;case"entity":return`entity:${r.groups[0].entityType}:${r.id}`;default:te(r)}}function Xv(r){return r&&r.type==="entityType"?r.entityType:""}function Qv(r){if(r.type==="entity")return r.groups[0]}var Zf={aiAnswerFooter:"Iu",sourcesHeadingButton:"Uu"};function em(r){let{answer:n,singleSpace:e,organization:t}=r,[o,i]=Me.useState(!1);return Me.createElement(O,{style:[u.flex.column]},Me.createElement(O,{style:[u.flex.row]},Me.createElement(O,{style:[u.flex.flex1]},Me.createElement(Y,{kind:"blank",size:"small",trailingIcon:o?S.ChevronDown.CSS:S.ChevronRight.CSS,onPress:()=>{i(!o)},style:[Zf.sourcesHeadingButton,u.text.uiSmall,u.text.colorMuted,u.background.colorTransparent,u.padding.all0],preventFocusOnPress:!0,label:`Answer based on ${n.sources.length} sources`}))),o?Me.createElement(O,{style:u.margin.top400},Me.createElement(Me.Suspense,{fallback:Me.createElement(Fr,{size:"medium"})},Me.createElement(Qf,{answer:n,singleSpace:e,organization:t}))):null)}s();var ct=P(k());function tm(r){let{query:n,answer:e,size:t="small"}=r,[o,i]=ct.useState(!1),a=pn(),c=Us(),h=()=>{U({type:"ai_search_copy_answer",query:n,answer:e.text}),c.writeTextAndNotify(e.text)},p=()=>{U({type:"ai_search_upvote_answer",query:n,answer:e.text}),i(!0),a.notify({icon:S.ThumbsUp.CSS,title:"Thanks for your feedback!",details:"This will help us improve the answering engine."})},d=()=>{U({type:"ai_search_downvote_answer",query:n,answer:e.text}),i(!0),a.notify({icon:S.ThumbsUp.CSS,title:"Thanks for your feedback!",details:"This will help us improve the answering engine."})};return ct.createElement(O,{style:[u.flex.row,u.flex.gap200]},ct.createElement(Y,{size:t,label:"Copy answer",iconOnly:!0,leadingIcon:S.Copy.CSS,kind:"blank",onPress:h}),o?null:ct.createElement(ct.Fragment,null,ct.createElement(Y,{size:t,leadingIcon:S.ThumbsUp.CSS,iconOnly:!0,label:"Mark as useful",kind:"blank",onPress:p}),ct.createElement(Y,{size:t,leadingIcon:S.ThumbsDown.CSS,iconOnly:!0,label:"Mark as not relevant",kind:"blank",onPress:d})))}s();var Fa=P(k());var nm={aiSearchSpinner:"Hu",aiSearchSpinnerAnim:"Zp"};function rm(){return Fa.createElement(O,{style:[nm.aiSearchSpinner,u.text.colorMuted,u.size.icon500]},Fa.createElement(S.AILens.CSS,{style:[u.width.full,u.height.full]}))}function om(r){let{query:n,target:e}=r,t=bt((o,i,a)=>{U(e.space?bn(e.space,{type:"ai_search_crash",query:n.query}):{type:"ai_search_crash",query:n.query})});return _.createElement(zr,{fallback:()=>_.createElement(rb,null),onError:t},_.createElement(_.Suspense,{fallback:_.createElement(im,null)},_.createElement(tb,{...r})))}function tb(r){let{target:n,query:e,onSubmitQuery:t}=r,o=pn(),[i,a]=io(n.space?Ge("streamAskInSpace",{spaceId:n.space.key},{query:{query:e.query,format:"markdown"}}):Ge("streamAskInOrganization",{organizationId:n.organization},{query:{query:e.query,format:"markdown"}}),{onError:g=>{throw o.notifyError(g),g},transform:async g=>{let{answer:b}=g;if(!b)return null;as("markdown"in b.answer,"Invalid answer format from API");let{document:A}=await dc(b.answer.markdown);return{...b,document:A}}}),[c,h]=_.useState(!1),p=c&&!a;_.useEffect(()=>{a&&h(!0)},[a]);let d=i.length===0&&!p,f=i[i.length-1],y=bt(()=>{let g={type:"ai_search_view_answer",query:e.query,queriesInMemory:e.previousQueries.length,hasAnswer:!!f,hasFollowupQuestions:!!f&&f.followupQuestions.length>0};U(n.space?bn(n.space,g):g)});_.useEffect(()=>{a||y()},[a,y]);let C=bt(r.onAnswerLoaded??(()=>{})),I=!!f;if(_.useEffect(()=>{I&&C()},[I,C]),d&&!f)return _.createElement(im,null);if(!f)return _.createElement(nb,{organizationKey:n.organization});let v=g=>{U(n.space?bn(n.space,{type:"ai_search_pick_followup",query:e.query,followup:g,previousQueriesCount:e.previousQueries.length}):{type:"ai_search_pick_followup",query:e.query,followup:g,previousQueriesCount:e.previousQueries.length}),t(g)};return _.createElement(O,{style:[u.flex.column,Qe.fullResponse]},_.createElement(O,{style:[u.flex.row,u.flex.alignItemsCenter,u.flex.gap200]},_.createElement(T,{style:[u.text.capitalizeFirstLetter,u.text.uiHeadingSmall,u.text.colorBase]},e.query),d?_.createElement(ln,{size:"small"}):null),_.createElement(O,{style:[u.text.uiBase,u.text.colorMuted]},_.createElement(Bc,{input:f.document,style:{minWidth:0}})),_.createElement(O,{style:Qe.actions},_.createElement(tm,{query:e.query,answer:f,size:"medium"})),_.createElement(em,{answer:f,singleSpace:!!n.space,organization:n.organization}),f.followupQuestions.length>0?_.createElement(O,{style:Qe.relatedQueries},_.createElement(T,{style:[u.text.uiSmall,u.text.colorMuted,u.margin.vertical400]},"Related queries"),_.createElement(O,{style:Qe.prompts},f.followupQuestions.map(g=>_.createElement(O,{key:g,style:[Qe.prompt,u.border.radiusPill,u.cursor.pointer],as:"button",type:"button",onClick:b=>{b.preventDefault(),v(g)}},_.createElement(S.SearchOrAsk.CSS,{style:Qe.icon}),_.createElement(T,{style:[u.text.uiSmall,u.text.colorBase,u.text.alignCenter]},g))))):null)}function im(r){let[n,e]=_.useState(!1);return _.useEffect(()=>{let t=setTimeout(()=>{e(!0)},3e3);return()=>{clearTimeout(t)}},[]),_.createElement(Le,{icon:rm,title:"Analysing the content to answer your question\u2026",style:u.padding.top200},_.createElement(T,{style:[Qe.loadingDelayedText,n&&Qe.loadingDelayedTextVisible]},"It might take a few more seconds."))}function nb(r){let{organizationKey:n}=r,e=Yl({organization:n,category:"captures"});return _.createElement(O,{style:[Qe.blankSlateNoAiAnswer,u.border.radiusThemeLarge]},_.createElement(T,{style:[u.text.uiHeadingSmall,u.text.colorBase]},"We need more knowledge to answer this."),_.createElement(T,{style:[u.text.colorBase]},"Connect more integrations or use an existing integration to capture your own answer"),n?_.createElement(O,{style:Qe.buttons},_.createElement(Y,{kind:"primary",leadingIcon:S.Integrations.CSS,label:"Connect integrations",onPress:()=>e()}),_.createElement(Y,{kind:"secondary",leadingIcon:S.VSCode.CSS,label:"Record with VSCode",onPress:()=>{window.open("vscode:extension/GitBook.gitbook-vscode","_blank","noopener, noreferer")}})):null)}function rb(r){return _.createElement(Le,{icon:S.Alert.CSS,title:"Unexpected error"},"Something went wrong. Please try again later.")}s();var am=P(k());function sm(r){let[n]=io(r===null?null:r.space?Ge("streamRecommendedQuestionsInSpace",{spaceId:r.space.key}):Ge("streamRecommendedQuestionsInOrganization",{organizationId:r.organization}));return am.useMemo(()=>n.map(e=>({type:"recommended-question",question:e.question})),[n])}s();var ob=P(k());var ib=cn({key:"recentAISearches",default:[],effects:[qe.recoilEffect("@recoil/recentAISearches",[])]});function cm(){return ut(ib)}s();var lm=P(k());var ab=10,sb=cn({key:"aiSearchQuery",default:{query:"",previousQueries:[]},effects:[qe.recoilEffect("@recoil/aiSearchQuery",{query:"",previousQueries:[]})]});function um(){let[r,n]=Oe(sb),e=lm.useCallback(t=>{n(o=>o?{query:t,previousQueries:[...o.previousQueries.filter(i=>i!==t&&i!==o.query),...o.query?[o.query]:[]].slice(-ab)}:{query:t,previousQueries:[]})},[n]);return[r,e]}s();var Nr=P(k());function dm(r,n,e){let t=Nr.useCallback(a=>{switch(a.type){case"ask-gitbook":{n(a.query,"click_ask_gitbook");break}default:te(a.type)}},[n]),o=Nr.useCallback(a=>{switch(a.type){case"ask-gitbook":return{title:a.query,icon:S.SearchOrAsk.CSS,action:"Ask GitBook",standout:!0};default:te(a.type)}},[]);return{suggestion:Nr.useMemo(()=>{let a=r.trim();return!e||!ub(r)?null:{type:"ask-gitbook",key:`ask-gitbook:${a}`,query:a}},[r,e]),onOpenSuggestion:t,onRenderSuggestion:o}}var cb=["who","what","where","when","why","how","explain","is","are","was","were","do","does","did","which","whom","whose","can","have","give","tell","show","find"],lb=new Set(cb);function ub(r){if(r.length>25||r.includes("?")||r.includes(" "))return!0;let n=r.toLowerCase().trim().split(/\s+/);if(n.length===0)return!1;for(let e of n)if(lb.has(e))return!0;return!1}function pm(r){let{organization:n,onAiSearchEnabled:e}=r,t=In({organization:n.id}),o=t!==void 0?re(t,"admin-billing"):!1,i=On(n.id,"ai-lens"),{state:a,enable:c}=bu(n.id),[h,p]=Ur();if(!i&&n.ai&&a.ready)return null;let d=a.total>0;return j.createElement(O,{style:[u.flex.row,u.flex.alignItemsCenter,u.padding.horizontal600,u.padding.vertical400,u.background.colorMuted]},j.createElement(O,null,j.createElement(S.SearchOrAsk.CSS,{style:[u.size.icon400,u.text.colorLight]})),j.createElement(O,{style:[u.flex.flex1,u.flex.row,u.flex.alignItemsCenter,u.margin.horizontal400]},j.createElement(T,{style:[u.text.uiBase,u.text.colorBase,u.margin.right400]},"Find an answer using ",j.createElement(T,{style:u.text.bold},"GitBook AI"))),j.createElement(O,null,i?j.createElement(Y,{size:"medium",...i}):j.createElement(j.Fragment,null,n.ai?j.createElement(_s,{size:"medium",kind:"info",icon:ln,tooltip:d?j.createElement(j.Fragment,null,a.indexed," of ",a.total," ",j.createElement(oc,{count:a.total,singular:"space",plural:"spaces"})," ","have been indexed.",`
`,"It can take a few minutes to index all."):j.createElement(j.Fragment,null,"The contents are being indexed. It can take a few minutes to index all.")},d&&j.createElement(j.Fragment,null,(a.indexed*100/a.total).toFixed(0),"%")):j.createElement(cs,{label:o?`Enable it in your organization.
You can disable it at any time.`:"Ask an administrator to enable it in this organization"},j.createElement(O,null,o?j.createElement(ps,{value:!1,loading:h,onValueChange:()=>{p(async()=>{await c("search"),e?.()})}}):j.createElement(S.HelpCircle.CSS,{style:[u.size.icon400,u.text.colorMuted]}))))))}s();var Vn=P(k());s();var Ht=P(k());function fm(r){let{organization:n,onUpdateQuery:e,onSubmitAIQuery:t}=r,o=Gf(),i=cm(),a=sm(n?{organization:n.id}:null),c=(d,f)=>{switch(d.type){case"recent-search":{e(d.query),U({type:"search_pick_suggestion_recent_search",suggestionIndex:f});break}case"recent-ai-search":{t(d.query),U({type:"search_pick_suggestion_recent_ai_search",suggestionIndex:f});break}case"recommended-question":U({type:"search_pick_suggestion_question"}),t(d.question);break;default:te(d)}},h=Ht.useCallback(d=>{switch(d.type){case"recent-search":return{icon:n?.ai?S.SearchOrAsk.CSS:S.Search.CSS,title:d.query,action:"Search"};case"recent-ai-search":return{icon:S.SearchOrAsk.CSS,title:d.query,action:"Ask"};case"recommended-question":return{icon:S.SearchOrAsk.CSS,title:d.question,action:"Ask",disabled:!n?.ai};default:te(d)}},[n?.ai]),p=Ht.useMemo(()=>{let d=n?.ai?i.map(v=>({type:"recent-ai-search",query:v})):[],f=o.filter(v=>!i.includes(v)).map(v=>({type:"recent-search",query:v})),y=Math.min(2,d.length),C=3-y;return[...[...n?.ai?d.slice(0,y):[],...f.slice(0,C)],...n?.ai?a:[]]},[o,i,a,!!n?.ai]);return p.length===0?Ht.createElement(Le,{description:"Type something to search."}):Ht.createElement(O,{style:[u.flex.flex1,u.flex.column,u.margin.bottom400]},Ht.createElement(gn,{data:p,showResultsAsPills:!0,getKey:db,renderItem:h,renderGroup:fb,groupItem:pb,getGroupKey:mb,onOpen:c,style:[u.padding.horizontal400,u.padding.bottom400]}))}function db(r){switch(r.type){case"recent-search":case"recent-ai-search":return`recent-search:${r.query}`;case"recommended-question":return`recommended-question:${r.question}`;default:te(r)}}function pb(r){switch(r.type){case"recent-search":case"recent-ai-search":return"Recently searched";case"recommended-question":return"Suggested for you";default:te(r)}}function fb(r){return{title:r}}function mb(r){return r}s();var Ke=P(k());function Ka(r){let{onSubmitAIQuery:n,hasAI:e}=r,t=Ke.useDeferredValue(r.query),{navigate:o}=Z(),i=dm(t,n,e),a=vu({query:t,types:["spaces","collections","pages","sections","snippets","snippet-sections","entities"]}),c=i.suggestion?[i.suggestion,...a]:a,h=Ke.useCallback(f=>{if(f.type==="ask-gitbook")return i.onRenderSuggestion(f);switch(f.type){case"space":return{title:f.title,icon:de(or,{code:lr(f.space),size:er.ICON_400}),action:"Go to space"};case"collection":return{title:f.title,icon:S.Collection.CSS,action:"Go to collection"};case"page":return{title:f.title,icon:S.Page.CSS,action:"Go to page"};case"section":return{title:f.title,body:f.body,icon:S.ArrowCurveDownRight.CSS,nested:!0,action:"Go to section"};case"entity":return{title:f.title,body:f.body,icon:S.ArrowCurveDownRight.CSS,action:"Open"};case"snippet":return{title:po(f.snippet),icon:uu(f.snippet),action:"Go to snippet"};case"snippet-section":return{title:f.title,body:f.body,icon:S.Hash.CSS,nested:!0,action:"Go to section"};default:te(f)}},[t,i.onRenderSuggestion]),p=Ke.useCallback(f=>{if(typeof f=="string")return{icon:f==="Snippets"?S.Snippet.CSS:S.Space.CSS,title:f};if(f?.type==="space")return{icon:de(or,{code:lr(f.space),size:er.ICON_400}),title:f.space.title||yn};if(f?.type==="entityType")return{icon:f.integration?de(go,{integrationId:f.integration,bordered:!1}):S.Database.CSS,title:f.title};if(f?.type==="snippet")return{icon:S.Snippet.CSS,title:"Snippets"}},[]),d=Ke.useCallback((f,y)=>{if(f.type==="ask-gitbook")return i.onOpenSuggestion(f);switch(U({type:"search_open_result",resultType:f.type,resultIndex:y}),f.type){case"space":{o({screen:{type:"space",space:f.space.objectID,organization:f.space.organization,page:"",query:void 0}});break}case"collection":{o({screen:{type:"collection",collection:f.collection.objectID,organization:f.collection.organization,query:void 0}});break}case"page":o({screen:{type:"space",space:f.space.key,organization:f.space.organization,page:f.path,query:void 0}});break;case"section":o({screen:{type:"space",space:f.space.key,organization:f.space.organization,page:f.path,hash:f.anchor,query:void 0}});break;case"entity":Xr(f.targetURL);break;case"snippet":case"snippet-section":o({screen:{type:"snippet",organization:f.organization,snippet:f.snippet.id,query:void 0}});break;default:te(f)}},[t,i.onOpenSuggestion]);return Ke.createElement(Ke.Fragment,null,Ke.createElement(gn,{data:c,getKey:hb,renderItem:h,renderGroup:p,groupItem:yb,getGroupKey:gb,onOpen:d,style:[u.padding.horizontal400,u.padding.bottom400,u.padding.top200]}),a.length===0?Ke.createElement(Le,{description:`No search results for "${t}"`}):null)}function hb(r){return r.key}function gb(r){return typeof r=="string"?r:r?r.type==="ask-gitbook"?r.type:r.type==="entityType"?r.entityType:r.type==="snippet"?r.snippet.id:r.space.key:""}function yb(r){if(r.type==="ask-gitbook")return{type:"ask-gitbook"};if(r.type==="space")return"Spaces";if(r.type==="collection")return"Collections";if(r.type==="snippet")return"Snippets";if(r.groups)return r.groups.find(n=>n.type==="space"||n.type==="entityType")}function mm(r){let{organization:n,query:e,aiQuery:t,onUpdateQuery:o,onSubmitAIQuery:i,usingAI:a}=r;$f(e),Xf(e,{organization:n});let c=()=>{o("")};return n&&a?Vn.createElement(om,{target:{organization:n.id},query:t,onAnswerLoaded:c,onSubmitQuery:i}):e?n?Vn.createElement(vb,{query:e,onSubmitAIQuery:i,organization:n}):Vn.createElement(Ka,{query:e,onSubmitAIQuery:i}):Vn.createElement(fm,{organization:n,onUpdateQuery:o,onSubmitAIQuery:i})}function vb({query:r,onSubmitAIQuery:n,organization:e}){let t=On(e.id,"ai-lens");return Vn.createElement(Ka,{query:r,onSubmitAIQuery:n,hasAI:!t&&e.ai})}function hm(){let[r,{open:n,close:e,setQuery:t},o]=vl();return mo({[fo.SEARCH_OPEN]:()=>{n()}},["application","editor-selection-collapsed"]),Ce.createElement(As,null,typeof r=="string"?Ce.createElement(Ce.Suspense,{fallback:null},Ce.createElement(bb,{query:r,setQuery:t,close:e,askAI:o})):null)}function bb(r){let{query:n,setQuery:e,close:t,askAI:o}=r,i=Ce.useRef(null),[a,c]=um(),[h,p]=Ce.useState(o),{screen:d,overlay:f}=wn(),y=f||d,C=wt(),I="organization"in y&&y.organization&&C.permissions.organizations[y.organization]?y.organization:void 0,{data:v}=rs(I?el("getOrganizationById",{organizationId:I}):Zc),g=tl(v?.id??null),b=bt((N,B)=>{!g||!v||(p(!0),e(N),c(N),i.current?.focus(),U({type:"ai_search_submit",organization:v.id,query:N,trigger:B??"press_enter"}))}),A=N=>{e(N),i.current?.focus()},E=N=>{p(!1),e(N)};return Ce.useEffect(()=>{o&&n&&n!==a.query&&b(n,"query_param")},[n,o,a.query,b]),bl({screen:"search",searchType:o?"ai":"search",organization:I},[o,I]),Ce.createElement(Uc,{ref:i,inputIcon:g?S.SearchOrAsk.CSS:S.Search.CSS,query:n,onQueryChange:E,onSubmitQuery:b,onClose:t,queryPlaceholder:g?"Ask or search...":"Search content...",footer:v?Ce.createElement(pm,{organization:v}):null},Ce.createElement(mm,{query:n,aiQuery:a,usingAI:h,organization:v,onUpdateQuery:A,onSubmitAIQuery:b}))}s();var ge=P(k());var gm={background:"Lu"};var wb=W("app:crash");function ym(r){let{children:n}=r,e=ge.useCallback((t,o,i)=>{wb.emergency(`An error occured during rendering:
`,t,`
The error is located at:
`,o),U({type:"crash",crashType:Wa(t),sentryEvent:i})},[]);return ge.createElement(zr,{fallback:t=>ge.createElement(Cb,{...t}),onError:e,beforeCapture:Ib},n)}function Cb(r){let{eventId:n,error:e}=r,t=()=>{ts({eventId:n||void 0})},o=()=>{window.location.reload()};pr();let i=()=>{switch(Wa(e)){case"network-crash":return ge.createElement(Pb,{onReload:o,...r});case"crash":default:return ge.createElement(Rb,{onShareFeedback:t,onReload:o,...r})}};return ge.createElement(O,{"data-testid":"error.screen",style:[u.flex.column,u.height.minFull,gm.background]},i())}function Rb(r){let{onReload:n,onShareFeedback:e}=r;return ge.createElement(Le,{kind:"alert",title:"Something went wrong.",actions:[ge.createElement(Y,{label:"Reload",kind:"primary",size:"medium",onPress:n,style:u.margin.right200,preventFocusOnPress:!0}),ge.createElement(Y,{label:"Let us know what happened",kind:"secondary",size:"medium",onPress:e,preventFocusOnPress:!0})]},ge.createElement(O,{style:u.flex.column},ge.createElement(T,{style:u.text.colorMuted},"Our team has been notified. If you'd like to help, you can describe what happened below."),null))}function Pb(r){let{onReload:n}=r,e=()=>{window.open("https://docs.gitbook.com/resources/firewall-safelist","_blank")};return ge.createElement(Le,{kind:"alert",title:"Connection lost",description:"Your device might be offline, or GitBook might be experiencing issues.",icon:S.CloudOff.CSS,actions:[ge.createElement(Y,{label:"reload",kind:"primary",size:"medium",onPress:n,style:u.margin.right200}),ge.createElement(Y,{kind:"secondary",label:"Network troubleshooting",size:"medium",leadingIcon:S.Link.CSS,onPress:e})]})}function Ib(r,n){switch(Wa(n)){case"network-crash":r.setTag("error_category","network-crash");break;case"crash":default:r.setTag("error_category","react-crash")}}function Wa(r){return r.name==="FirebaseError"&&r.code==="unavailable"?"network-crash":"crash"}s();var ye=P(k());var vm={zIndexModal:"Wu"};function bm(r){let n=ye.useRef(null),e=Pp(),t=ye.useRef(e),o=ye.useRef(0);return ye.useEffect(()=>{e&&(t.current||U({type:"app_back_online",offlineDuration:(Date.now()-o.current)/1e3})),t.current=e,o.current=Date.now()},[e]),e?null:ye.createElement(Ze,{ref:n},ye.createElement(O,{style:[u.position.absolute,u.position.inset0,u.width.full,u.height.full,u.flex.flex1,u.flex.justifyCenter,u.flex.alignItemsCenter,u.background.colorOverlay,u.text.colorWhite,vm.zIndexModal]},ye.createElement(O,{style:u.flex.column},ye.createElement(O,{style:[u.margin.bottom400,u.flex.alignItemsCenter]},ye.createElement(O,{style:u.margin.right400},ye.createElement(S.CloudOff.CSS,{style:u.size.icon400})),ye.createElement(T,{style:u.text.uiHeadingSmall},"Connection lost")),ye.createElement(O,{style:u.margin.bottom400},ye.createElement(T,{style:u.text.contentParagraph},"Your device might be offline, or GitBook might be experiencing issues.")))))}s();var Ee=P(k());s();var L=P(k());s();var xe=P(k());s();var Pe=P(k());var Re={treeItemButton:"ko",addContentButton:"vo",addContentNestedButton:"jo",headerHeight:"is",compact:"D",searchAskButtonWrapper:"Zu",searchAskButton:"t",footerShadow:"o5"};s();var mi=P(k()),hi=P(Ve());function Sm(r){let{owner:n,children:e,onDropHover:t,style:o}=r,i=xi(n);return mi.createElement(ms,{ref:i.setNodeRef,style:o,onDropHover:t,dropHovered:i.isOver},e)}function Jn(r){let{accept:n,owner:e,position:t}=r,o=xi(e,{accept:[n],position:t});return mi.createElement(hi.View,{style:Ab.collectionDropLine},mi.createElement(ks,{ref:o.setNodeRef,dropHovered:o.isOver,position:"top"}))}var Ab=hi.StyleSheet.create({collectionDropLine:{position:"relative",zIndex:10}});function wm(r){let{collection:n,active:e,indent:t,previousCollection:o,nextCollection:i,children:a}=r,c={organization:n.organization,collection:n.collection},h={...c,collection:n.key},p=Pe.useRef(null),d=et(p),[f,y]=gu(n),C=yu(n,h),[I,v]=Oe(Rl(n.key)),g=mu(n),b=()=>{v(!0)},{getNavigationLinkProps:A}=Z(),E=A({screen:{type:"collection",collection:n.key,organization:n.organization}});return Pe.createElement(Sm,{owner:h,onDropHover:b},Pe.createElement(Jn,{accept:"collection",owner:c,position:{...o?{before:{type:"collection",collection:o.key}}:{},after:{type:"collection",collection:n.key}}}),Pe.createElement(fs,{ref:g.setNodeRef,...g.listeners},y,Pe.createElement(z,{isCollection:!0,style:[Pe.Children.count(a)>0&&J.Margin.bottom100],active:e,...E,opened:I,onToggle:()=>v(!I),buttonsVisibility:d.opened?"always":"hover",buttons:[C?.commands.length||f.commands.length?Pe.createElement(Y,{ref:p,onClick:N=>N.preventDefault(),onPress:()=>{d.open(ze({groups:[f.commands.length?f:null,C?.commands.length?C:null].filter(ue)}))},leadingIcon:S.MoreVertical.CSS,kind:"blank",size:"small",active:d.opened,preventFocusOnPress:!0,iconOnly:!0,label:"Collection actions",style:[Re.treeItemButton]}):null],indent:t},Pe.createElement(T,null,n.title||Yc))),I?Pe.createElement(Pe.Fragment,null,a):Pe.createElement(Jn,{accept:"collection",owner:c,position:{before:{type:"collection",collection:n.key},...i?{after:{type:"collection",collection:i.key}}:{}}}))}s();var rn=P(k());var xb="Untitled";function Cm(r){let{site:n,active:e,indent:t}=r,{getNavigationLinkProps:o}=Z(),i=o({screen:{type:"site",site:n.key,organization:n.organization}}),a=rn.createElement(rn.Fragment,null,rn.createElement(z,{icon:S.DocsSite,active:e,...i,indent:t},rn.createElement(T,null,n.title||xb)));return rn.createElement(O,{style:u.flex.column},a)}s();var We=P(k());function Rm(r){let{space:n,active:e,previousSpace:t,nextSpace:o,indent:i}=r,a=We.useRef(null),[c,h]=Tl(n),p=et(a),d={organization:n.organization,collection:n.collection},f=Kc(n),{getNavigationLinkProps:y}=Z(),C=y({screen:{type:"space",space:n.key,organization:n.organization,changeRequest:void 0,page:"/",diff:void 0}}),I=hu(n),v=Kr(Dl,{space:n,size:er.ICON_400,withBackground:!1},[n]),g={onPointerDown:A=>{I.listeners?.onPointerDown(A),C.onPress(A)},onMouseDown:A=>{I.listeners?.onMouseDown(A),C.onPress(A)}},b=We.createElement(We.Fragment,null,h,We.createElement(z,{buttonRef:I.setNodeRef,icon:v,active:e,...g,...C,indent:i,buttonsVisibility:p.opened?"always":"hover",buttons:c.commands.length?[We.createElement(Y,{ref:a,leadingIcon:S.MoreVertical.CSS,kind:"blank",size:"small",active:p.opened,onClick:A=>A.preventDefault(),onPress:()=>{p.open(ze({groups:[c].filter(ue)}))},iconOnly:!0,preventFocusOnPress:!0,label:"Space actions",style:[Re.treeItemButton]})]:void 0},We.createElement(T,null,n.title||yn)));return f?b:We.createElement(O,{style:u.flex.column},We.createElement(Jn,{accept:"space",owner:d,position:{...t?{before:{type:"space",space:t.key}}:{},after:{type:"space",space:n.key}}}),b,We.createElement(Jn,{accept:"space",owner:d,position:{before:{type:"space",space:n.key},...o?{after:{type:"space",space:o.key}}:{}}}))}function Va(r){let{type:n="content",indent:e=0,owner:t,screenSite:o,screenSpace:i,screenCollection:a,placeholder:c=null,compact:h}=r,{sites:p,spaces:d,collections:f}=lo(t,{includeOrphans:!0});return h?null:n==="site"?xe.createElement(O,{style:[u.flex.column,u.flex.gap100]},p.length===0?c?xe.createElement(T,{style:[u.text.colorLight,u.margin.vertical100,u.margin.horizontal400]},c):null:xe.createElement(xe.Fragment,null,p.map((y,C)=>{let I=C>0?p[C-1]:void 0,v=p[C+1];return xe.createElement(Cm,{key:y.key,site:y,active:o===y.key,previousSite:I,nextSite:v,indent:e})}))):xe.createElement(O,{style:[u.flex.column,u.flex.gap100]},!t.collection&&d.length===0&&f.length===0?c?xe.createElement(T,{style:[u.text.colorLight,u.margin.vertical100,u.margin.horizontal400]},c):null:xe.createElement(xe.Fragment,null,d.map((y,C)=>{let I=C>0?d[C-1]:void 0,v=d[C+1];return xe.createElement(Rm,{key:y.key,space:y,active:i===y.key,previousSpace:I,nextSpace:v,indent:e})}),f.map((y,C)=>{let I=C>0?f[C-1]:void 0,v=f[C+1];return xe.createElement(wm,{key:y.key,collection:y,active:a===y.key,previousCollection:I,nextCollection:v,indent:e},xe.createElement(Va,{...r,placeholder:null,owner:{...t,collection:y.key},indent:e+1}))})))}s();var Pm=P(k());function Im(r){let n=wt(),e=Je(Cl);Pm.useEffect(()=>{if(!r?.type)return;let t=r.type==="space"?Eb(n,r.space):Ja(n,r.collection);t.length>0&&e(o=>{let i=o;return t.forEach(a=>{i=i[a]?i:{...i,[a]:!0}}),i})},[n,e,r?.type,r?.space,r?.collection])}function Ja(r,n){let e=r.collections.find(t=>t.key===n);return e?e.collection?[...Ja(r,e.collection),e.collection]:[]:[]}function Eb(r,n){let e=r.spaces.find(t=>t.key===n);return e?.collection?[...Ja(r,e.collection),e.collection]:[]}function Om(r){let{screenSpace:n,screenCollection:e}=r,{compact:t}=L.useContext(Rt);return Im((n?{type:"space",space:n}:void 0)||(e?{type:"collection",collection:e}:void 0)),L.createElement(L.Suspense,{fallback:null},L.createElement(Tb,{...r,compact:t}))}function Tb(r){let{screenOrganization:n}=r,[e]=Sn([Ft(n)]);return e?L.createElement(Db,{...r,organization:e}):null}function Db(r){let{organization:n,organizationMenuScreenType:e,compact:t,screenCollection:o,screenSpace:i}=r,a={organization:n.key},{navigate:c,getNavigationLinkProps:h}=Z(),p=In(a),d=Ol(),f=so(),y=co(),C=oo(Oe(Rn),Oe(Pn),{collapsable:!0,lockedAsCollapsed:y}),{collections:I,spaces:v}=lo(a,{includeOrphans:!0}),[g]=v,[b]=I,A=bt(()=>{E(),N()}),E=()=>{y&&f(),C.toggle()},N=()=>{c(i||o?{screen:{type:i?"space":"collection",organization:n.key,...i?{space:i}:{},...o?{collection:o}:{}}}:g||b?{screen:{type:g?"space":"collection",organization:n.key,...g?{space:g.key}:{},...b?{collection:b.key}:{}}}:{screen:{type:"home",organization:n.key}})},B=L.useRef(null),K=et(B),ee=_b(a),ae=re(p,"view-captures"),Te=re(p,"view-insights"),on=re(p,"admin-integrations")||Jc(d,"admin-integrations"),Gn=kl(n.key),{createSpace:vt,createSnippet:Lr,createSite:an}=Ei(a),[Nt,gi]=Ur(!1);return L.createElement(O,{style:[u.flex.column,t?u.flex.alignItemsCenter:u.flex.alignItemsStretch,u.flex.shrink1,u.flex.grow1,u.overflow.yAuto,u.overflow.xHidden,u.padding.bottom600,u.flex.gap400]},ae||Te||on?L.createElement(O,{style:[u.flex.column,t?u.flex.gap400:u.flex.gap100]},L.createElement(z,{kind:"default",icon:S.Grid,active:e==="home",compact:t,tooltipTitle:"Home",tooltipPlacement:"right",...h({screen:{type:"home",organization:n.key}})},t?null:L.createElement(O,{style:[u.flex.gap200,u.flex.alignItemsCenter]},L.createElement(T,null,"Home"))),Gn?L.createElement(z,{kind:"default",icon:S.DocsSite,active:e==="sites"||e==="site",compact:t,tooltipTitle:"Docs sites",tooltipPlacement:"right",buttonsVisibility:"active",onPress:()=>c({screen:{type:"sites",organization:n.key}}),buttons:!t&&an?[L.createElement(Y,{onClick:$n=>$n.preventDefault(),onPress:async()=>{await an()},loadable:!0,leadingIcon:S.Plus.CSS,label:"Create new site",iconOnly:!0,size:"small",kind:"nested",style:Re.addContentNestedButton})]:void 0},t?null:L.createElement(O,{style:[u.flex.gap200,u.flex.alignItemsCenter]},L.createElement(T,null,"Docs sites"))):null,ae?L.createElement(z,{kind:"default",icon:S.Snippet,buttonsVisibility:Nt?"always":"active",active:e==="snippets"||e==="snippet",compact:t,tooltipTitle:"Snippets",tooltipPlacement:"right",...h({screen:{type:"snippets",organization:n.key}}),buttons:!t&&Lr?[L.createElement(Y,{onClick:$n=>$n.preventDefault(),onPress:async()=>{await gi(async()=>{await Lr()})},disabled:Nt,leadingIcon:Nt?ln:S.Plus.CSS,label:"Create new snippet",iconOnly:!0,size:"small",kind:"nested",style:Re.addContentNestedButton})]:void 0},t?null:L.createElement(O,{style:[u.flex.gap200,u.flex.alignItemsCenter]},L.createElement(T,null,"Snippets"),L.createElement(us,{kind:"beta",label:"Beta",size:"xsmall"}))):null,Te?L.createElement(z,{kind:"default",icon:S.Insights,active:e==="insights",compact:t,tooltipTitle:"Insights",tooltipPlacement:"right",...h({screen:{type:"insights",organization:n.key,tab:{type:"audit"}}})},t?null:L.createElement(O,{style:[u.flex.gap200,u.flex.alignItemsCenter]},L.createElement(T,null,"Insights"))):null,on?L.createElement(Wo,{name:"FEATURE_INTEGRATIONS_PAGE",fallback:null},L.createElement(z,{kind:"default",icon:S.Integrations,active:e==="integrations",compact:t,tooltipTitle:"Integrations",tooltipPlacement:"right",...h({screen:{type:"integrations",organization:n.key,space:void 0,site:void 0,integration:void 0,category:void 0}})},t?null:L.createElement(O,{style:[u.flex.gap200,u.flex.alignItemsCenter]},L.createElement(T,null,"Integrations")))):null):null,L.createElement(O,{style:[u.flex.column,u.flex.gap200]},L.createElement(z,{kind:"default",icon:t?S.Documentation:void 0,compact:t,onPress:t?A:void 0,tooltipTitle:"Documentation",tooltipPlacement:"right",active:t&&(e==="space"||e==="collection"),buttonsVisibility:t?"never":"always",buttons:vt?[L.createElement(Y,{ref:B,onPress:()=>K.open(ee),leadingIcon:S.Plus.CSS,label:"Add new content",iconOnly:!0,size:"small",kind:"blank",style:Re.addContentButton,active:K.opened,testID:"sidebar.createPaletteButton"})]:void 0},t?null:L.createElement(T,{style:[u.text.uiAction,u.text.colorMuted]},"Documentation")),t?null:L.createElement(Va,{...r,type:"content",placeholder:"Share things with other members of your organization, or publish them to a wider audience.",owner:a,indent:0})))}var _b=r=>{let{createSpace:n,createCollection:e}=Ei(r),{navigate:t}=Z();return ze({groups:[{key:"owner",commands:[n?{key:"new_space",icon:S.Space.CSS,title:"New space",subtitle:"A blank space for your content",testID:"sidebar.createSpaceButton",trigger:async()=>{await n()}}:null,e?{key:"new_collection",icon:S.Collection.CSS,title:"New collection",subtitle:"Group your spaces",trigger:async()=>{await e()}}:null,{key:"import_content",icon:S.Download.CSS,title:"Import content",subtitle:"Add from other sources",trigger:()=>{t({overlay:{type:"import",organization:r.organization}})}}].filter(ue)}]})};s();var Ne=P(k());s();var He=P(k());s();var Ie=P(k()),qn=P(Ve());function km(r){let{onClose:n}=r,[,e]=St(Mb),t=cl(),o=async()=>{await t(),n()};return Ie.createElement(ac,{title:"Help and Feedback",onClose:n,size:"small"},Ie.createElement(qn.View,{style:[e.cardsWrapper]},Ie.createElement(qn.View,{style:e.actionCard},Ie.createElement(ir,{kind:"blank",url:"https://docs.gitbook.com/resources/keyboard-shortcuts"},Ie.createElement(S.EnterKey,{style:J.Margin.right200}),"Keyboard shortcuts")),Ie.createElement(qn.View,{style:e.actionCard},Ie.createElement(ir,{kind:"blank",url:"https://docs.gitbook.com/"},Ie.createElement(S.Page,{style:J.Margin.right200}),"Read the docs")),Ie.createElement(qn.View,{style:e.actionCard},Ie.createElement(ir,{kind:"blank",url:"https://github.com/GitbookIO/community/discussions"},Ie.createElement(S.Bulb,{style:J.Margin.right200}),"Suggest a feature / share feedback")),Ie.createElement(qn.View,{style:e.actionCard},Ie.createElement(ir,{kind:"blank",onPress:o},Ie.createElement(S.Send,{style:J.Margin.right200}),"Contact support"))))}var Mb=Wr.create({actionCard:r=>({flexBasis:"100%",marginBottom:J.small,borderWidth:1,borderColor:r.colors.border.main,borderRadius:4,padding:J.small}),cardsWrapper:{flexDirection:"column"}});function Am({organization:r,tooltipTitle:n,label:e,compact:t}){let[o,i]=He.useState(null),{signOut:a}=ll(),{navigate:c}=Z(),h=vn(),p=Is(),d=uo(r?.key),f=p.color==="light",y=Je(Pl),C=He.useRef(null),I=et(C),v=He.useMemo(()=>{let g=[];if(r){let b=re(d,"admin-profile"),A=re(d,"update-team"),E=re(d,"invite-team-members");(A||b)&&g.push({key:"org_settings",commands:[{key:"org_settings.profile",title:b?"Organization Settings":"Teams Settings",icon:de(pt,{org:r}),trigger:()=>{c({overlay:b?{type:"org_settings",organization:r.key,tab:{type:"profile"}}:{type:"org_settings",organization:r.key,tab:{type:"teams"}}})}},E?{key:"org_settings.invite",title:"Invite teammates",icon:S.UserAdd.CSS,trigger:()=>{c({overlay:{type:"org_invite",organization:r.key}})}}:null].filter(ue)})}return g.push({key:"settings",commands:[{key:"settings.personal",title:"Account Settings",icon:S.Settings.CSS,trigger:()=>{c({overlay:{type:"account",tab:"profile"}})}},{key:"theme.switch",icon:S.Modes.CSS,title:`Switch to ${f?"dark":"light"} mode`,keywords:["theme","dark","light"],trigger:async()=>{let b=f?"dark":"light";y(b),U({type:"account_edit_theme",theme:b})}}]}),g.push({key:"account",commands:[{key:"account.help",icon:S.HelpCircle.CSS,title:"Help & Feedback",trigger:()=>{i("help")}},{key:"account.signout",icon:S.Leave.CSS,title:"Sign Out",trigger:()=>{a()}}]}),ze({groups:g})},[h.uid,f,c,r,d]);return He.createElement(He.Fragment,null,He.createElement(z,{buttonRef:C,testID:"sidebar.settingsButton",icon:S.Settings,kind:"secondary",onPress:()=>{I.open(v)},tooltipTitle:n,tooltipPlacement:"right",compact:t},t?null:e),He.createElement(jr,null,o==="help"?He.createElement(km,{onClose:()=>{i(null)}}):null))}s();var oe=P(k());function qa(r){let{organization:n,style:e}=r,t=In({organization:n.key}),[{result:o}]=sl([Vc(n.key)]),i=Sl(n,o??null),a=Ct("UPGRADE_TRIAL_ALERT_DAYS"),c=re(t,"admin-billing"),h=re(t,"add-guests");return o&&zb(o,a)&&c?oe.createElement(Lb,{organization:n,billing:o,canAdminBilling:c,featuresSet:i,style:e}):o?.status==="past_due"&&c?oe.createElement(Bb,{organization:n,style:e}):xm("new-feature")?h&&!xm("invite")?oe.createElement(Nb,{organization:n,billing:o||null,style:e}):null:oe.createElement(Hb,{style:e})}function Hb(r){let n=new URL("https://www.gitbook.com/blog/meet-the-all-new-gitbook");return oe.createElement(yr,{title:"We've changed a few things",dismissable:"new-feature",style:r.style,action:oe.createElement(Y,{label:"Take me there",kind:"secondary",size:"small",href:n.toString()})},"Head to our blog post to discover everything that's new in our latest release.")}function Nb(r){let{organization:n,billing:e,style:t}=r,o=Em(e);return oe.createElement(yr,{title:"Invite your team",style:t,dismissable:"invite",action:oe.createElement(Cn,{label:"Invite teammates",kind:"primary",size:"small",to:{overlay:{type:"org_invite",organization:n.key}}})},typeof o=="number"?oe.createElement(oe.Fragment,null,"Get the most out of your free trial by inviting your team."):oe.createElement(oe.Fragment,null,"Invite team members to your organization to enjoy the best of GitBook."))}function Bb(r){let{organization:n,style:e}=r;return oe.createElement(yr,{title:"Payment failed",style:e,action:oe.createElement(Cn,{label:"Update payment method",kind:"primary",size:"small",to:{overlay:{type:"org_settings",organization:n.key,tab:{type:"billing"}}},onPress:()=>{U(dr(n.key,{type:"organization_open_billing",reason:"sidebar_cta_past_due"}))}})},"Your payment failed. Update your payment method to keep your organization active.")}function Lb(r){let{organization:n,billing:e,canAdminBilling:t,featuresSet:o,style:i}=r,[,a]=St(Os),c=Em(e),h=t?oe.createElement(Cn,{label:"Upgrade Now",kind:"upgrade",size:"small",to:{overlay:{type:"org_settings",organization:n.key,tab:{type:"plans"},hash:"sidebar_cta"}},onPress:()=>{U(dr(n.key,{type:"organization_open_upgrade",currentFeaturesSet:o,reason:"sidebar_cta"}))}}):null;return oe.createElement(yr,{title:"Your trial ends soon!",action:h,style:i},"Your trial ends"," ",oe.createElement(T,{style:[a.Bold]},c===0?"today":c===1?"tomorrow":`in ${c} days`),". Upgrade to keep access to premium features.")}function Em(r){let n=r?.trialEnd?.toDate()||new Date(0),e=Math.floor((n.getTime()-Date.now())/(24*60*60*1e3));return ic(n),r?.status==="trialing"?e:void 0}function zb(r,n){if(r.status!=="trialing"||!r.trialEnd)return!1;let e=r.trialEnd.toDate(),t=new Date,o=1e3*60*60*24*n;return e.getTime()-t.getTime()<o}function xm(r){let n=`@sidebar:alert:${r}`;return qe.get(n)||!1}function Ga(r){let{organization:n,organizationMenuScreenType:e}=r,{compact:t}=Ne.useContext(Rt),{getNavigationLinkProps:o}=Z(),{isMobile:i}=Jr(),[a]=Oe(Rn);return Ne.createElement(Ne.Fragment,null,n?Ne.createElement(O,{style:[u.flex.flex1,u.flex.column,u.flex.justifySpaceBetween,u.padding.top300,u.padding.bottom400,t?[u.flex.alignItemsCenter,u.padding.top400]:null,!i||i&&a?Re.footerShadow:null]},t?null:Ne.createElement(Ne.Suspense,{fallback:null},Ne.createElement(qa,{organization:n,style:[u.margin.top0,u.margin.bottom400,u.margin.horizontal300]})),Ne.createElement(Am,{compact:t,organization:n,tooltipTitle:t?"Settings":void 0,label:"Settings"}),t?null:Ne.createElement(z,{kind:"secondary",icon:S.Trashcan,active:!t&&e==="trash",compact:t,style:J.Margin.vertical100,tooltipTitle:"Trash",...o({screen:{type:"trash",organization:n.key}})},t?null:"Trash")):null)}s();var ve=P(k());s();var Br=P(k()),Dm=P(Ve());function _m(r){let{activeOrganization:n,children:e,compact:t,style:o,title:i,...a}=r,c=vn(),{navigate:h}=Z(),p=Br.useRef(null),d=et(p);function f(){r.disabled||d.open(Yb(c.uid,n,y=>{h({screen:y?{type:"home",organization:y.id}:{type:"home",organization:void 0}})},()=>{U({type:"organization_open_create",reason:"sidebar_menu"}),h({overlay:{type:"welcome",organizationType:"business",hash:"sidebar_menu"}})}))}return Br.createElement(z,{kind:"heading",buttonRef:p,icon:r.icon,compact:t,active:d.opened,onPress:f,style:[Tm.orgSwitchButton,t&&Tm.orgSwitchButtonCompact,r.style],...a,tooltipTitle:`${i??""}`},t?null:Br.createElement(T,{style:[u.text.uiStandout,u.text.colorBase]},i))}function Yb(r,n,e,t){return ze({groups:[{key:"organizations",commands:()=>{let[o]=ao([Wc(r)]);return ys(o,a=>ur(Ge("getOrganizationById",{organizationId:a.organization},{nullOnError:!0}))).filter(ue).map(a=>({key:a.id,title:a.title,...a.id===n?{type:0,selected:!0}:{selected:void 0},icon:de(pt,{org:a}),trigger:()=>{e(a)}}))}},{key:"organization-controls",commands:[{key:"create-organization",title:"Create an organization",icon:S.Organization.CSS,trigger:()=>{t()}}]}].filter(ue)})}var Tm=Dm.StyleSheet.create({orgSwitchButton:{position:"relative",borderRadius:4,left:-2,paddingLeft:"var(--sp-spacing-100)",paddingRight:"var(--sp-spacing-200)",paddingVertical:0,justifyContent:"flex-start",flexBasis:0,flexGrow:1},orgSwitchButtonCompact:{left:0,paddingLeft:0,paddingRight:0,justifyContent:"center",alignItems:"center"}});function $a({organization:r,sidebarCollapsable:n}){let[,{open:e}]=yl(),{compact:t}=ve.useContext(Rt),o=so(),i=co(),a=oo(Oe(Rn),Oe(Pn),{collapsable:n,lockedAsCollapsed:i}),{opened:c}=zc(a),[h,p]=ve.useState(!1);if(ve.useEffect(()=>{if(!h)return;let y=window.requestAnimationFrame(()=>p(!1));return()=>window.cancelAnimationFrame(y)},[h]),!r)return null;let d=r?.hasAI?"Ask or search":"Search content",f=de(pt,{org:r});return ve.createElement(O,{style:[Re.headerHeight,u.flex.column,u.padding.all400,t?[Re.compact,u.flex.justifyCenter,u.flex.alignItemsCenter,u.flex.gap400]:[u.flex.justifySpaceBetween,u.flex.alignItemsStretch]]},ve.createElement(O,{style:[u.flex.alignItemsCenter,u.width.min0,u.width.full,t?[u.flex.column,u.flex.justifyCenter,u.flex.gap400]:[u.flex.justifySpaceBetween]]},ve.createElement(_m,{activeOrganization:r.key,title:r.title,compact:t,icon:f}),ve.createElement(O,{style:[u.width.min0,u.flex.basis30,u.flex.alignItemsCenter,u.flex.justifyEnd,t?[u.flex.column,u.flex.gap400,u.margin.left0]:null]},ve.createElement(du,{compact:t}),ve.createElement(Y,{label:`${c?"Hide":"Show"} sidebar`,title:`${c?"Hide":"Show"} sidebar`,testID:"sidebar.toggleButton",leadingIcon:c?S.PanelLeftClose.CSS:S.PanelLeftOpen.CSS,iconOnly:!0,onPress:()=>{p(!0),i&&o(),a.toggle()},style:t?u.flex.orderFirst:null,kind:"nested"}))),ve.createElement(O,{style:[u.flex.justifyStart,t?[u.flex.alignItemsCenter]:[Re.searchAskButtonWrapper]]},ve.createElement(Y,{testID:"sidebar.findButton",label:d,tooltip:{label:d,position:"right",disabled:!t},iconOnly:t,leadingIcon:r?.hasAI?S.SearchOrAsk.CSS:S.Search.CSS,size:"medium",kind:"blank",style:[Re.searchAskButton,u.width.full,u.border.none,t?[u.margin.top0,u.padding.all0,u.size.button300,u.text.colorBase]:[u.padding.vertical400,u.padding.right100,u.padding.left200,u.text.colorMuted]],trailingIcon:t?void 0:()=>ve.createElement(ss,{style:[u.responsive.desktopOnlyInsert],shortcut:fo.SEARCH_OPEN}),onPress:()=>e(),preventFocusOnPress:!0})))}s();function Mm(r){return"organization"in r&&(r.type==="home"||r.type==="snippets"||r.type==="snippet"||r.type==="trash"||r.type==="insights"||r.type==="integrations"||r.type==="space"||r.type==="collection"||r.type==="sites"||r.type==="site")}function Hm(r){let{screen:n}=r,{permissions:e}=wt(),t="organization"in n&&n.organization?n.organization:Object.keys(e.organizations)[0],o="organization"in n&&n.type==="site"?n.site:void 0,i="organization"in n&&n.type==="space"?n.space:void 0,a="organization"in n&&n.type==="collection"?n.collection:void 0,c=Mm(n)?n.type:void 0;return t?Ee.createElement(Fb,{screenOrganization:t,screenSite:o,screenSpace:i,screenCollection:a,organizationMenuScreenType:c,...r}):Ee.createElement(Nm,null)}function Nm(r){return Ee.createElement(cr,{header:Ee.createElement($a,null),footer:Ee.createElement(Ga,null)},Ee.createElement(T,{style:[u.text.colorLight,u.margin.vertical400,u.margin.horizontal400]},"Join an organization or create a new one to get started with your content."))}var Fb=Ee.memo(function(n){let{screenOrganization:e,sidebarCollapsable:t}=n,[o]=Sn([Ft(e)]);return o?Ee.createElement(cr,{header:Ee.createElement($a,{organization:o,sidebarCollapsable:t}),footer:Ee.createElement(Ga,{organization:o,organizationMenuScreenType:n.organizationMenuScreenType}),withDividers:!1},Ee.createElement(Om,{...n})):Ee.createElement(Nm,null)});s();var M=P(k());function Bm(r){let{screen:n}=r,{compact:e}=M.useContext(Rt),t=Je(Pn);return M.useEffect(()=>{e&&t(!0)},[e,t]),M.createElement(cr,{kind:"settings",contrast:"low",header:M.createElement(Jb,null),footer:M.createElement(qb,{organization:"organization"in n?n.organization:void 0})},M.createElement(Kb,{screen:n}),M.createElement(Wb,{screen:n}))}function Kb(r){let{screen:n}=r,{getNavigationLinkProps:e}=Z(),t=vn(),o=ds(ho,{user:t.uid,size:Yr.sm},[t.uid]),i=a=>({...e({current:{type:"account",tab:a}}),active:n.type==="account"&&n.tab===a});return M.createElement(O,{style:[u.flex.column,u.padding.bottom400,u.flex.gap100]},M.createElement(z,{kind:"heading",icon:o,...i("profile"),active:!1},"Personal"),M.createElement(z,{icon:S.Settings,...i("profile")},"Account"),M.createElement(z,{icon:S.Bell,...i("notification")},"Notifications"),M.createElement(z,{icon:S.Organization,...i("organizations")},"Organizations"),M.createElement(z,{icon:S.Code,...i("developer")},"Developer Settings"))}function Wb(r){let{screen:n}=r,{permissions:e}=wt(),t=e.organizations,o=M.useRef(null),i="organization"in n?n.organization:o.current,a=Object.keys(e.organizations).filter(p=>re(t[p],"admin-profile")||re(t[p],"update-team-member-roles")),c=(i?a.find(p=>p===i):null)||a[0],[h]=Sn([c?Ft(c):null]);return h?(o.current=i,M.createElement(M.Fragment,null,M.createElement(Lc,null),M.createElement(O,{style:[u.flex.column,u.padding.bottom400,u.flex.gap100]},M.createElement(Vb,{screen:n,organization:h,organizationsKeys:a})))):null}function Vb(r){let{screen:n,organization:e,organizationsKeys:t}=r,{navigate:o,getNavigationLinkProps:i}=Z(),a=Ct("CUSTOM_FIELDS"),c=On(e.key,"members-teams"),h=uo(e.key),p=re(h,"admin-profile"),d=re(h,"admin-billing"),f=re(h,"update-team-member-roles"),y=Kr(pt,{org:e},[e]),C=v=>({...i({current:{type:"org_settings",organization:e.key,tab:v}}),active:n.type==="org_settings"&&n.organization===e.key&&n.tab.type===v.type}),I=()=>ze({groups:[{key:"organizations",commands:()=>ao(t.map(g=>Ft(g))).map(g=>(Qn(g),{key:g.key,title:g.title,...g.key===e.key?{type:0,selected:!0}:{selected:void 0},icon:de(pt,{org:g}),trigger:()=>{o({current:{type:"org_settings",organization:g.key,tab:{type:"profile"}}})}}))}]});return M.createElement(M.Fragment,null,M.createElement(z,{kind:"heading",icon:y,...C({type:"profile"}),active:!1,buttonsVisibility:"always",buttons:[M.createElement(lc,{onClick:v=>{v.preventDefault()},size:"small",leadingIcon:S.ChevronsVertical.CSS,label:"Switch organization",kind:"blank",palette:I,iconOnly:!0})]},e.title),p?M.createElement(z,{icon:S.Organization,...C({type:"profile"})},"General"):null,p?M.createElement(z,{icon:S.Users,...C({type:"members"})},"Members"):null,p||f?M.createElement(z,{icon:S.Team,...C({type:"teams"}),trailingIcon:c?M.createElement(S.Upgrade.CSS,{style:[u.size.icon400,u.text.colorUpgrade]}):void 0},"Teams"):null,p?M.createElement(z,{icon:S.Sso,...C({type:"sso"})},"SSO"):null,p?M.createElement(Wo,{name:"FEATURE_INTEGRATIONS_PAGE",fallback:M.createElement(z,{icon:S.Integrations,...C({type:"integrations"})},"Integrations")}):null,p&&a?M.createElement(z,{icon:S.Numbers,...C({type:"custom-fields"})},"Custom Fields"):null,p?M.createElement(z,{icon:S.Grid,...C({type:"plans"})},"Plans"):null,d?M.createElement(z,{icon:S.ExternalLink,...C({type:"billing"})},"Billing"):null)}function Jb(r){return M.createElement(O,{style:u.padding.all400},M.createElement(T,{style:[u.text.uiStandout,u.text.colorBase]},"Settings"))}function qb(r){let{organization:n}=r;return M.createElement(O,{style:[u.flex.column,u.padding.all400]},M.createElement(Cn,{kind:"blank",testID:"settings.closeButton",leadingIcon:S.ArrowLeft.CSS,to:{overlay:null,screen:{type:"root",organization:n}},size:"large",label:"Return to the app"}))}function Lm(){return pr(4e3,!0),x.createElement(ns,{client:Qc},x.createElement(os,null,x.createElement(ym,null,x.createElement(ls,{portalContainer:Bs()??void 0},x.createElement(Dd,null,x.createElement(Ep,null,x.createElement(Op,null,x.createElement(x.Suspense,{fallback:x.createElement(zm,null)},x.createElement(O,{style:[u.height.min0,u.flex.flex1,u.flex.column]},x.createElement(yp,null,x.createElement(fl,{persist:!0},x.createElement(fp,null,x.createElement(Vl,null,x.createElement(Il,null,x.createElement(Gb,null))))))),x.createElement(bm,null)))))))))}function Gb(){Cp(),fu();let{screen:r}=wn();return x.createElement(pu,null,x.createElement(wp,{Screen:$b,fallback:x.createElement(zm,null)}),x.createElement(El,null),x.createElement(Vf,null),r.type==="back_office"?x.createElement(Kl,null):x.createElement(hm,null))}function $b(r){let{screen:n,isOverlay:e,isCurrent:t}=r;pr(),ku(t?n.type==="space"&&n.revision?"bottom-right-with-bar":"bottom-right":void 0);let o=Ct("FEATURE_INTEGRATIONS_PAGE");switch(n.type){case"root":return x.createElement(Gl,{screen:n});case"account":case"org_settings":return x.createElement(Ti,{sidebar:x.createElement(Bm,{screen:n}),screen:n},x.createElement(Jl,{screen:n}));case"account_verification":return x.createElement(Ql,null);case"org_join":return x.createElement(jl,{screen:n});case"org_invite":return x.createElement(Xl,{screen:n,isOverlay:e});case"welcome":return x.createElement(ql,{screen:n});case"template":return x.createElement(tu,{screen:n,isOverlay:e});case"import":return x.createElement(nu,{screen:n,isOverlay:e});case"back_office":return x.createElement(Fl,{screen:n});case"legacy_account":return x.createElement(Zl,{screen:n});case"legacy_space":return x.createElement(eu,{screen:n});case"contentkit_builder":return x.createElement(ru,{screen:n});case"join":return x.createElement(gl,{to:{screen:{type:"root"}},replace:!0});case"integrations":if(!o)return x.createElement(Ai,{screen:n,isOverlay:e});default:return x.createElement(Ti,{sidebar:x.createElement(Hm,{sidebarCollapsable:!0,screen:n}),sidebarCollapsable:!0,screen:n},x.createElement(jb,{screen:n}))}}function jb(r){let{screen:n}=r;switch(n.type){case"home":return x.createElement($l,{screen:n});case"site":return x.createElement(lu,{screen:n});case"sites":return x.createElement(cu,{screen:n});case"space":return x.createElement(Wl,{screen:n});case"collection":return x.createElement(zl,{screen:n});case"snippet":return x.createElement(ou,{screen:n});case"snippets":return x.createElement(iu,{screen:n});case"trash":return x.createElement(au,{screen:n});case"insights":return x.createElement(su,{screen:n});case"integrations":return n.integration?x.createElement(Ul,{screen:n}):x.createElement(Ai,{screen:n,isOverlay:!1});default:return x.createElement(Xb,null)}}var Xb=()=>x.createElement(Le,{kind:"alert",title:"Page not found",description:"The page you are looking for does not exist."});function zm(){let[r]=St();return x.createElement(Ds,{backgroundColor:r.colors.background.muted,style:[dt.flex1]},x.createElement(Fr,{size:"xlarge"}))}var Um=!1;function Qb(){Um||(es({dsn:lt.sentry.dsn,release:Za,projectId:lt.firebase.projectId,tracesSampling:lt.sentry.tracesSampling,recordReplays:!!lt.sentry.recordReplays}),pp(),Um=!0,ja.AppRegistry.registerComponent("Application",()=>Lm),ja.AppRegistry.runApplication("Application",{rootTag:document.getElementById("gitbook-root")}))}function Zb(r){document.readyState==="interactive"||document.readyState==="complete"?r():document.addEventListener("DOMContentLoaded",()=>{r()})}Zb(()=>{Qb()});
//# sourceMappingURL=/public/dist/index-EO662V74.min.js.map