dbf-mirador-annotation-editor 1.5.0-testing3 → 1.5.0-testing4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
6
6
  Plugins prop is no longer supported.
7
7
  Instead, mount it with "Sortable.mount(new MultiDrag())"
8
8
  Please read the updated README.md at https://github.com/SortableJS/react-sortablejs.
9
- `)}componentDidMount(){if(this.ref.current===null)return;const U=this.makeOptions();a(e).create(this.ref.current,U)}componentDidUpdate(U){U.disabled!==this.props.disabled&&this.sortable&&this.sortable.option("disabled",this.props.disabled)}render(){const{tag:U,style:W,className:V,id:Z}=this.props,L={style:W,className:V,id:Z},z=!U||U===null?"div":U;return(0,r.createElement)(z,{ref:this.ref,...L},this.getChildren())}getChildren(){const{children:U,dataIdAttr:W,selectedClass:V="sortable-selected",chosenClass:Z="sortable-chosen",dragClass:L="sortable-drag",fallbackClass:z="sortable-falback",ghostClass:q="sortable-ghost",swapClass:ne="sortable-swap-highlight",filter:te="sortable-filter",list:$}=this.props;if(!U||U==null)return null;const fe=W||"data-id";return r.Children.map(U,(Q,oe)=>{if(Q===void 0)return;const se=$[oe]||{},{className:be}=Q.props,pe=typeof te=="string"&&{[te.replace(".","")]:!!se.filtered},Oe=a(t)(be,{[V]:se.selected,[Z]:se.chosen,...pe});return(0,r.cloneElement)(Q,{[fe]:Q.key,className:Oe})})}get sortable(){const U=this.ref.current;if(U===null)return null;const W=Object.keys(U).find(V=>V.includes("Sortable"));return W?U[W]:null}makeOptions(){const U=["onAdd","onChoose","onDeselect","onEnd","onRemove","onSelect","onSpill","onStart","onUnchoose","onUpdate"],W=["onChange","onClone","onFilter","onSort"],V=D(this.props);return U.forEach(L=>V[L]=this.prepareOnHandlerPropAndDOM(L)),W.forEach(L=>V[L]=this.prepareOnHandlerProp(L)),{...V,onMove:(L,z)=>{const{onMove:q}=this.props,ne=L.willInsertAfter||-1;if(!q)return ne;const te=q(L,z,this.sortable,k);return typeof te>"u"?!1:te}}}prepareOnHandlerPropAndDOM(U){return W=>{this.callOnHandlerProp(W,U),this[U](W)}}prepareOnHandlerProp(U){return W=>{this.callOnHandlerProp(W,U)}}callOnHandlerProp(U,W){const V=this.props[W];V&&V(U,this.sortable,k)}onAdd(U){const{list:W,setList:V,clone:Z}=this.props,L=[...k.dragging.props.list],z=b(U,L);g(z);const q=I(z,W,U,Z).map(ne=>Object.assign(ne,{selected:!1}));V(q,this.sortable,k)}onRemove(U){const{list:W,setList:V}=this.props,Z=C(U),L=b(U,W);v(L);let z=[...W];if(U.pullMode!=="clone")z=E(L,z);else{let q=L;switch(Z){case"multidrag":q=L.map((ne,te)=>({...ne,element:U.clones[te]}));break;case"normal":q=L.map(ne=>({...ne,element:U.clone}));break;default:a(i)(!0,`mode "${Z}" cannot clone. Please remove "props.clone" from <ReactSortable/> when using the "${Z}" plugin`)}g(q),L.forEach(ne=>{const te=ne.oldIndex,$=this.props.clone(ne.item,U);z.splice(te,1,$)})}z=z.map(q=>Object.assign(q,{selected:!1})),V(z,this.sortable,k)}onUpdate(U){const{list:W,setList:V}=this.props,Z=b(U,W);g(Z),v(Z);const L=S(Z,W);return V(L,this.sortable,k)}onStart(){k.dragging=this}onEnd(){k.dragging=null}onChoose(U){const{list:W,setList:V}=this.props,Z=W.map((L,z)=>{let q=L;return z===U.oldIndex&&(q=Object.assign(L,{chosen:!0})),q});V(Z,this.sortable,k)}onUnchoose(U){const{list:W,setList:V}=this.props,Z=W.map((L,z)=>{let q=L;return z===U.oldIndex&&(q=Object.assign(q,{chosen:!1})),q});V(Z,this.sortable,k)}onSpill(U){const{removeOnSpill:W,revertOnSpill:V}=this.props;W&&!V&&c(U.item)}onSelect(U){const{list:W,setList:V}=this.props,Z=W.map(L=>Object.assign(L,{selected:!1}));U.newIndicies.forEach(L=>{const z=L.index;if(z===-1){console.log(`"${U.type}" had indice of "${L.index}", which is probably -1 and doesn't usually happen here.`),console.log(U);return}Z[z].selected=!0}),V(Z,this.sortable,k)}onDeselect(U){const{list:W,setList:V}=this.props,Z=W.map(L=>Object.assign(L,{selected:!1}));U.newIndicies.forEach(L=>{const z=L.index;z!==-1&&(Z[z].selected=!0)}),V(Z,this.sortable,k)}}var G={};u(n.exports,G)})(xx)),xx.exports}var lA=LB();const uA=(n,e)=>n.order===e.order?n.id.localeCompare(e.id):n.order===null||n.order===void 0?1:e.order===null||e.order===void 0?-1:n.order-e.order,kB=(n=[])=>{const e=n.filter(a=>a["dbf:kind"]==="Journey"),t={},r=[];n.filter(a=>a["dbf:kind"]!=="Journey").forEach(a=>{const s=a["dbf:journey"];s?.id?(t[s.id]??=[]).push(a):r.push(a)}),Object.values(t).forEach(a=>a.sort((s,u)=>uA({id:s.id,order:s["dbf:journey"]?.order},{id:u.id,order:u["dbf:journey"]?.order})));const i=[...e.map(a=>({id:a.id,item:a,kind:"Journey",order:a["dbf:order"],pois:t[a.id]??[]})),...r.map(a=>({id:a.id,item:a,kind:"POI",order:a["dbf:order"]}))];return i.sort(uA),i},PB=(n,e)=>{const t=(Array.isArray(n?.body)?n.body:[]).filter(i=>i?.purpose==="identifying"&&i?.type==="TextualBody");return((t.find(i=>i.language===e)??t[0])?.value??"").trim()},jB=(n,e)=>{const t={...n,"dbf:order":e};return n["dbf:kind"]==="POI"&&n["dbf:journey"]&&(t["dbf:journey"]=null),t},FB=(n,e,t)=>({...n,"dbf:journey":{id:e,order:t}});function S5({canvasId:n,deselectAnnotation:e,hoverAnnotation:t,hoveredAnnotationIds:r=[],index:i,items:a=[],label:s,receiveAnnotation:u,selectAnnotation:c,selectedAnnotationId:h,storageAdapter:g,totalSize:v,windowId:b}){const{i18n:S,t:E}=Bs.useTranslation(),[I,C]=N.useState(a);N.useEffect(()=>{C(a)},[a]);const w=N.useMemo(()=>kB(I),[I]),D=N.useMemo(()=>w.map(V=>V.item),[w]),k=N.useCallback(V=>{const Z=g(n);Z.update(V).then(L=>{u(n,Z.annotationPageId,L)})},[g,n,u]),P=N.useCallback(V=>{C(Z=>{const L=new Map(Z.map(z=>[z.id,z]));return V.forEach(z=>{L.set(z.id,z)}),Array.from(L.values())}),V.forEach(Z=>k(Z))},[k]),G=N.useCallback(V=>{const Z=V.map((L,z)=>jB(L,z));P(Z)},[P]),B=N.useCallback((V,Z)=>{const L=Z.map((z,q)=>FB(z,V,q));P(L)},[P]),U=N.useCallback(V=>{window.getSelection()?.toString()||(h===V?e(b,V):c(b,V))},[b,e,c,h]),W=V=>{const Z=PB(V,S.language)||"—",L=r.includes(V.id)||h===V.id;return O.jsx(g5,{annotationid:V.id,"data-kind":V["dbf:kind"],onClick:()=>U(V.id),onMouseEnter:()=>t(b,[V.id]),onMouseLeave:()=>t(b,[]),style:{backgroundColor:L?"rgba(0, 0, 0, 0.04)":void 0,cursor:"pointer",listStyle:"none",padding:"8px 16px"},children:O.jsx(Hn,{variant:"body2",children:Z})},V.id)};return D.length===0?null:O.jsxs(O.Fragment,{children:[O.jsx(Hn,{sx:{paddingLeft:2,paddingRight:1,paddingTop:2},variant:"overline",children:E("annotationCanvasLabel",{context:`${i+1}/${v}`,label:s})}),O.jsx(lA.ReactSortable,{animation:150,group:{name:"maps-annotation-list",put:!0},list:D,setList:G,tag:"ul",style:{listStyle:"none",margin:0,padding:0},children:w.map(V=>V.kind==="Journey"?O.jsxs("li",{style:{listStyle:"none"},"data-kind":"Journey",children:[W(V.item),O.jsx(lA.ReactSortable,{animation:150,group:{name:"maps-annotation-list",put:(Z,L,z)=>z.getAttribute("data-kind")==="POI"},list:V.pois,setList:Z=>B(V.id,Z),tag:"ul",style:{listStyle:"none",margin:0,paddingInlineStart:24},children:V.pois.map(Z=>O.jsx(N.Fragment,{children:W(Z)},Z.id))})]},V.id):O.jsx(N.Fragment,{children:W(V.item)},V.id))})]})}S5.propTypes={canvasId:T.string.isRequired,deselectAnnotation:T.func.isRequired,hoverAnnotation:T.func.isRequired,hoveredAnnotationIds:T.arrayOf(T.string),index:T.number.isRequired,items:T.arrayOf(T.object),label:T.string.isRequired,receiveAnnotation:T.func.isRequired,selectAnnotation:T.func.isRequired,selectedAnnotationId:T.string,storageAdapter:T.func.isRequired,totalSize:T.number.isRequired,windowId:T.string.isRequired};S5.defaultProps={hoveredAnnotationIds:[],items:[],selectedAnnotationId:void 0};const v_=n=>{if(!n)return!1;const e=getComputedStyle(n),t=e.overflowY||e.overflow||"";return/(auto|scroll|overlay)/.test(t)&&n.scrollHeight>n.clientHeight},BB=n=>{let e=n?.parentElement||null;for(;e;){if(v_(e))return e;e=e.parentElement}return null},GB=()=>document.scrollingElement||document.documentElement;function HB(n,e,t){const r=n.getBoundingClientRect(),i=e.getBoundingClientRect(),a=i.top-r.top+n.scrollTop,s=i.bottom-r.top+n.scrollTop,u=n.scrollTop+t,c=n.scrollTop+n.clientHeight,h=a<u,g=s>c;return!h&&!g?null:h?a-t:Math.max(s-n.clientHeight,a-t)}function zB(n,e){const t=n.getBoundingClientRect(),r=t.top+window.scrollY,i=t.bottom+window.scrollY,a=window.scrollY+e,s=window.scrollY+window.innerHeight,u=r<a,c=i>s;return!u&&!c?null:u?r-e:Math.max(i-window.innerHeight,r-e)}const qB=(n,e,t)=>new Promise(r=>{const i="smooth";requestAnimationFrame(()=>{requestAnimationFrame(()=>{let s=e.current;if(v_(s)||(s=BB(n)),v_(s)||(s=GB()),s===document.body||s===document.documentElement||s===document.scrollingElement){const g=zB(n,96);if(g==null)return r(!0);const v=window.scrollY;window.scrollTo({behavior:i,top:g}),setTimeout(()=>{const b=window.scrollY;r(Math.abs(b-v)>.5)},t);return}const c=HB(s,n,96);if(c==null)return r(!0);const h=s.scrollTop;typeof s.scrollTo=="function"&&s.scrollTo({behavior:i,top:c}),setTimeout(()=>{const g=s.scrollTop;r(Math.abs(g-h)>.5)},t)})})}),UB=async(n,e)=>{for(let i=0;i<=3&&!await qB(n,e,24);i++)i<3&&await new Promise(s=>{setTimeout(s,24)})},aO={defaultForm:{default:null,type:"string"},defaultTags:{default:[],type:"array"},editMode:{default:!1,type:"boolean"}},VB={array:n=>n?n.split(",").map(e=>e.trim()).filter(Boolean):[],boolean:n=>n==="true",number:n=>{const e=Number(n);return Number.isNaN(e)?null:e},string:n=>n||null};let $v=null;function WB(){if(!$v){const n=new URLSearchParams(window.location.search);$v={},Object.entries(aO).forEach(([e,t])=>{const r=n.get(e);r!==null&&($v[e]=VB[t.type](r))})}return $v}function Um(n){const e=WB(),t={};return Object.entries(aO).forEach(([r,i])=>{r in e?t[r]=e[r]:n?.annotation?.[r]!==void 0?t[r]=n.annotation[r]:t[r]=i.default}),t}function XB(n){return N.useMemo(()=>Um(n),[n])}function sO({addCompanionWindow:n,annotationsOnCanvases:e={},canvases:t=[],config:r,deselectAnnotation:i,highlightAllAnnotations:a,receiveAnnotation:s,switchToSingleCanvasView:u,TargetComponent:c,targetProps:h,updateWindow:g,windowViewType:v,annotationEditCompanionWindowIsOpened:b}){const[S,E]=N.useState(!1),{t:I}=Bs.useTranslation(),C=N.useRef(null),w=N.useRef(null);N.useEffect(()=>{const L=h?.selectedAnnotationId;if(!L)return;const z=C.current?.querySelector(`li[annotationid="${L}"]`)||C.current?.querySelector("li.MuiMenuItem-root.Mui-selected");z&&UB(z,w)},[h?.selectedAnnotationId]);const D=N.useCallback(()=>{E(L=>!L)});N.useEffect(()=>{ax.isInitialized&&r.translations&&(Object.keys(r.translations).forEach(L=>{ax.addResourceBundle(L,"translation",r.translations[L],!0,!0)}),r.language&&ax.changeLanguage(r.language))},[r.translations,r.language]);const{editMode:k}=XB(r);N.useEffect(()=>{k&&!a&&g({highlightAllAnnotations:!0})},[k,a,g]);const P=N.useCallback(L=>L?t.some(z=>{const q=e[z.id];return q?Object.values(q).some(ne=>ne.json&&ne.json.items?ne.json.items.some(te=>te.id===L&&te.maeData):!1):!1}):!1,[t,e]),G=N.useRef(b);N.useEffect(()=>{const L=!G.current,z=b;G.current=b,k&&L&&z&&i()},[k,b,i]);const B=N.useRef(null);N.useEffect(()=>{if(!k)return;const L=h?.selectedAnnotationId;L!==B.current&&(B.current=L,L&&b&&P(L)&&n("annotationCreation",{annotationid:L,position:"right"}))},[k,h?.selectedAnnotationId,b,P,n]);const U={containerRef:w,...h,listContainerComponent:g5},W=N.useMemo(()=>{const L=h?.canvasId;return!L||!e[L]?[]:Object.values(e[L]).flatMap(z=>z?.json?.items??[])},[h?.canvasId,e]),V=W.some(L=>L["dbf:kind"]==="POI"||L["dbf:kind"]==="Journey"),Z=N.useMemo(()=>({addCompanionWindow:n,annotationEditCompanionWindowIsOpened:b,annotationsOnCanvases:e,canvases:t,config:r,receiveAnnotation:s,storageAdapter:r.annotation.adapter,t:I,toggleSingleCanvasDialogOpen:D,windowId:h.windowId,windowViewType:v}),[n,b,e,t,r,s,I,D,h.windowId,v]);return O.jsxs(q7.Provider,{value:Z,children:[O.jsx("div",{ref:C,style:{height:"100%",position:"relative"},children:V?O.jsx(S5,{canvasId:h.canvasId,deselectAnnotation:h.deselectAnnotation,hoverAnnotation:h.hoverAnnotation,hoveredAnnotationIds:h.hoveredAnnotationIds,index:h.index,items:W,label:h.label,receiveAnnotation:s,selectAnnotation:h.selectAnnotation,selectedAnnotationId:h.selectedAnnotationId,storageAdapter:r.annotation.adapter,totalSize:h.totalSize,windowId:h.windowId}):O.jsx(c,{...U})}),v!=="single"&&O.jsx(c5,{handleClose:D,open:S,switchToSingleCanvasView:u})]})}sO.propTypes={addCompanionWindow:T.func.isRequired,annotationEditCompanionWindowIsOpened:T.bool.isRequired,annotationsOnCanvases:T.shape({id:T.string,isFetching:T.bool,json:T.shape({id:T.string,items:T.arrayOf(T.shape({body:T.shape({format:T.string,id:T.string,value:T.string}),drawingState:T.string,id:T.string,manifestNetwork:T.string,motivation:T.string,target:T.string,type:T.string})),type:T.string})}).isRequired,canvases:T.arrayOf(T.shape({id:T.string,index:T.number})).isRequired,config:T.shape({annotation:T.shape({adapter:T.func,editMode:T.bool}),language:T.string,translations:T.objectOf(T.object)}).isRequired,deselectAnnotation:T.func.isRequired,highlightAllAnnotations:T.bool.isRequired,receiveAnnotation:T.func.isRequired,switchToSingleCanvasView:T.func.isRequired,t:T.func.isRequired,TargetComponent:T.oneOfType([T.func,T.node]).isRequired,targetProps:T.object.isRequired,updateWindow:T.func.isRequired,windowViewType:T.string.isRequired};function YB(n,{targetProps:{windowId:e}}){const t=Gt.getVisibleCanvases(n,{windowId:e}),r={},i=Gt.getCompanionWindowsForContent(n,{content:"annotationCreation",windowId:e}),a=Object.keys(i).length===0;return t.forEach(s=>{const u=n.annotations[s.id];u&&(r[s.id]=u)}),{annotationEditCompanionWindowIsOpened:a,annotationsOnCanvases:r,canvases:t,config:{...n.config,translations:d5},highlightAllAnnotations:Gt.getWindow(n,{windowId:e}).highlightAllAnnotations,windowViewType:Gt.getWindowViewType(n,{windowId:e})}}const ZB=(n,e)=>({addCompanionWindow:(t,r)=>n(Gt.addCompanionWindow(e.targetProps.windowId,{content:t,...r})),deselectAnnotation:()=>n(Gt.deselectAnnotation(e.targetProps.windowId)),receiveAnnotation:(t,r,i)=>n(Gt.receiveAnnotation(t,r,i)),switchToSingleCanvasView:()=>n(Gt.setWindowViewType(e.targetProps.windowId,"single")),updateWindow:t=>n(Gt.updateWindow(e.targetProps.windowId,t))}),oO={component:sO,mapDispatchToProps:ZB,mapStateToProps:YB,mode:"wrap",target:"CanvasAnnotations"},Ia=[];for(let n=0;n<256;++n)Ia.push((n+256).toString(16).slice(1));function JB(n,e=0){return(Ia[n[e+0]]+Ia[n[e+1]]+Ia[n[e+2]]+Ia[n[e+3]]+"-"+Ia[n[e+4]]+Ia[n[e+5]]+"-"+Ia[n[e+6]]+Ia[n[e+7]]+"-"+Ia[n[e+8]]+Ia[n[e+9]]+"-"+Ia[n[e+10]]+Ia[n[e+11]]+Ia[n[e+12]]+Ia[n[e+13]]+Ia[n[e+14]]+Ia[n[e+15]]).toLowerCase()}let Mx;const KB=new Uint8Array(16);function $B(){if(!Mx){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Mx=crypto.getRandomValues.bind(crypto)}return Mx(KB)}const QB=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cA={randomUUID:QB};function eG(n,e,t){n=n||{};const r=n.random??n.rng?.()??$B();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,JB(r)}function vs(n,e,t){return cA.randomUUID&&!n?cA.randomUUID():eG(n)}var Lg={},dA;function tG(){if(dA)return Lg;dA=1,Object.defineProperty(Lg,"__esModule",{value:!0});function n(a){return!a||typeof a=="string"?a:a+""}class e{async svg2canvas(s,u,c){const h=await new Promise(b=>{var S=new Image;S.onload=function(){b(S)},S.src=s});var g=document.createElement("canvas");return g.width=u,g.height=c,g.getContext("2d").drawImage(h,0,0),g}toDataURL(s,u,c,h,g,v){var b=new XMLSerializer().serializeToString(s),S=document.documentMode;if(S){var E=/xmlns="http:\/\/www\.w3\.org\/2000\/svg".+xmlns="http:\/\/www\.w3\.org\/2000\/svg/gi;E.test(b)&&(b=b.replace('xmlns="http://www.w3.org/2000/svg','xmlns:xlink="http://www.w3.org/1999/xlink'))}v||(v={});var I="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(b);if(h==="image/svg+xml"||!h)return v.async?Promise.resolve(I):I;if(h==="image/jpeg"||h==="image/png"){if(!v.async)throw new Error("svgcanvas: options.async must be set to true if type is image/jpeg | image/png");return(async()=>{const C=await this.svg2canvas(I,u,c),w=C.toDataURL(h,g);return C.remove(),w})()}throw new Error("svgcanvas: Unknown type for toDataURL, please use image/jpeg | image/png | image/svg+xml.")}getImageData(s,u,c,h,g,v,b,S){if(S||(S={}),!S.async)throw new Error("svgcanvas: options.async must be set to true for getImageData");const E=this.toDataURL(s,u,c,"image/svg+xml");return(async()=>{const I=await this.svg2canvas(E,u,c),w=I.getContext("2d").getImageData(h,g,v,b);return I.remove(),w})()}}const t=new e;var r=(function(){var a,s,u,c,h;function g(C,w){var D=Object.keys(w),k;for(k=0;k<D.length;k++)C=C.replace(new RegExp("\\{"+D[k]+"\\}","gi"),w[D[k]]);return C}function v(C){var w,D,k;if(!C)throw new Error("cannot create a random attribute name for an undefined object");w="ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",D="";do for(D="",k=0;k<12;k++)D+=w[Math.floor(Math.random()*w.length)];while(C[D]);return D}function b(C,w){var D,k,P={},G;for(C=C.split(","),w=w||10,D=0;D<C.length;D+=2)k="&"+C[D+1]+";",G=parseInt(C[D],w),P[k]="&#"+G+";";return P["\\xa0"]="&#160;",P}function S(C){var w={left:"start",right:"end",center:"middle",start:"start",end:"end"};return w[C]||w.start}function E(C){var w={alphabetic:"alphabetic",hanging:"hanging",top:"text-before-edge",bottom:"text-after-edge",middle:"central"};return w[C]||w.alphabetic}h=b("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32),a={strokeStyle:{svgAttr:"stroke",canvas:"#000000",svg:"none",apply:"stroke"},fillStyle:{svgAttr:"fill",canvas:"#000000",svg:null,apply:"fill"},lineCap:{svgAttr:"stroke-linecap",canvas:"butt",svg:"butt",apply:"stroke"},lineJoin:{svgAttr:"stroke-linejoin",canvas:"miter",svg:"miter",apply:"stroke"},miterLimit:{svgAttr:"stroke-miterlimit",canvas:10,svg:4,apply:"stroke"},lineWidth:{svgAttr:"stroke-width",canvas:1,svg:1,apply:"stroke"},globalAlpha:{svgAttr:"opacity",canvas:1,svg:1,apply:"fill stroke"},font:{canvas:"10px sans-serif"},shadowColor:{canvas:"#000000"},shadowOffsetX:{canvas:0},shadowOffsetY:{canvas:0},shadowBlur:{canvas:0},textAlign:{canvas:"start"},textBaseline:{canvas:"alphabetic"},lineDash:{svgAttr:"stroke-dasharray",canvas:[],svg:null,apply:"stroke"}},u=function(C,w){this.__root=C,this.__ctx=w},u.prototype.addColorStop=function(C,w){var D=this.__ctx.__createElement("stop"),k,P;D.setAttribute("offset",C),n(w).indexOf("rgba")!==-1?(k=/rgba\(\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi,P=k.exec(w),D.setAttribute("stop-color",g("rgb({r},{g},{b})",{r:P[1],g:P[2],b:P[3]})),D.setAttribute("stop-opacity",P[4])):D.setAttribute("stop-color",n(w)),this.__root.appendChild(D)},c=function(C,w){this.__root=C,this.__ctx=w},s=function(C){var w={width:500,height:500,enableMirroring:!1},D;if(arguments.length>1?(D=w,D.width=arguments[0],D.height=arguments[1]):C?D=C:D=w,!(this instanceof s))return new s(D);this.width=D.width||w.width,this.height=D.height||w.height,this.enableMirroring=D.enableMirroring!==void 0?D.enableMirroring:w.enableMirroring,this.canvas=this,this.__document=D.document||document,D.ctx?this.__ctx=D.ctx:(this.__canvas=this.__document.createElement("canvas"),this.__ctx=this.__canvas.getContext("2d")),this.__setDefaultStyles(),this.__styleStack=[this.__getStyleState()],this.__groupStack=[],this.__root=this.__document.createElementNS("http://www.w3.org/2000/svg","svg"),this.__root.setAttribute("version",1.1),this.__root.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.__root.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),this.__root.setAttribute("width",this.width),this.__root.setAttribute("height",this.height),this.__ids={},this.__defs=this.__document.createElementNS("http://www.w3.org/2000/svg","defs"),this.__root.appendChild(this.__defs),this.__currentElement=this.__document.createElementNS("http://www.w3.org/2000/svg","g"),this.__root.appendChild(this.__currentElement),this.resetTransform(),this.__options=D,this.__id=Math.random().toString(16).substring(2,8),this.__debug("new",C)},s.prototype.__debug=function(...C){this.__options.debug&&console.debug(`svgcanvas#${this.__id}:`,...C)},s.prototype.__createElement=function(C,w,D){typeof w>"u"&&(w={});var k=this.__document.createElementNS("http://www.w3.org/2000/svg",C),P=Object.keys(w),G,B;for(D&&(k.setAttribute("fill","none"),k.setAttribute("stroke","none")),G=0;G<P.length;G++)B=P[G],k.setAttribute(B,w[B]);return k},s.prototype.__setDefaultStyles=function(){var C=Object.keys(a),w,D;for(w=0;w<C.length;w++)D=C[w],this[D]=a[D].canvas},s.prototype.__applyStyleState=function(C){var w=Object.keys(C),D,k;for(D=0;D<w.length;D++)k=w[D],this[k]=C[k]},s.prototype.__getStyleState=function(){var C,w={},D=Object.keys(a),k;for(C=0;C<D.length;C++)k=D[C],w[k]=this[k];return w},s.prototype.__applyTransformation=function(C,w){const{a:D,b:k,c:P,d:G,e:B,f:U}=w||this.getTransform();C.setAttribute("transform",`matrix(${D} ${k} ${P} ${G} ${B} ${U})`)},s.prototype.__applyStyleToCurrentElement=function(C){var w=this.__currentElement,D=this.__currentElementsToStyle;D&&(w.setAttribute(C,""),w=D.element,D.children.forEach(function($){$.setAttribute(C,"")}));var k=Object.keys(a),P,G,B,U,W,V,Z,L;for(P=0;P<k.length;P++)if(G=a[k[P]],B=this[k[P]],G.apply){if(B instanceof c){if(B.__ctx)for(Z=0;Z<B.__ctx.__defs.childNodes.length;Z++)L=B.__ctx.__defs.childNodes[Z],V=L.getAttribute("id"),this.__ids[V]=V,this.__defs.appendChild(L);w.setAttribute(G.apply,g("url(#{id})",{id:B.__root.getAttribute("id")}))}else if(B instanceof u)w.setAttribute(G.apply,g("url(#{id})",{id:B.__root.getAttribute("id")}));else if(G.apply.indexOf(C)!==-1&&G.svg!==B)if((G.svgAttr==="stroke"||G.svgAttr==="fill")&&B&&B.indexOf("rgba")!==-1){U=/rgba\(\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi,W=U.exec(B),w.setAttribute(G.svgAttr,g("rgb({r},{g},{b})",{r:W[1],g:W[2],b:W[3]}));var z=W[4],q=this.globalAlpha;q!=null&&(z*=q),w.setAttribute(G.svgAttr+"-opacity",z)}else{var ne=G.svgAttr;if(k[P]==="globalAlpha"){if(ne=C+"-"+G.svgAttr,w.getAttribute(ne))continue}else if(k[P]==="lineWidth"){var te=this.__getTransformScale();B=B*Math.max(te.x,te.y)}w.setAttribute(ne,B)}}},s.prototype.__closestGroupOrSvg=function(C){return C=C||this.__currentElement,C.nodeName==="g"||C.nodeName==="svg"?C:this.__closestGroupOrSvg(C.parentNode)},s.prototype.getSerializedSvg=function(C){var w=new XMLSerializer().serializeToString(this.__root),D,k,P,G,B,U;if(U=/xmlns="http:\/\/www\.w3\.org\/2000\/svg".+xmlns="http:\/\/www\.w3\.org\/2000\/svg/gi,U.test(w)&&(w=w.replace('xmlns="http://www.w3.org/2000/svg','xmlns:xlink="http://www.w3.org/1999/xlink')),C)for(D=Object.keys(h),k=0;k<D.length;k++)P=D[k],G=h[P],B=new RegExp(P,"gi"),B.test(w)&&(w=w.replace(B,G));return w},s.prototype.getSvg=function(){return this.__root},s.prototype.save=function(){var C=this.__createElement("g"),w=this.__closestGroupOrSvg();this.__groupStack.push(w),w.appendChild(C),this.__currentElement=C;const D=this.__getStyleState();this.__debug("save style",D),this.__styleStack.push(D),this.__transformMatrixStack||(this.__transformMatrixStack=[]),this.__transformMatrixStack.push(this.getTransform())},s.prototype.restore=function(){this.__currentElement=this.__groupStack.pop(),this.__currentElementsToStyle=null,this.__currentElement||(this.__currentElement=this.__root.childNodes[1]);var C=this.__styleStack.pop();this.__debug("restore style",C),this.__applyStyleState(C),this.__transformMatrixStack&&this.__transformMatrixStack.length>0&&this.setTransform(this.__transformMatrixStack.pop())},s.prototype.beginPath=function(){var C,w;this.__currentDefaultPath="",this.__currentPosition={},C=this.__createElement("path",{},!0),w=this.__closestGroupOrSvg(),w.appendChild(C),this.__currentElement=C},s.prototype.__applyCurrentDefaultPath=function(){var C=this.__currentElement;C.nodeName==="path"?C.setAttribute("d",this.__currentDefaultPath):console.error("Attempted to apply path command to node",C.nodeName)},s.prototype.__addPathCommand=function(C){this.__currentDefaultPath+=" ",this.__currentDefaultPath+=C},s.prototype.moveTo=function(C,w){this.__currentElement.nodeName!=="path"&&this.beginPath(),this.__currentPosition={x:C,y:w},this.__addPathCommand(g("M {x} {y}",{x:this.__matrixTransform(C,w).x,y:this.__matrixTransform(C,w).y}))},s.prototype.closePath=function(){this.__currentDefaultPath&&this.__addPathCommand("Z")},s.prototype.lineTo=function(C,w){this.__currentPosition={x:C,y:w},this.__currentDefaultPath.indexOf("M")>-1?this.__addPathCommand(g("L {x} {y}",{x:this.__matrixTransform(C,w).x,y:this.__matrixTransform(C,w).y})):this.__addPathCommand(g("M {x} {y}",{x:this.__matrixTransform(C,w).x,y:this.__matrixTransform(C,w).y}))},s.prototype.bezierCurveTo=function(C,w,D,k,P,G){this.__currentPosition={x:P,y:G},this.__addPathCommand(g("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:this.__matrixTransform(C,w).x,cp1y:this.__matrixTransform(C,w).y,cp2x:this.__matrixTransform(D,k).x,cp2y:this.__matrixTransform(D,k).y,x:this.__matrixTransform(P,G).x,y:this.__matrixTransform(P,G).y}))},s.prototype.quadraticCurveTo=function(C,w,D,k){this.__currentPosition={x:D,y:k},this.__addPathCommand(g("Q {cpx} {cpy} {x} {y}",{cpx:this.__matrixTransform(C,w).x,cpy:this.__matrixTransform(C,w).y,x:this.__matrixTransform(D,k).x,y:this.__matrixTransform(D,k).y}))};var I=function(C){var w=Math.sqrt(C[0]*C[0]+C[1]*C[1]);return[C[0]/w,C[1]/w]};return s.prototype.arcTo=function(C,w,D,k,P){var G=this.__currentPosition&&this.__currentPosition.x,B=this.__currentPosition&&this.__currentPosition.y;if(!(typeof G>"u"||typeof B>"u")){if(P<0)throw new Error("IndexSizeError: The radius provided ("+P+") is negative.");if(G===C&&B===w||C===D&&w===k||P===0){this.lineTo(C,w);return}var U=I([G-C,B-w]),W=I([D-C,k-w]);if(U[0]*W[1]===U[1]*W[0]){this.lineTo(C,w);return}var V=U[0]*W[0]+U[1]*W[1],Z=Math.acos(Math.abs(V)),L=I([U[0]+W[0],U[1]+W[1]]),z=P/Math.sin(Z/2),q=C+z*L[0],ne=w+z*L[1],te=[-U[1],U[0]],$=[W[1],-W[0]],fe=function(se){var be=se[0],pe=se[1];return pe>=0?Math.acos(be):-Math.acos(be)},Q=fe(te),oe=fe($);this.lineTo(q+te[0]*P,ne+te[1]*P),this.arc(q,ne,P,Q,oe)}},s.prototype.stroke=function(){this.__currentElement.nodeName==="path"&&this.__currentElement.setAttribute("paint-order","fill stroke markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("stroke")},s.prototype.fill=function(){this.__currentElement.nodeName==="path"&&this.__currentElement.setAttribute("paint-order","stroke fill markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("fill")},s.prototype.rect=function(C,w,D,k){this.__currentElement.nodeName!=="path"&&this.beginPath(),this.moveTo(C,w),this.lineTo(C+D,w),this.lineTo(C+D,w+k),this.lineTo(C,w+k),this.lineTo(C,w),this.closePath()},s.prototype.roundRect=function(C,w,D,k,P){this.__currentElement.nodeName!=="path"&&this.beginPath();let G,B,U,W;typeof P=="number"?(G=P,B=P,U=P,W=P):[G,B,U,W]=P,this.moveTo(C+G,w),this.arcTo(C+D,w,C+D,w+k,B),this.arcTo(C+D,w+k,C,w+k,U),this.arcTo(C,w+k,C,w,W),this.arcTo(C,w,C+D,w,G),this.closePath()},s.prototype.fillRect=function(C,w,D,k){let{a:P,b:G,c:B,d:U,e:W,f:V}=this.getTransform();JSON.stringify([P,G,B,U,W,V])===JSON.stringify([1,0,0,1,0,0])&&C===0&&w===0&&D===this.width&&k===this.height&&this.__clearCanvas();var Z,L;Z=this.__createElement("rect",{x:C,y:w,width:D,height:k},!0),L=this.__closestGroupOrSvg(),L.appendChild(Z),this.__currentElement=Z,this.__applyTransformation(Z),this.__applyStyleToCurrentElement("fill")},s.prototype.strokeRect=function(C,w,D,k){var P,G;P=this.__createElement("rect",{x:C,y:w,width:D,height:k},!0),G=this.__closestGroupOrSvg(),G.appendChild(P),this.__currentElement=P,this.__applyTransformation(P),this.__applyStyleToCurrentElement("stroke")},s.prototype.__clearCanvas=function(){var C=this.__root.childNodes[1];this.__root.removeChild(C),this.__currentElement=this.__document.createElementNS("http://www.w3.org/2000/svg","g"),this.__root.appendChild(this.__currentElement),this.__groupStack=[]},s.prototype.clearRect=function(C,w,D,k){let{a:P,b:G,c:B,d:U,e:W,f:V}=this.getTransform();if(JSON.stringify([P,G,B,U,W,V])===JSON.stringify([1,0,0,1,0,0])&&C===0&&w===0&&D===this.width&&k===this.height){this.__clearCanvas();return}var Z,L=this.__closestGroupOrSvg();Z=this.__createElement("rect",{x:C,y:w,width:D,height:k,fill:"#FFFFFF"},!0),this.__applyTransformation(Z),L.appendChild(Z)},s.prototype.createLinearGradient=function(C,w,D,k){var P=this.__createElement("linearGradient",{id:v(this.__ids),x1:C+"px",x2:D+"px",y1:w+"px",y2:k+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(P),new u(P,this)},s.prototype.createRadialGradient=function(C,w,D,k,P,G){var B=this.__createElement("radialGradient",{id:v(this.__ids),cx:k+"px",cy:P+"px",r:G+"px",fx:C+"px",fy:w+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(B),new u(B,this)},s.prototype.__applyText=function(C,w,D,k){var P=document.createElement("span");P.setAttribute("style","font:"+this.font);var G=P.style,B=this.__closestGroupOrSvg(),U=this.__createElement("text",{"font-family":G.fontFamily,"font-size":G.fontSize,"font-style":G.fontStyle,"font-weight":G.fontWeight,"text-decoration":this.__fontUnderline,x:w,y:D,"text-anchor":S(this.textAlign),"dominant-baseline":E(this.textBaseline)},!0);if(U.appendChild(this.__document.createTextNode(C)),this.__currentElement=U,this.__applyTransformation(U),this.__applyStyleToCurrentElement(k),this.__fontHref){var W=this.__createElement("a");W.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.__fontHref),W.appendChild(U),U=W}B.appendChild(U)},s.prototype.fillText=function(C,w,D){this.__applyText(C,w,D,"fill")},s.prototype.strokeText=function(C,w,D){this.__applyText(C,w,D,"stroke")},s.prototype.measureText=function(C){return this.__ctx.font=this.font,this.__ctx.measureText(C)},s.prototype.arc=function(C,w,D,k,P,G){if(k!==P){k=k%(2*Math.PI),P=P%(2*Math.PI),k===P&&(P=(P+2*Math.PI-.001*(G?-1:1))%(2*Math.PI));var B=C+D*Math.cos(P),U=w+D*Math.sin(P),W=C+D*Math.cos(k),V=w+D*Math.sin(k),Z=G?0:1,L=0,z=P-k;z<0&&(z+=2*Math.PI),G?L=z>Math.PI?0:1:L=z>Math.PI?1:0;var q=Math.hypot(this.__transformMatrix.a,this.__transformMatrix.b),ne=Math.hypot(this.__transformMatrix.c,this.__transformMatrix.d);this.lineTo(W,V),this.__addPathCommand(g("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:D*q,ry:D*ne,xAxisRotation:0,largeArcFlag:L,sweepFlag:Z,endX:this.__matrixTransform(B,U).x,endY:this.__matrixTransform(B,U).y})),this.__currentPosition={x:B,y:U}}},s.prototype.ellipse=function(C,w,D,k,P,G,B,U){if(G!==B){var W=this.__matrixTransform(C,w);C=W.x,w=W.y;var V=this.__getTransformScale();D=D*V.x,k=k*V.y,P=P+this.__getTransformRotation(),G=G%(2*Math.PI),B=B%(2*Math.PI),G===B&&(B=(B+2*Math.PI-.001*(U?-1:1))%(2*Math.PI));var Z=C+Math.cos(-P)*D*Math.cos(B)+Math.sin(-P)*k*Math.sin(B),L=w-Math.sin(-P)*D*Math.cos(B)+Math.cos(-P)*k*Math.sin(B),z=C+Math.cos(-P)*D*Math.cos(G)+Math.sin(-P)*k*Math.sin(G),q=w-Math.sin(-P)*D*Math.cos(G)+Math.cos(-P)*k*Math.sin(G),ne=U?0:1,te=0,$=B-G;$<0&&($+=2*Math.PI),U?te=$>Math.PI?0:1:te=$>Math.PI?1:0;var fe=this.__transformMatrix;this.resetTransform(),this.lineTo(z,q),this.__transformMatrix=fe,this.__addPathCommand(g("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:D,ry:k,xAxisRotation:P*(180/Math.PI),largeArcFlag:te,sweepFlag:ne,endX:Z,endY:L})),this.__currentPosition={x:Z,y:L}}},s.prototype.clip=function(){var C=this.__closestGroupOrSvg(),w=this.__createElement("clipPath"),D=v(this.__ids),k=this.__createElement("g");this.__applyCurrentDefaultPath(),C.removeChild(this.__currentElement),w.setAttribute("id",D),w.appendChild(this.__currentElement),this.__defs.appendChild(w),C.setAttribute("clip-path",g("url(#{id})",{id:D})),C.appendChild(k),this.__currentElement=k},s.prototype.drawImage=function(){var C=Array.prototype.slice.call(arguments),w=C[0],D,k,P,G,B=0,U=0,W,V,Z,L,z,q,ne,te,$,fe;if(C.length===3)D=C[1],k=C[2],W=w.width,V=w.height,P=W,G=V;else if(C.length===5)D=C[1],k=C[2],P=C[3],G=C[4],W=w.width,V=w.height;else if(C.length===9)B=C[1],U=C[2],W=C[3],V=C[4],D=C[5],k=C[6],P=C[7],G=C[8];else throw new Error("Invalid number of arguments passed to drawImage: "+arguments.length);Z=this.__closestGroupOrSvg(),this.__currentElement;const Q=this.getTransform().translate(D,k);if(w instanceof s){if(L=w.getSvg().cloneNode(!0),L.childNodes&&L.childNodes.length>1){for(z=L.childNodes[0];z.childNodes.length;)fe=z.childNodes[0].getAttribute("id"),this.__ids[fe]=fe,this.__defs.appendChild(z.childNodes[0]);q=L.childNodes[1],q&&(this.__applyTransformation(q,Q),Z.appendChild(q))}}else(w.nodeName==="CANVAS"||w.nodeName==="IMG")&&(ne=this.__createElement("image"),ne.setAttribute("width",P),ne.setAttribute("height",G),ne.setAttribute("preserveAspectRatio","none"),(B||U||W!==w.width||V!==w.height)&&(te=this.__document.createElement("canvas"),te.width=P,te.height=G,$=te.getContext("2d"),$.drawImage(w,B,U,W,V,0,0,P,G),w=te),this.__applyTransformation(ne,Q),ne.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",w.nodeName==="CANVAS"?w.toDataURL():w.getAttribute("src")),Z.appendChild(ne))},s.prototype.createPattern=function(C,w){var D=this.__document.createElementNS("http://www.w3.org/2000/svg","pattern"),k=v(this.__ids),P;return D.setAttribute("id",k),D.setAttribute("width",C.width),D.setAttribute("height",C.height),D.setAttribute("patternUnits","userSpaceOnUse"),C.nodeName==="CANVAS"||C.nodeName==="IMG"?(P=this.__document.createElementNS("http://www.w3.org/2000/svg","image"),P.setAttribute("width",C.width),P.setAttribute("height",C.height),P.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",C.nodeName==="CANVAS"?C.toDataURL():C.getAttribute("src")),D.appendChild(P),this.__defs.appendChild(D)):C instanceof s&&(D.appendChild(C.__root.childNodes[1]),this.__defs.appendChild(D)),new c(D,this)},s.prototype.setLineDash=function(C){C&&C.length>0?this.lineDash=C.join(","):this.lineDash=null},s.prototype.setTransform=function(C,w,D,k,P,G){C instanceof DOMMatrix?this.__transformMatrix=new DOMMatrix([C.a,C.b,C.c,C.d,C.e,C.f]):this.__transformMatrix=new DOMMatrix([C,w,D,k,P,G])},s.prototype.getTransform=function(){let{a:C,b:w,c:D,d:k,e:P,f:G}=this.__transformMatrix;return new DOMMatrix([C,w,D,k,P,G])},s.prototype.resetTransform=function(){this.setTransform(1,0,0,1,0,0)},s.prototype.scale=function(C,w){if(w===void 0&&(w=C),isNaN(C)||isNaN(w)||!isFinite(C)||!isFinite(w))return;let D=this.getTransform().scale(C,w);this.setTransform(D)},s.prototype.rotate=function(C){let w=this.getTransform().multiply(new DOMMatrix([Math.cos(C),Math.sin(C),-Math.sin(C),Math.cos(C),0,0]));this.setTransform(w)},s.prototype.translate=function(C,w){const D=this.getTransform().translate(C,w);this.setTransform(D)},s.prototype.transform=function(C,w,D,k,P,G){const B=this.getTransform().multiply(new DOMMatrix([C,w,D,k,P,G]));this.setTransform(B)},s.prototype.__matrixTransform=function(C,w){return new DOMPoint(C,w).matrixTransform(this.__transformMatrix)},s.prototype.__getTransformScale=function(){return{x:Math.hypot(this.__transformMatrix.a,this.__transformMatrix.b),y:Math.hypot(this.__transformMatrix.c,this.__transformMatrix.d)}},s.prototype.__getTransformRotation=function(){return Math.atan2(this.__transformMatrix.b,this.__transformMatrix.a)},s.prototype.getImageData=function(C,w,D,k,P){return t.getImageData(this.getSvg(),this.width,this.height,C,w,D,k,P)},s.prototype.drawFocusRing=function(){},s.prototype.createImageData=function(){},s.prototype.putImageData=function(){},s.prototype.globalCompositeOperation=function(){},s})();function i(a){this.ctx=new r(a),this.svg=this.ctx.__root;var s=this.svg,u=this,c=document.createElement("div");c.style.display="inline-block",c.appendChild(s),this.wrapper=c,Object.defineProperty(this,"className",{get:function(){return c.getAttribute("class")||""},set:function(h){return c.setAttribute("class",h)}}),Object.defineProperty(this,"tagName",{get:function(){return"CANVAS"},set:function(){}}),["width","height"].forEach(function(h){Object.defineProperty(u,h,{get:function(){return s.getAttribute(h)|0},set:function(g){if(!(isNaN(g)||typeof g>"u"))return u.ctx[h]=g,s.setAttribute(h,g),c[h]=g}})}),["style","id"].forEach(function(h){Object.defineProperty(u,h,{get:function(){return c[h]},set:function(g){if(typeof g<"u")return c[h]=g}})}),["getBoundingClientRect"].forEach(function(h){u[h]=function(){return s[h]()}})}return i.prototype.getContext=function(a){if(a!=="2d")throw new Error("Unsupported type of context for SVGCanvas");return this.ctx},i.prototype.toObjectURL=function(){var a=new XMLSerializer().serializeToString(this.svg),s=new Blob([a],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(s)},i.prototype.toDataURL=function(a,s,u){return t.toDataURL(this.svg,this.width,this.height,a,s,u)},i.prototype.addEventListener=function(){return this.svg.addEventListener.apply(this.svg,arguments)},i.prototype.getElement=function(){return this.wrapper},i.prototype.getAttribute=function(a){return this.wrapper.getAttribute(a)},i.prototype.setAttribute=function(a,s){this.wrapper.setAttribute(a,s)},Lg.Context=r,Lg.Element=i,Lg}var nG=tG();const fA=async n=>new Promise(e=>setTimeout(e,n));async function rG(n,e=!1,{onBefore:t,onAfter:r}={}){const i=n.getLayers()[0];t&&t([n,i]),await fA(200);const a=i.canvas.context._context,s=i.canvas.context._context=new nG.Context({height:n.height(),width:n.width(),ctx:a});n.draw();let u=s.getSerializedSvg();return u=e?new Blob([u],{type:"image/svg+xml;charset=utf-8"}):u,i.canvas.context._context=a,r&&r([n,i]),await fA(200),n.draw(),u}function lO(n){return window.Konva.stages.find(e=>e.attrs.id===n)}function hy(n,e,t,r,i=!0,a=!1){iG();const s=lO(n);s.width(e),s.height(t),s.scale({x:r,y:r}),a&&(s.find("Rect").map(u=>{u.strokeWidth(u.strokeWidth()*r)}),s.find("Line").map(u=>{u.strokeWidth(u.strokeWidth()*r)}),s.find("Circle").map(u=>{u.strokeWidth(u.strokeWidth()*r)}),s.find("Ellipse").map(u=>{u.strokeWidth(u.strokeWidth()*r)})),i||aG()}function iG(){const n=document.getElementsByClassName("konvajs-content");n[0].style.visibility="hidden"}function aG(){const n=document.getElementsByClassName("konvajs-content");n[0].style.visibility="visible"}function sG(n){const e=new DOMParser().parseFromString(n,"image/svg+xml");return e.querySelectorAll("rect").forEach(t=>{const r=(t.getAttribute("fill")||"").trim().toLowerCase(),i=r==="#ffffff"||r==="#fff"||r==="white",a=(t.getAttribute("stroke")||"none").trim().toLowerCase();i&&(a==="none"||a==="")&&t.remove()}),new XMLSerializer().serializeToString(e.documentElement)}async function oG(n){const e=lO(n),t=3;e.find("Transformer").forEach(a=>a.destroy());function r(a){const{r:s,g:u,b:c,a:h}=uO(a.stroke());a.strokeScaleEnabled(!0),a.stroke(`rgb(${s},${u},${c})`),a.strokeWidth(t)}e.find("Rect").map(a=>{r(a)}),e.find("Line").map(a=>{r(a)}),e.find("Circle").map(a=>{r(a)}),e.find("Ellipse").map(a=>{r(a)});let i=await rG(e,!1);return i=sG(i),i=i.replaceAll('"',"'"),i}const lG=[0,2,5,10,20,50],ma={DRAW:"draw",IMAGE:"image",POI:"poi",TARGET:"target"},Ur={CURSOR:"cursor",DELETE:"delete",EDIT:"edit",IMAGE:"image",SHAPE:"shapes",TEXT:"text"},Xt={ARROW:"arrow",CIRCLE:"circle",ELLIPSE:"ellipse",FREEHAND:"freehand",IMAGE:"image",POI:"poi",POLYGON:"polygon",RECTANGLE:"rectangle",SHAPES:"shapes"},uG={fill:"#e53935",stroke:"#ffffff",strokeWidth:2};function cG(n,e){const t=Math.min(n,e);return!Number.isFinite(t)||t<=0?10:Math.min(40,Math.max(6,t*.015))}function C5(n){return Object.values(Xt).find(e=>e===n)}const uO=(n="rgba(255,255,255,0.5)")=>window.Konva.Util.colorToRGBA(n),dG=(n={r:255,g:255,b:255,a:.5})=>`rgba(${n.r},${n.g},${n.b},${n.a})`,er={IIIF_TYPE:"iiif",JOURNEY_TYPE:"journey",MULTIPLE_BODY_TYPE:"multiple_body",POI_TYPE:"poi",TAGGING_TYPE:"tagging",TEXT_TYPE:"text"},hA={expert:er.IIIF_TYPE,journey:er.JOURNEY_TYPE,note:er.MULTIPLE_BODY_TYPE,poi:er.POI_TYPE,tag:er.TAGGING_TYPE},Bi={AUDIO:"Audio",IMAGE:"Image",UNKNOWN:"Unknown",VIDEO:"Video"},fG={activeTool:Ur.SHAPE,closedMode:"closed",fillColor:"rgba(83,162, 235, 0.5)",image:{id:""},imageEvent:null,strokeColor:"rgba(20,82,168,1)",strokeWidth:2},oo={activeTool:Ur.EDIT,closedMode:"closed",fillColor:"rgba(100,100,100, 0)",image:{id:null},imageEvent:null,strokeColor:"rgba(255,0, 0, 0.5)",strokeWidth:5},cO="target",Qv="layer";function pA(){return new Date().toLocaleString([navigator.language],{dateStyle:"short",timeStyle:"short"})}async function hG(n,e,t,r){r?.maeData?r.id?(r.lastSavedDate=pA(),r.lastEditor=e.getStorageAdapterUser(),console.log("Annotation to update",r),e.update(r).then(i=>{t(n,e.annotationPageId,i)})):(r.id=`${n}/annotation/${vs()}`,r.creationDate=pA(),r.creator=e.getStorageAdapterUser(),r?.maeData?.manifestNetwork&&(r.id=`${r.id}#${r.maeData.manifestNetwork}`),console.log("Annotation to create",r),e.create(r).then(i=>{t(n,e.annotationPageId,i)})):r.id?e.update(r).then(i=>{t(n,e.annotationPageId,i)}):(r.id=`${n}/annotation/${vs()}`,e.create(r).then(i=>{t(n,e.annotationPageId,i)}))}const dO=xs.styled(l5)(({theme:n})=>({"&:first-of-type":{borderRadius:n.shape.borderRadius},"&:not(:first-of-type)":{borderRadius:n.shape.borderRadius},border:"none",margin:n.spacing(.5),"& .MuiToggleButton-root":{borderRadius:n.shape.borderRadius,color:n.palette.text.primary,transition:"transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease","&:hover":{transform:"translateY(-1px)",boxShadow:n.shadows[1]}},"& .MuiToggleButton-root.Mui-selected":{backgroundColor:n.palette.primary.main,color:n.palette.primary.contrastText,boxShadow:n.shadows[3],transform:"scale(1.03)","&:hover":{backgroundColor:n.palette.primary.dark}}}));function pG(n){return!1}const gG=n=>n.strokeColor===oo.strokeColor&&n.fillColor===oo.fillColor,mG=n=>n.type===Xt.RECTANGLE,vG=n=>{if(n.length!==1)return!1;const e=n[0];return mG(e)&&(!e?.rotation||e.rotation===0)&&gG(e)},yG=(n,e)=>{console.info("Implement target as string on fullSizeCanvas.");const t=n.target;return`${e}#${t.tend?`xywh=${t.fullCanvaXYWH}&t=${t.tstart},${t.tend}`:`xywh=${t.fullCanvaXYWH}`}`},bG=(n,e,t)=>{console.info("Implement target as string with one shape (rectangle)");let{x:r,y:i,width:a,height:s,scaleX:u,scaleY:c}=t;return a<0&&(a=-a,r-=a),s<0&&(s=-s,i-=s),`${e}#${n.tend?`xywh=${r},${i},${a*u},${s*c}&t=${n.tstart},${n.tend}`:`xywh=${r},${i},${a*u},${s*c}`}`},xG=(n,e)=>{const t=`${n.tend?`t=${n.tstart},${n.tend}`:""}`;return{selector:[{type:"SvgSelector",value:n.svg},{type:"FragmentSelector",value:`${e}#${t}`}],source:e}},SG=(n,e,t=null,r=null)=>{const i=n.target,{templateType:a}=n;switch(a){case er.IIIF_TYPE:return i;case er.TAGGING_TYPE:case er.TEXT_TYPE:case er.MULTIPLE_BODY_TYPE:case er.POI_TYPE:return vG(i.drawingState.shapes)?(console.info("Simple target detected"),bG(i,e,i.drawingState.shapes[0])):(console.info("Implement target as SVG/Fragment with shapes"),xG(i,e));default:return yG(n,e)}},CG=n=>{const e={purpose:"describing",type:"TextualBody",value:""},t=s=>{const u=structuredClone(e);return u.value=s.value||"",u},r=s=>{const u=structuredClone(e);return u.value=s||"",u};let i="",a={};return n["dbf:kind"]==="POI"?i=er.POI_TYPE:n["dbf:kind"]==="Journey"?i=er.JOURNEY_TYPE:n.motivation==="tagging"||Array.isArray(n.motivation)&&n.motivation.includes("tagging")?i=er.TAGGING_TYPE:(i=er.MULTIPLE_BODY_TYPE,n.bodyValue?a=r(n.bodyValue):n.body&&(a=Array.isArray(n.body)?n.body.map(t):t(n.body))),[i,a]},EG=n=>{const e=n.documentElement,t=document.createElement("div");t.style.position="absolute",t.style.left="-99999px",t.style.width="0",t.style.height="0",t.style.overflow="hidden",t.style.pointerEvents="none",document.body.appendChild(t);const r=document.importNode(e,!0),i="http://www.w3.org/2000/svg",a=document.createElementNS(i,"svg");for(const c of r.attributes||[])a.setAttribute(c.name,c.value);const s=document.createElementNS(i,"g");for(;r.firstChild;)s.appendChild(r.firstChild);a.appendChild(s),t.appendChild(a),t.offsetWidth;const u=s.getBBox();return document.body.removeChild(t),u},_G=({x:n,y:e,w:t,h:r,fullW:i=void 0,fullH:a=void 0})=>{n=parseFloat(n),e=parseFloat(e),t=parseFloat(t),r=parseFloat(r),a?a=parseFloat(a):i&&(i=parseFloat(i));const s=i&&a?`width='${i}' height='${a}'`:"";if([n,e,t,r].some(u=>typeof u!="number"))throw new Error(`xywhToSvg: x,y,w,h must be floats (got x=${n}, y=${e}, w=${t}, h=${r})`);return`<svg
9
+ `)}componentDidMount(){if(this.ref.current===null)return;const U=this.makeOptions();a(e).create(this.ref.current,U)}componentDidUpdate(U){U.disabled!==this.props.disabled&&this.sortable&&this.sortable.option("disabled",this.props.disabled)}render(){const{tag:U,style:W,className:V,id:Z}=this.props,L={style:W,className:V,id:Z},z=!U||U===null?"div":U;return(0,r.createElement)(z,{ref:this.ref,...L},this.getChildren())}getChildren(){const{children:U,dataIdAttr:W,selectedClass:V="sortable-selected",chosenClass:Z="sortable-chosen",dragClass:L="sortable-drag",fallbackClass:z="sortable-falback",ghostClass:q="sortable-ghost",swapClass:ne="sortable-swap-highlight",filter:te="sortable-filter",list:$}=this.props;if(!U||U==null)return null;const fe=W||"data-id";return r.Children.map(U,(Q,oe)=>{if(Q===void 0)return;const se=$[oe]||{},{className:be}=Q.props,pe=typeof te=="string"&&{[te.replace(".","")]:!!se.filtered},Oe=a(t)(be,{[V]:se.selected,[Z]:se.chosen,...pe});return(0,r.cloneElement)(Q,{[fe]:Q.key,className:Oe})})}get sortable(){const U=this.ref.current;if(U===null)return null;const W=Object.keys(U).find(V=>V.includes("Sortable"));return W?U[W]:null}makeOptions(){const U=["onAdd","onChoose","onDeselect","onEnd","onRemove","onSelect","onSpill","onStart","onUnchoose","onUpdate"],W=["onChange","onClone","onFilter","onSort"],V=D(this.props);return U.forEach(L=>V[L]=this.prepareOnHandlerPropAndDOM(L)),W.forEach(L=>V[L]=this.prepareOnHandlerProp(L)),{...V,onMove:(L,z)=>{const{onMove:q}=this.props,ne=L.willInsertAfter||-1;if(!q)return ne;const te=q(L,z,this.sortable,k);return typeof te>"u"?!1:te}}}prepareOnHandlerPropAndDOM(U){return W=>{this.callOnHandlerProp(W,U),this[U](W)}}prepareOnHandlerProp(U){return W=>{this.callOnHandlerProp(W,U)}}callOnHandlerProp(U,W){const V=this.props[W];V&&V(U,this.sortable,k)}onAdd(U){const{list:W,setList:V,clone:Z}=this.props,L=[...k.dragging.props.list],z=b(U,L);g(z);const q=I(z,W,U,Z).map(ne=>Object.assign(ne,{selected:!1}));V(q,this.sortable,k)}onRemove(U){const{list:W,setList:V}=this.props,Z=C(U),L=b(U,W);v(L);let z=[...W];if(U.pullMode!=="clone")z=E(L,z);else{let q=L;switch(Z){case"multidrag":q=L.map((ne,te)=>({...ne,element:U.clones[te]}));break;case"normal":q=L.map(ne=>({...ne,element:U.clone}));break;default:a(i)(!0,`mode "${Z}" cannot clone. Please remove "props.clone" from <ReactSortable/> when using the "${Z}" plugin`)}g(q),L.forEach(ne=>{const te=ne.oldIndex,$=this.props.clone(ne.item,U);z.splice(te,1,$)})}z=z.map(q=>Object.assign(q,{selected:!1})),V(z,this.sortable,k)}onUpdate(U){const{list:W,setList:V}=this.props,Z=b(U,W);g(Z),v(Z);const L=S(Z,W);return V(L,this.sortable,k)}onStart(){k.dragging=this}onEnd(){k.dragging=null}onChoose(U){const{list:W,setList:V}=this.props,Z=W.map((L,z)=>{let q=L;return z===U.oldIndex&&(q=Object.assign(L,{chosen:!0})),q});V(Z,this.sortable,k)}onUnchoose(U){const{list:W,setList:V}=this.props,Z=W.map((L,z)=>{let q=L;return z===U.oldIndex&&(q=Object.assign(q,{chosen:!1})),q});V(Z,this.sortable,k)}onSpill(U){const{removeOnSpill:W,revertOnSpill:V}=this.props;W&&!V&&c(U.item)}onSelect(U){const{list:W,setList:V}=this.props,Z=W.map(L=>Object.assign(L,{selected:!1}));U.newIndicies.forEach(L=>{const z=L.index;if(z===-1){console.log(`"${U.type}" had indice of "${L.index}", which is probably -1 and doesn't usually happen here.`),console.log(U);return}Z[z].selected=!0}),V(Z,this.sortable,k)}onDeselect(U){const{list:W,setList:V}=this.props,Z=W.map(L=>Object.assign(L,{selected:!1}));U.newIndicies.forEach(L=>{const z=L.index;z!==-1&&(Z[z].selected=!0)}),V(Z,this.sortable,k)}}var G={};u(n.exports,G)})(xx)),xx.exports}var lA=LB();const uA=(n,e)=>n.order===e.order?n.id.localeCompare(e.id):n.order===null||n.order===void 0?1:e.order===null||e.order===void 0?-1:n.order-e.order,kB=(n=[])=>{const e=n.filter(a=>a["dbf:kind"]==="Journey"),t={},r=[];n.filter(a=>a["dbf:kind"]!=="Journey").forEach(a=>{const s=a["dbf:journey"];s?.id?(t[s.id]??=[]).push(a):r.push(a)}),Object.values(t).forEach(a=>a.sort((s,u)=>uA({id:s.id,order:s["dbf:journey"]?.order},{id:u.id,order:u["dbf:journey"]?.order})));const i=[...e.map(a=>({id:a.id,item:a,kind:"Journey",order:a["dbf:order"],pois:t[a.id]??[]})),...r.map(a=>({id:a.id,item:a,kind:"POI",order:a["dbf:order"]}))];return i.sort(uA),i},PB=(n,e)=>{const t=(Array.isArray(n?.body)?n.body:[]).filter(i=>i?.purpose==="identifying"&&i?.type==="TextualBody");return((t.find(i=>i.language===e)??t[0])?.value??"").trim()},jB=(n,e)=>{const t={...n,"dbf:order":e};return n["dbf:kind"]==="POI"&&n["dbf:journey"]&&(t["dbf:journey"]=null),t},FB=(n,e,t)=>({...n,"dbf:journey":{id:e,order:t}});function S5({canvasId:n,deselectAnnotation:e,hoverAnnotation:t,hoveredAnnotationIds:r=[],index:i,items:a=[],label:s,receiveAnnotation:u,selectAnnotation:c,selectedAnnotationId:h,storageAdapter:g,totalSize:v,windowId:b}){const{i18n:S,t:E}=Bs.useTranslation(),[I,C]=N.useState(a);N.useEffect(()=>{C(a)},[a]);const w=N.useMemo(()=>kB(I),[I]),D=N.useMemo(()=>w.map(V=>V.item),[w]),k=N.useCallback(V=>{const Z=g(n);return Z.update(V).then(L=>{u(n,Z.annotationPageId,L)})},[g,n,u]),P=N.useCallback(V=>{C(Z=>{const L=new Map(Z.map(z=>[z.id,z]));return V.forEach(z=>{L.set(z.id,z)}),Array.from(L.values())}),V.reduce((Z,L)=>Z.then(()=>k(L)),Promise.resolve())},[k]),G=N.useCallback(V=>{const Z=V.map((L,z)=>jB(L,z));P(Z)},[P]),B=N.useCallback((V,Z)=>{const L=Z.map((z,q)=>FB(z,V,q));P(L)},[P]),U=N.useCallback(V=>{window.getSelection()?.toString()||(h===V?e(b,V):c(b,V))},[b,e,c,h]),W=V=>{const Z=PB(V,S.language)||"—",L=r.includes(V.id)||h===V.id;return O.jsx(g5,{annotationid:V.id,"data-kind":V["dbf:kind"],onClick:()=>U(V.id),onMouseEnter:()=>t(b,[V.id]),onMouseLeave:()=>t(b,[]),style:{backgroundColor:L?"rgba(0, 0, 0, 0.04)":void 0,cursor:"pointer",listStyle:"none",padding:"8px 16px"},children:O.jsx(Hn,{variant:"body2",children:Z})},V.id)};return D.length===0?null:O.jsxs(O.Fragment,{children:[O.jsx(Hn,{sx:{paddingLeft:2,paddingRight:1,paddingTop:2},variant:"overline",children:E("annotationCanvasLabel",{context:`${i+1}/${v}`,label:s})}),O.jsx(lA.ReactSortable,{animation:150,forceFallback:!0,group:{name:"maps-annotation-list",put:!0},list:D,setList:G,tag:"ul",style:{listStyle:"none",margin:0,padding:0},children:w.map(V=>V.kind==="Journey"?O.jsxs("li",{style:{listStyle:"none"},"data-kind":"Journey",children:[W(V.item),O.jsx(lA.ReactSortable,{animation:150,forceFallback:!0,group:{name:"maps-annotation-list",put:(Z,L,z)=>z.getAttribute("data-kind")==="POI"},list:V.pois,setList:Z=>B(V.id,Z),tag:"ul",style:{listStyle:"none",margin:0,paddingInlineStart:24},children:V.pois.map(Z=>O.jsx("li",{style:{listStyle:"none"},"data-kind":"POI",children:W(Z)},Z.id))})]},V.id):O.jsx("li",{style:{listStyle:"none"},"data-kind":"POI",children:W(V.item)},V.id))})]})}S5.propTypes={canvasId:T.string.isRequired,deselectAnnotation:T.func.isRequired,hoverAnnotation:T.func.isRequired,hoveredAnnotationIds:T.arrayOf(T.string),index:T.number.isRequired,items:T.arrayOf(T.object),label:T.string.isRequired,receiveAnnotation:T.func.isRequired,selectAnnotation:T.func.isRequired,selectedAnnotationId:T.string,storageAdapter:T.func.isRequired,totalSize:T.number.isRequired,windowId:T.string.isRequired};S5.defaultProps={hoveredAnnotationIds:[],items:[],selectedAnnotationId:void 0};const v_=n=>{if(!n)return!1;const e=getComputedStyle(n),t=e.overflowY||e.overflow||"";return/(auto|scroll|overlay)/.test(t)&&n.scrollHeight>n.clientHeight},BB=n=>{let e=n?.parentElement||null;for(;e;){if(v_(e))return e;e=e.parentElement}return null},GB=()=>document.scrollingElement||document.documentElement;function HB(n,e,t){const r=n.getBoundingClientRect(),i=e.getBoundingClientRect(),a=i.top-r.top+n.scrollTop,s=i.bottom-r.top+n.scrollTop,u=n.scrollTop+t,c=n.scrollTop+n.clientHeight,h=a<u,g=s>c;return!h&&!g?null:h?a-t:Math.max(s-n.clientHeight,a-t)}function zB(n,e){const t=n.getBoundingClientRect(),r=t.top+window.scrollY,i=t.bottom+window.scrollY,a=window.scrollY+e,s=window.scrollY+window.innerHeight,u=r<a,c=i>s;return!u&&!c?null:u?r-e:Math.max(i-window.innerHeight,r-e)}const qB=(n,e,t)=>new Promise(r=>{const i="smooth";requestAnimationFrame(()=>{requestAnimationFrame(()=>{let s=e.current;if(v_(s)||(s=BB(n)),v_(s)||(s=GB()),s===document.body||s===document.documentElement||s===document.scrollingElement){const g=zB(n,96);if(g==null)return r(!0);const v=window.scrollY;window.scrollTo({behavior:i,top:g}),setTimeout(()=>{const b=window.scrollY;r(Math.abs(b-v)>.5)},t);return}const c=HB(s,n,96);if(c==null)return r(!0);const h=s.scrollTop;typeof s.scrollTo=="function"&&s.scrollTo({behavior:i,top:c}),setTimeout(()=>{const g=s.scrollTop;r(Math.abs(g-h)>.5)},t)})})}),UB=async(n,e)=>{for(let i=0;i<=3&&!await qB(n,e,24);i++)i<3&&await new Promise(s=>{setTimeout(s,24)})},aO={defaultForm:{default:null,type:"string"},defaultTags:{default:[],type:"array"},editMode:{default:!1,type:"boolean"}},VB={array:n=>n?n.split(",").map(e=>e.trim()).filter(Boolean):[],boolean:n=>n==="true",number:n=>{const e=Number(n);return Number.isNaN(e)?null:e},string:n=>n||null};let $v=null;function WB(){if(!$v){const n=new URLSearchParams(window.location.search);$v={},Object.entries(aO).forEach(([e,t])=>{const r=n.get(e);r!==null&&($v[e]=VB[t.type](r))})}return $v}function Um(n){const e=WB(),t={};return Object.entries(aO).forEach(([r,i])=>{r in e?t[r]=e[r]:n?.annotation?.[r]!==void 0?t[r]=n.annotation[r]:t[r]=i.default}),t}function XB(n){return N.useMemo(()=>Um(n),[n])}function sO({addCompanionWindow:n,annotationsOnCanvases:e={},canvases:t=[],config:r,deselectAnnotation:i,highlightAllAnnotations:a,receiveAnnotation:s,switchToSingleCanvasView:u,TargetComponent:c,targetProps:h,updateWindow:g,windowViewType:v,annotationEditCompanionWindowIsOpened:b}){const[S,E]=N.useState(!1),{t:I}=Bs.useTranslation(),C=N.useRef(null),w=N.useRef(null);N.useEffect(()=>{const L=h?.selectedAnnotationId;if(!L)return;const z=C.current?.querySelector(`li[annotationid="${L}"]`)||C.current?.querySelector("li.MuiMenuItem-root.Mui-selected");z&&UB(z,w)},[h?.selectedAnnotationId]);const D=N.useCallback(()=>{E(L=>!L)});N.useEffect(()=>{ax.isInitialized&&r.translations&&(Object.keys(r.translations).forEach(L=>{ax.addResourceBundle(L,"translation",r.translations[L],!0,!0)}),r.language&&ax.changeLanguage(r.language))},[r.translations,r.language]);const{editMode:k}=XB(r);N.useEffect(()=>{k&&!a&&g({highlightAllAnnotations:!0})},[k,a,g]);const P=N.useCallback(L=>L?t.some(z=>{const q=e[z.id];return q?Object.values(q).some(ne=>ne.json&&ne.json.items?ne.json.items.some(te=>te.id===L&&te.maeData):!1):!1}):!1,[t,e]),G=N.useRef(b);N.useEffect(()=>{const L=!G.current,z=b;G.current=b,k&&L&&z&&i()},[k,b,i]);const B=N.useRef(null);N.useEffect(()=>{if(!k)return;const L=h?.selectedAnnotationId;L!==B.current&&(B.current=L,L&&b&&P(L)&&n("annotationCreation",{annotationid:L,position:"right"}))},[k,h?.selectedAnnotationId,b,P,n]);const U={containerRef:w,...h,listContainerComponent:g5},W=N.useMemo(()=>{const L=h?.canvasId;return!L||!e[L]?[]:Object.values(e[L]).flatMap(z=>z?.json?.items??[])},[h?.canvasId,e]),V=W.some(L=>L["dbf:kind"]==="POI"||L["dbf:kind"]==="Journey"),Z=N.useMemo(()=>({addCompanionWindow:n,annotationEditCompanionWindowIsOpened:b,annotationsOnCanvases:e,canvases:t,config:r,receiveAnnotation:s,storageAdapter:r.annotation.adapter,t:I,toggleSingleCanvasDialogOpen:D,windowId:h.windowId,windowViewType:v}),[n,b,e,t,r,s,I,D,h.windowId,v]);return O.jsxs(q7.Provider,{value:Z,children:[O.jsx("div",{ref:C,style:{height:"100%",position:"relative"},children:V?O.jsx(S5,{canvasId:h.canvasId,deselectAnnotation:h.deselectAnnotation,hoverAnnotation:h.hoverAnnotation,hoveredAnnotationIds:h.hoveredAnnotationIds,index:h.index,items:W,label:h.label,receiveAnnotation:s,selectAnnotation:h.selectAnnotation,selectedAnnotationId:h.selectedAnnotationId,storageAdapter:r.annotation.adapter,totalSize:h.totalSize,windowId:h.windowId}):O.jsx(c,{...U})}),v!=="single"&&O.jsx(c5,{handleClose:D,open:S,switchToSingleCanvasView:u})]})}sO.propTypes={addCompanionWindow:T.func.isRequired,annotationEditCompanionWindowIsOpened:T.bool.isRequired,annotationsOnCanvases:T.shape({id:T.string,isFetching:T.bool,json:T.shape({id:T.string,items:T.arrayOf(T.shape({body:T.shape({format:T.string,id:T.string,value:T.string}),drawingState:T.string,id:T.string,manifestNetwork:T.string,motivation:T.string,target:T.string,type:T.string})),type:T.string})}).isRequired,canvases:T.arrayOf(T.shape({id:T.string,index:T.number})).isRequired,config:T.shape({annotation:T.shape({adapter:T.func,editMode:T.bool}),language:T.string,translations:T.objectOf(T.object)}).isRequired,deselectAnnotation:T.func.isRequired,highlightAllAnnotations:T.bool.isRequired,receiveAnnotation:T.func.isRequired,switchToSingleCanvasView:T.func.isRequired,t:T.func.isRequired,TargetComponent:T.oneOfType([T.func,T.node]).isRequired,targetProps:T.object.isRequired,updateWindow:T.func.isRequired,windowViewType:T.string.isRequired};function YB(n,{targetProps:{windowId:e}}){const t=Gt.getVisibleCanvases(n,{windowId:e}),r={},i=Gt.getCompanionWindowsForContent(n,{content:"annotationCreation",windowId:e}),a=Object.keys(i).length===0;return t.forEach(s=>{const u=n.annotations[s.id];u&&(r[s.id]=u)}),{annotationEditCompanionWindowIsOpened:a,annotationsOnCanvases:r,canvases:t,config:{...n.config,translations:d5},highlightAllAnnotations:Gt.getWindow(n,{windowId:e}).highlightAllAnnotations,windowViewType:Gt.getWindowViewType(n,{windowId:e})}}const ZB=(n,e)=>({addCompanionWindow:(t,r)=>n(Gt.addCompanionWindow(e.targetProps.windowId,{content:t,...r})),deselectAnnotation:()=>n(Gt.deselectAnnotation(e.targetProps.windowId)),receiveAnnotation:(t,r,i)=>n(Gt.receiveAnnotation(t,r,i)),switchToSingleCanvasView:()=>n(Gt.setWindowViewType(e.targetProps.windowId,"single")),updateWindow:t=>n(Gt.updateWindow(e.targetProps.windowId,t))}),oO={component:sO,mapDispatchToProps:ZB,mapStateToProps:YB,mode:"wrap",target:"CanvasAnnotations"},Ia=[];for(let n=0;n<256;++n)Ia.push((n+256).toString(16).slice(1));function JB(n,e=0){return(Ia[n[e+0]]+Ia[n[e+1]]+Ia[n[e+2]]+Ia[n[e+3]]+"-"+Ia[n[e+4]]+Ia[n[e+5]]+"-"+Ia[n[e+6]]+Ia[n[e+7]]+"-"+Ia[n[e+8]]+Ia[n[e+9]]+"-"+Ia[n[e+10]]+Ia[n[e+11]]+Ia[n[e+12]]+Ia[n[e+13]]+Ia[n[e+14]]+Ia[n[e+15]]).toLowerCase()}let Mx;const KB=new Uint8Array(16);function $B(){if(!Mx){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Mx=crypto.getRandomValues.bind(crypto)}return Mx(KB)}const QB=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cA={randomUUID:QB};function eG(n,e,t){n=n||{};const r=n.random??n.rng?.()??$B();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,JB(r)}function vs(n,e,t){return cA.randomUUID&&!n?cA.randomUUID():eG(n)}var Lg={},dA;function tG(){if(dA)return Lg;dA=1,Object.defineProperty(Lg,"__esModule",{value:!0});function n(a){return!a||typeof a=="string"?a:a+""}class e{async svg2canvas(s,u,c){const h=await new Promise(b=>{var S=new Image;S.onload=function(){b(S)},S.src=s});var g=document.createElement("canvas");return g.width=u,g.height=c,g.getContext("2d").drawImage(h,0,0),g}toDataURL(s,u,c,h,g,v){var b=new XMLSerializer().serializeToString(s),S=document.documentMode;if(S){var E=/xmlns="http:\/\/www\.w3\.org\/2000\/svg".+xmlns="http:\/\/www\.w3\.org\/2000\/svg/gi;E.test(b)&&(b=b.replace('xmlns="http://www.w3.org/2000/svg','xmlns:xlink="http://www.w3.org/1999/xlink'))}v||(v={});var I="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(b);if(h==="image/svg+xml"||!h)return v.async?Promise.resolve(I):I;if(h==="image/jpeg"||h==="image/png"){if(!v.async)throw new Error("svgcanvas: options.async must be set to true if type is image/jpeg | image/png");return(async()=>{const C=await this.svg2canvas(I,u,c),w=C.toDataURL(h,g);return C.remove(),w})()}throw new Error("svgcanvas: Unknown type for toDataURL, please use image/jpeg | image/png | image/svg+xml.")}getImageData(s,u,c,h,g,v,b,S){if(S||(S={}),!S.async)throw new Error("svgcanvas: options.async must be set to true for getImageData");const E=this.toDataURL(s,u,c,"image/svg+xml");return(async()=>{const I=await this.svg2canvas(E,u,c),w=I.getContext("2d").getImageData(h,g,v,b);return I.remove(),w})()}}const t=new e;var r=(function(){var a,s,u,c,h;function g(C,w){var D=Object.keys(w),k;for(k=0;k<D.length;k++)C=C.replace(new RegExp("\\{"+D[k]+"\\}","gi"),w[D[k]]);return C}function v(C){var w,D,k;if(!C)throw new Error("cannot create a random attribute name for an undefined object");w="ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",D="";do for(D="",k=0;k<12;k++)D+=w[Math.floor(Math.random()*w.length)];while(C[D]);return D}function b(C,w){var D,k,P={},G;for(C=C.split(","),w=w||10,D=0;D<C.length;D+=2)k="&"+C[D+1]+";",G=parseInt(C[D],w),P[k]="&#"+G+";";return P["\\xa0"]="&#160;",P}function S(C){var w={left:"start",right:"end",center:"middle",start:"start",end:"end"};return w[C]||w.start}function E(C){var w={alphabetic:"alphabetic",hanging:"hanging",top:"text-before-edge",bottom:"text-after-edge",middle:"central"};return w[C]||w.alphabetic}h=b("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32),a={strokeStyle:{svgAttr:"stroke",canvas:"#000000",svg:"none",apply:"stroke"},fillStyle:{svgAttr:"fill",canvas:"#000000",svg:null,apply:"fill"},lineCap:{svgAttr:"stroke-linecap",canvas:"butt",svg:"butt",apply:"stroke"},lineJoin:{svgAttr:"stroke-linejoin",canvas:"miter",svg:"miter",apply:"stroke"},miterLimit:{svgAttr:"stroke-miterlimit",canvas:10,svg:4,apply:"stroke"},lineWidth:{svgAttr:"stroke-width",canvas:1,svg:1,apply:"stroke"},globalAlpha:{svgAttr:"opacity",canvas:1,svg:1,apply:"fill stroke"},font:{canvas:"10px sans-serif"},shadowColor:{canvas:"#000000"},shadowOffsetX:{canvas:0},shadowOffsetY:{canvas:0},shadowBlur:{canvas:0},textAlign:{canvas:"start"},textBaseline:{canvas:"alphabetic"},lineDash:{svgAttr:"stroke-dasharray",canvas:[],svg:null,apply:"stroke"}},u=function(C,w){this.__root=C,this.__ctx=w},u.prototype.addColorStop=function(C,w){var D=this.__ctx.__createElement("stop"),k,P;D.setAttribute("offset",C),n(w).indexOf("rgba")!==-1?(k=/rgba\(\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi,P=k.exec(w),D.setAttribute("stop-color",g("rgb({r},{g},{b})",{r:P[1],g:P[2],b:P[3]})),D.setAttribute("stop-opacity",P[4])):D.setAttribute("stop-color",n(w)),this.__root.appendChild(D)},c=function(C,w){this.__root=C,this.__ctx=w},s=function(C){var w={width:500,height:500,enableMirroring:!1},D;if(arguments.length>1?(D=w,D.width=arguments[0],D.height=arguments[1]):C?D=C:D=w,!(this instanceof s))return new s(D);this.width=D.width||w.width,this.height=D.height||w.height,this.enableMirroring=D.enableMirroring!==void 0?D.enableMirroring:w.enableMirroring,this.canvas=this,this.__document=D.document||document,D.ctx?this.__ctx=D.ctx:(this.__canvas=this.__document.createElement("canvas"),this.__ctx=this.__canvas.getContext("2d")),this.__setDefaultStyles(),this.__styleStack=[this.__getStyleState()],this.__groupStack=[],this.__root=this.__document.createElementNS("http://www.w3.org/2000/svg","svg"),this.__root.setAttribute("version",1.1),this.__root.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.__root.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),this.__root.setAttribute("width",this.width),this.__root.setAttribute("height",this.height),this.__ids={},this.__defs=this.__document.createElementNS("http://www.w3.org/2000/svg","defs"),this.__root.appendChild(this.__defs),this.__currentElement=this.__document.createElementNS("http://www.w3.org/2000/svg","g"),this.__root.appendChild(this.__currentElement),this.resetTransform(),this.__options=D,this.__id=Math.random().toString(16).substring(2,8),this.__debug("new",C)},s.prototype.__debug=function(...C){this.__options.debug&&console.debug(`svgcanvas#${this.__id}:`,...C)},s.prototype.__createElement=function(C,w,D){typeof w>"u"&&(w={});var k=this.__document.createElementNS("http://www.w3.org/2000/svg",C),P=Object.keys(w),G,B;for(D&&(k.setAttribute("fill","none"),k.setAttribute("stroke","none")),G=0;G<P.length;G++)B=P[G],k.setAttribute(B,w[B]);return k},s.prototype.__setDefaultStyles=function(){var C=Object.keys(a),w,D;for(w=0;w<C.length;w++)D=C[w],this[D]=a[D].canvas},s.prototype.__applyStyleState=function(C){var w=Object.keys(C),D,k;for(D=0;D<w.length;D++)k=w[D],this[k]=C[k]},s.prototype.__getStyleState=function(){var C,w={},D=Object.keys(a),k;for(C=0;C<D.length;C++)k=D[C],w[k]=this[k];return w},s.prototype.__applyTransformation=function(C,w){const{a:D,b:k,c:P,d:G,e:B,f:U}=w||this.getTransform();C.setAttribute("transform",`matrix(${D} ${k} ${P} ${G} ${B} ${U})`)},s.prototype.__applyStyleToCurrentElement=function(C){var w=this.__currentElement,D=this.__currentElementsToStyle;D&&(w.setAttribute(C,""),w=D.element,D.children.forEach(function($){$.setAttribute(C,"")}));var k=Object.keys(a),P,G,B,U,W,V,Z,L;for(P=0;P<k.length;P++)if(G=a[k[P]],B=this[k[P]],G.apply){if(B instanceof c){if(B.__ctx)for(Z=0;Z<B.__ctx.__defs.childNodes.length;Z++)L=B.__ctx.__defs.childNodes[Z],V=L.getAttribute("id"),this.__ids[V]=V,this.__defs.appendChild(L);w.setAttribute(G.apply,g("url(#{id})",{id:B.__root.getAttribute("id")}))}else if(B instanceof u)w.setAttribute(G.apply,g("url(#{id})",{id:B.__root.getAttribute("id")}));else if(G.apply.indexOf(C)!==-1&&G.svg!==B)if((G.svgAttr==="stroke"||G.svgAttr==="fill")&&B&&B.indexOf("rgba")!==-1){U=/rgba\(\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi,W=U.exec(B),w.setAttribute(G.svgAttr,g("rgb({r},{g},{b})",{r:W[1],g:W[2],b:W[3]}));var z=W[4],q=this.globalAlpha;q!=null&&(z*=q),w.setAttribute(G.svgAttr+"-opacity",z)}else{var ne=G.svgAttr;if(k[P]==="globalAlpha"){if(ne=C+"-"+G.svgAttr,w.getAttribute(ne))continue}else if(k[P]==="lineWidth"){var te=this.__getTransformScale();B=B*Math.max(te.x,te.y)}w.setAttribute(ne,B)}}},s.prototype.__closestGroupOrSvg=function(C){return C=C||this.__currentElement,C.nodeName==="g"||C.nodeName==="svg"?C:this.__closestGroupOrSvg(C.parentNode)},s.prototype.getSerializedSvg=function(C){var w=new XMLSerializer().serializeToString(this.__root),D,k,P,G,B,U;if(U=/xmlns="http:\/\/www\.w3\.org\/2000\/svg".+xmlns="http:\/\/www\.w3\.org\/2000\/svg/gi,U.test(w)&&(w=w.replace('xmlns="http://www.w3.org/2000/svg','xmlns:xlink="http://www.w3.org/1999/xlink')),C)for(D=Object.keys(h),k=0;k<D.length;k++)P=D[k],G=h[P],B=new RegExp(P,"gi"),B.test(w)&&(w=w.replace(B,G));return w},s.prototype.getSvg=function(){return this.__root},s.prototype.save=function(){var C=this.__createElement("g"),w=this.__closestGroupOrSvg();this.__groupStack.push(w),w.appendChild(C),this.__currentElement=C;const D=this.__getStyleState();this.__debug("save style",D),this.__styleStack.push(D),this.__transformMatrixStack||(this.__transformMatrixStack=[]),this.__transformMatrixStack.push(this.getTransform())},s.prototype.restore=function(){this.__currentElement=this.__groupStack.pop(),this.__currentElementsToStyle=null,this.__currentElement||(this.__currentElement=this.__root.childNodes[1]);var C=this.__styleStack.pop();this.__debug("restore style",C),this.__applyStyleState(C),this.__transformMatrixStack&&this.__transformMatrixStack.length>0&&this.setTransform(this.__transformMatrixStack.pop())},s.prototype.beginPath=function(){var C,w;this.__currentDefaultPath="",this.__currentPosition={},C=this.__createElement("path",{},!0),w=this.__closestGroupOrSvg(),w.appendChild(C),this.__currentElement=C},s.prototype.__applyCurrentDefaultPath=function(){var C=this.__currentElement;C.nodeName==="path"?C.setAttribute("d",this.__currentDefaultPath):console.error("Attempted to apply path command to node",C.nodeName)},s.prototype.__addPathCommand=function(C){this.__currentDefaultPath+=" ",this.__currentDefaultPath+=C},s.prototype.moveTo=function(C,w){this.__currentElement.nodeName!=="path"&&this.beginPath(),this.__currentPosition={x:C,y:w},this.__addPathCommand(g("M {x} {y}",{x:this.__matrixTransform(C,w).x,y:this.__matrixTransform(C,w).y}))},s.prototype.closePath=function(){this.__currentDefaultPath&&this.__addPathCommand("Z")},s.prototype.lineTo=function(C,w){this.__currentPosition={x:C,y:w},this.__currentDefaultPath.indexOf("M")>-1?this.__addPathCommand(g("L {x} {y}",{x:this.__matrixTransform(C,w).x,y:this.__matrixTransform(C,w).y})):this.__addPathCommand(g("M {x} {y}",{x:this.__matrixTransform(C,w).x,y:this.__matrixTransform(C,w).y}))},s.prototype.bezierCurveTo=function(C,w,D,k,P,G){this.__currentPosition={x:P,y:G},this.__addPathCommand(g("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:this.__matrixTransform(C,w).x,cp1y:this.__matrixTransform(C,w).y,cp2x:this.__matrixTransform(D,k).x,cp2y:this.__matrixTransform(D,k).y,x:this.__matrixTransform(P,G).x,y:this.__matrixTransform(P,G).y}))},s.prototype.quadraticCurveTo=function(C,w,D,k){this.__currentPosition={x:D,y:k},this.__addPathCommand(g("Q {cpx} {cpy} {x} {y}",{cpx:this.__matrixTransform(C,w).x,cpy:this.__matrixTransform(C,w).y,x:this.__matrixTransform(D,k).x,y:this.__matrixTransform(D,k).y}))};var I=function(C){var w=Math.sqrt(C[0]*C[0]+C[1]*C[1]);return[C[0]/w,C[1]/w]};return s.prototype.arcTo=function(C,w,D,k,P){var G=this.__currentPosition&&this.__currentPosition.x,B=this.__currentPosition&&this.__currentPosition.y;if(!(typeof G>"u"||typeof B>"u")){if(P<0)throw new Error("IndexSizeError: The radius provided ("+P+") is negative.");if(G===C&&B===w||C===D&&w===k||P===0){this.lineTo(C,w);return}var U=I([G-C,B-w]),W=I([D-C,k-w]);if(U[0]*W[1]===U[1]*W[0]){this.lineTo(C,w);return}var V=U[0]*W[0]+U[1]*W[1],Z=Math.acos(Math.abs(V)),L=I([U[0]+W[0],U[1]+W[1]]),z=P/Math.sin(Z/2),q=C+z*L[0],ne=w+z*L[1],te=[-U[1],U[0]],$=[W[1],-W[0]],fe=function(se){var be=se[0],pe=se[1];return pe>=0?Math.acos(be):-Math.acos(be)},Q=fe(te),oe=fe($);this.lineTo(q+te[0]*P,ne+te[1]*P),this.arc(q,ne,P,Q,oe)}},s.prototype.stroke=function(){this.__currentElement.nodeName==="path"&&this.__currentElement.setAttribute("paint-order","fill stroke markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("stroke")},s.prototype.fill=function(){this.__currentElement.nodeName==="path"&&this.__currentElement.setAttribute("paint-order","stroke fill markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("fill")},s.prototype.rect=function(C,w,D,k){this.__currentElement.nodeName!=="path"&&this.beginPath(),this.moveTo(C,w),this.lineTo(C+D,w),this.lineTo(C+D,w+k),this.lineTo(C,w+k),this.lineTo(C,w),this.closePath()},s.prototype.roundRect=function(C,w,D,k,P){this.__currentElement.nodeName!=="path"&&this.beginPath();let G,B,U,W;typeof P=="number"?(G=P,B=P,U=P,W=P):[G,B,U,W]=P,this.moveTo(C+G,w),this.arcTo(C+D,w,C+D,w+k,B),this.arcTo(C+D,w+k,C,w+k,U),this.arcTo(C,w+k,C,w,W),this.arcTo(C,w,C+D,w,G),this.closePath()},s.prototype.fillRect=function(C,w,D,k){let{a:P,b:G,c:B,d:U,e:W,f:V}=this.getTransform();JSON.stringify([P,G,B,U,W,V])===JSON.stringify([1,0,0,1,0,0])&&C===0&&w===0&&D===this.width&&k===this.height&&this.__clearCanvas();var Z,L;Z=this.__createElement("rect",{x:C,y:w,width:D,height:k},!0),L=this.__closestGroupOrSvg(),L.appendChild(Z),this.__currentElement=Z,this.__applyTransformation(Z),this.__applyStyleToCurrentElement("fill")},s.prototype.strokeRect=function(C,w,D,k){var P,G;P=this.__createElement("rect",{x:C,y:w,width:D,height:k},!0),G=this.__closestGroupOrSvg(),G.appendChild(P),this.__currentElement=P,this.__applyTransformation(P),this.__applyStyleToCurrentElement("stroke")},s.prototype.__clearCanvas=function(){var C=this.__root.childNodes[1];this.__root.removeChild(C),this.__currentElement=this.__document.createElementNS("http://www.w3.org/2000/svg","g"),this.__root.appendChild(this.__currentElement),this.__groupStack=[]},s.prototype.clearRect=function(C,w,D,k){let{a:P,b:G,c:B,d:U,e:W,f:V}=this.getTransform();if(JSON.stringify([P,G,B,U,W,V])===JSON.stringify([1,0,0,1,0,0])&&C===0&&w===0&&D===this.width&&k===this.height){this.__clearCanvas();return}var Z,L=this.__closestGroupOrSvg();Z=this.__createElement("rect",{x:C,y:w,width:D,height:k,fill:"#FFFFFF"},!0),this.__applyTransformation(Z),L.appendChild(Z)},s.prototype.createLinearGradient=function(C,w,D,k){var P=this.__createElement("linearGradient",{id:v(this.__ids),x1:C+"px",x2:D+"px",y1:w+"px",y2:k+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(P),new u(P,this)},s.prototype.createRadialGradient=function(C,w,D,k,P,G){var B=this.__createElement("radialGradient",{id:v(this.__ids),cx:k+"px",cy:P+"px",r:G+"px",fx:C+"px",fy:w+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(B),new u(B,this)},s.prototype.__applyText=function(C,w,D,k){var P=document.createElement("span");P.setAttribute("style","font:"+this.font);var G=P.style,B=this.__closestGroupOrSvg(),U=this.__createElement("text",{"font-family":G.fontFamily,"font-size":G.fontSize,"font-style":G.fontStyle,"font-weight":G.fontWeight,"text-decoration":this.__fontUnderline,x:w,y:D,"text-anchor":S(this.textAlign),"dominant-baseline":E(this.textBaseline)},!0);if(U.appendChild(this.__document.createTextNode(C)),this.__currentElement=U,this.__applyTransformation(U),this.__applyStyleToCurrentElement(k),this.__fontHref){var W=this.__createElement("a");W.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.__fontHref),W.appendChild(U),U=W}B.appendChild(U)},s.prototype.fillText=function(C,w,D){this.__applyText(C,w,D,"fill")},s.prototype.strokeText=function(C,w,D){this.__applyText(C,w,D,"stroke")},s.prototype.measureText=function(C){return this.__ctx.font=this.font,this.__ctx.measureText(C)},s.prototype.arc=function(C,w,D,k,P,G){if(k!==P){k=k%(2*Math.PI),P=P%(2*Math.PI),k===P&&(P=(P+2*Math.PI-.001*(G?-1:1))%(2*Math.PI));var B=C+D*Math.cos(P),U=w+D*Math.sin(P),W=C+D*Math.cos(k),V=w+D*Math.sin(k),Z=G?0:1,L=0,z=P-k;z<0&&(z+=2*Math.PI),G?L=z>Math.PI?0:1:L=z>Math.PI?1:0;var q=Math.hypot(this.__transformMatrix.a,this.__transformMatrix.b),ne=Math.hypot(this.__transformMatrix.c,this.__transformMatrix.d);this.lineTo(W,V),this.__addPathCommand(g("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:D*q,ry:D*ne,xAxisRotation:0,largeArcFlag:L,sweepFlag:Z,endX:this.__matrixTransform(B,U).x,endY:this.__matrixTransform(B,U).y})),this.__currentPosition={x:B,y:U}}},s.prototype.ellipse=function(C,w,D,k,P,G,B,U){if(G!==B){var W=this.__matrixTransform(C,w);C=W.x,w=W.y;var V=this.__getTransformScale();D=D*V.x,k=k*V.y,P=P+this.__getTransformRotation(),G=G%(2*Math.PI),B=B%(2*Math.PI),G===B&&(B=(B+2*Math.PI-.001*(U?-1:1))%(2*Math.PI));var Z=C+Math.cos(-P)*D*Math.cos(B)+Math.sin(-P)*k*Math.sin(B),L=w-Math.sin(-P)*D*Math.cos(B)+Math.cos(-P)*k*Math.sin(B),z=C+Math.cos(-P)*D*Math.cos(G)+Math.sin(-P)*k*Math.sin(G),q=w-Math.sin(-P)*D*Math.cos(G)+Math.cos(-P)*k*Math.sin(G),ne=U?0:1,te=0,$=B-G;$<0&&($+=2*Math.PI),U?te=$>Math.PI?0:1:te=$>Math.PI?1:0;var fe=this.__transformMatrix;this.resetTransform(),this.lineTo(z,q),this.__transformMatrix=fe,this.__addPathCommand(g("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:D,ry:k,xAxisRotation:P*(180/Math.PI),largeArcFlag:te,sweepFlag:ne,endX:Z,endY:L})),this.__currentPosition={x:Z,y:L}}},s.prototype.clip=function(){var C=this.__closestGroupOrSvg(),w=this.__createElement("clipPath"),D=v(this.__ids),k=this.__createElement("g");this.__applyCurrentDefaultPath(),C.removeChild(this.__currentElement),w.setAttribute("id",D),w.appendChild(this.__currentElement),this.__defs.appendChild(w),C.setAttribute("clip-path",g("url(#{id})",{id:D})),C.appendChild(k),this.__currentElement=k},s.prototype.drawImage=function(){var C=Array.prototype.slice.call(arguments),w=C[0],D,k,P,G,B=0,U=0,W,V,Z,L,z,q,ne,te,$,fe;if(C.length===3)D=C[1],k=C[2],W=w.width,V=w.height,P=W,G=V;else if(C.length===5)D=C[1],k=C[2],P=C[3],G=C[4],W=w.width,V=w.height;else if(C.length===9)B=C[1],U=C[2],W=C[3],V=C[4],D=C[5],k=C[6],P=C[7],G=C[8];else throw new Error("Invalid number of arguments passed to drawImage: "+arguments.length);Z=this.__closestGroupOrSvg(),this.__currentElement;const Q=this.getTransform().translate(D,k);if(w instanceof s){if(L=w.getSvg().cloneNode(!0),L.childNodes&&L.childNodes.length>1){for(z=L.childNodes[0];z.childNodes.length;)fe=z.childNodes[0].getAttribute("id"),this.__ids[fe]=fe,this.__defs.appendChild(z.childNodes[0]);q=L.childNodes[1],q&&(this.__applyTransformation(q,Q),Z.appendChild(q))}}else(w.nodeName==="CANVAS"||w.nodeName==="IMG")&&(ne=this.__createElement("image"),ne.setAttribute("width",P),ne.setAttribute("height",G),ne.setAttribute("preserveAspectRatio","none"),(B||U||W!==w.width||V!==w.height)&&(te=this.__document.createElement("canvas"),te.width=P,te.height=G,$=te.getContext("2d"),$.drawImage(w,B,U,W,V,0,0,P,G),w=te),this.__applyTransformation(ne,Q),ne.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",w.nodeName==="CANVAS"?w.toDataURL():w.getAttribute("src")),Z.appendChild(ne))},s.prototype.createPattern=function(C,w){var D=this.__document.createElementNS("http://www.w3.org/2000/svg","pattern"),k=v(this.__ids),P;return D.setAttribute("id",k),D.setAttribute("width",C.width),D.setAttribute("height",C.height),D.setAttribute("patternUnits","userSpaceOnUse"),C.nodeName==="CANVAS"||C.nodeName==="IMG"?(P=this.__document.createElementNS("http://www.w3.org/2000/svg","image"),P.setAttribute("width",C.width),P.setAttribute("height",C.height),P.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",C.nodeName==="CANVAS"?C.toDataURL():C.getAttribute("src")),D.appendChild(P),this.__defs.appendChild(D)):C instanceof s&&(D.appendChild(C.__root.childNodes[1]),this.__defs.appendChild(D)),new c(D,this)},s.prototype.setLineDash=function(C){C&&C.length>0?this.lineDash=C.join(","):this.lineDash=null},s.prototype.setTransform=function(C,w,D,k,P,G){C instanceof DOMMatrix?this.__transformMatrix=new DOMMatrix([C.a,C.b,C.c,C.d,C.e,C.f]):this.__transformMatrix=new DOMMatrix([C,w,D,k,P,G])},s.prototype.getTransform=function(){let{a:C,b:w,c:D,d:k,e:P,f:G}=this.__transformMatrix;return new DOMMatrix([C,w,D,k,P,G])},s.prototype.resetTransform=function(){this.setTransform(1,0,0,1,0,0)},s.prototype.scale=function(C,w){if(w===void 0&&(w=C),isNaN(C)||isNaN(w)||!isFinite(C)||!isFinite(w))return;let D=this.getTransform().scale(C,w);this.setTransform(D)},s.prototype.rotate=function(C){let w=this.getTransform().multiply(new DOMMatrix([Math.cos(C),Math.sin(C),-Math.sin(C),Math.cos(C),0,0]));this.setTransform(w)},s.prototype.translate=function(C,w){const D=this.getTransform().translate(C,w);this.setTransform(D)},s.prototype.transform=function(C,w,D,k,P,G){const B=this.getTransform().multiply(new DOMMatrix([C,w,D,k,P,G]));this.setTransform(B)},s.prototype.__matrixTransform=function(C,w){return new DOMPoint(C,w).matrixTransform(this.__transformMatrix)},s.prototype.__getTransformScale=function(){return{x:Math.hypot(this.__transformMatrix.a,this.__transformMatrix.b),y:Math.hypot(this.__transformMatrix.c,this.__transformMatrix.d)}},s.prototype.__getTransformRotation=function(){return Math.atan2(this.__transformMatrix.b,this.__transformMatrix.a)},s.prototype.getImageData=function(C,w,D,k,P){return t.getImageData(this.getSvg(),this.width,this.height,C,w,D,k,P)},s.prototype.drawFocusRing=function(){},s.prototype.createImageData=function(){},s.prototype.putImageData=function(){},s.prototype.globalCompositeOperation=function(){},s})();function i(a){this.ctx=new r(a),this.svg=this.ctx.__root;var s=this.svg,u=this,c=document.createElement("div");c.style.display="inline-block",c.appendChild(s),this.wrapper=c,Object.defineProperty(this,"className",{get:function(){return c.getAttribute("class")||""},set:function(h){return c.setAttribute("class",h)}}),Object.defineProperty(this,"tagName",{get:function(){return"CANVAS"},set:function(){}}),["width","height"].forEach(function(h){Object.defineProperty(u,h,{get:function(){return s.getAttribute(h)|0},set:function(g){if(!(isNaN(g)||typeof g>"u"))return u.ctx[h]=g,s.setAttribute(h,g),c[h]=g}})}),["style","id"].forEach(function(h){Object.defineProperty(u,h,{get:function(){return c[h]},set:function(g){if(typeof g<"u")return c[h]=g}})}),["getBoundingClientRect"].forEach(function(h){u[h]=function(){return s[h]()}})}return i.prototype.getContext=function(a){if(a!=="2d")throw new Error("Unsupported type of context for SVGCanvas");return this.ctx},i.prototype.toObjectURL=function(){var a=new XMLSerializer().serializeToString(this.svg),s=new Blob([a],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(s)},i.prototype.toDataURL=function(a,s,u){return t.toDataURL(this.svg,this.width,this.height,a,s,u)},i.prototype.addEventListener=function(){return this.svg.addEventListener.apply(this.svg,arguments)},i.prototype.getElement=function(){return this.wrapper},i.prototype.getAttribute=function(a){return this.wrapper.getAttribute(a)},i.prototype.setAttribute=function(a,s){this.wrapper.setAttribute(a,s)},Lg.Context=r,Lg.Element=i,Lg}var nG=tG();const fA=async n=>new Promise(e=>setTimeout(e,n));async function rG(n,e=!1,{onBefore:t,onAfter:r}={}){const i=n.getLayers()[0];t&&t([n,i]),await fA(200);const a=i.canvas.context._context,s=i.canvas.context._context=new nG.Context({height:n.height(),width:n.width(),ctx:a});n.draw();let u=s.getSerializedSvg();return u=e?new Blob([u],{type:"image/svg+xml;charset=utf-8"}):u,i.canvas.context._context=a,r&&r([n,i]),await fA(200),n.draw(),u}function lO(n){return window.Konva.stages.find(e=>e.attrs.id===n)}function hy(n,e,t,r,i=!0,a=!1){iG();const s=lO(n);s.width(e),s.height(t),s.scale({x:r,y:r}),a&&(s.find("Rect").map(u=>{u.strokeWidth(u.strokeWidth()*r)}),s.find("Line").map(u=>{u.strokeWidth(u.strokeWidth()*r)}),s.find("Circle").map(u=>{u.strokeWidth(u.strokeWidth()*r)}),s.find("Ellipse").map(u=>{u.strokeWidth(u.strokeWidth()*r)})),i||aG()}function iG(){const n=document.getElementsByClassName("konvajs-content");n[0].style.visibility="hidden"}function aG(){const n=document.getElementsByClassName("konvajs-content");n[0].style.visibility="visible"}function sG(n){const e=new DOMParser().parseFromString(n,"image/svg+xml");return e.querySelectorAll("rect").forEach(t=>{const r=(t.getAttribute("fill")||"").trim().toLowerCase(),i=r==="#ffffff"||r==="#fff"||r==="white",a=(t.getAttribute("stroke")||"none").trim().toLowerCase();i&&(a==="none"||a==="")&&t.remove()}),new XMLSerializer().serializeToString(e.documentElement)}async function oG(n){const e=lO(n),t=3;e.find("Transformer").forEach(a=>a.destroy());function r(a){const{r:s,g:u,b:c,a:h}=uO(a.stroke());a.strokeScaleEnabled(!0),a.stroke(`rgb(${s},${u},${c})`),a.strokeWidth(t)}e.find("Rect").map(a=>{r(a)}),e.find("Line").map(a=>{r(a)}),e.find("Circle").map(a=>{r(a)}),e.find("Ellipse").map(a=>{r(a)});let i=await rG(e,!1);return i=sG(i),i=i.replaceAll('"',"'"),i}const lG=[0,2,5,10,20,50],ma={DRAW:"draw",IMAGE:"image",POI:"poi",TARGET:"target"},Ur={CURSOR:"cursor",DELETE:"delete",EDIT:"edit",IMAGE:"image",SHAPE:"shapes",TEXT:"text"},Xt={ARROW:"arrow",CIRCLE:"circle",ELLIPSE:"ellipse",FREEHAND:"freehand",IMAGE:"image",POI:"poi",POLYGON:"polygon",RECTANGLE:"rectangle",SHAPES:"shapes"},uG={fill:"#e53935",stroke:"#ffffff",strokeWidth:2};function cG(n,e){const t=Math.min(n,e);return!Number.isFinite(t)||t<=0?10:Math.min(40,Math.max(6,t*.015))}function C5(n){return Object.values(Xt).find(e=>e===n)}const uO=(n="rgba(255,255,255,0.5)")=>window.Konva.Util.colorToRGBA(n),dG=(n={r:255,g:255,b:255,a:.5})=>`rgba(${n.r},${n.g},${n.b},${n.a})`,er={IIIF_TYPE:"iiif",JOURNEY_TYPE:"journey",MULTIPLE_BODY_TYPE:"multiple_body",POI_TYPE:"poi",TAGGING_TYPE:"tagging",TEXT_TYPE:"text"},hA={expert:er.IIIF_TYPE,journey:er.JOURNEY_TYPE,note:er.MULTIPLE_BODY_TYPE,poi:er.POI_TYPE,tag:er.TAGGING_TYPE},Bi={AUDIO:"Audio",IMAGE:"Image",UNKNOWN:"Unknown",VIDEO:"Video"},fG={activeTool:Ur.SHAPE,closedMode:"closed",fillColor:"rgba(83,162, 235, 0.5)",image:{id:""},imageEvent:null,strokeColor:"rgba(20,82,168,1)",strokeWidth:2},oo={activeTool:Ur.EDIT,closedMode:"closed",fillColor:"rgba(100,100,100, 0)",image:{id:null},imageEvent:null,strokeColor:"rgba(255,0, 0, 0.5)",strokeWidth:5},cO="target",Qv="layer";function pA(){return new Date().toLocaleString([navigator.language],{dateStyle:"short",timeStyle:"short"})}async function hG(n,e,t,r){r?.maeData?r.id?(r.lastSavedDate=pA(),r.lastEditor=e.getStorageAdapterUser(),console.log("Annotation to update",r),e.update(r).then(i=>{t(n,e.annotationPageId,i)})):(r.id=`${n}/annotation/${vs()}`,r.creationDate=pA(),r.creator=e.getStorageAdapterUser(),r?.maeData?.manifestNetwork&&(r.id=`${r.id}#${r.maeData.manifestNetwork}`),console.log("Annotation to create",r),e.create(r).then(i=>{t(n,e.annotationPageId,i)})):r.id?e.update(r).then(i=>{t(n,e.annotationPageId,i)}):(r.id=`${n}/annotation/${vs()}`,e.create(r).then(i=>{t(n,e.annotationPageId,i)}))}const dO=xs.styled(l5)(({theme:n})=>({"&:first-of-type":{borderRadius:n.shape.borderRadius},"&:not(:first-of-type)":{borderRadius:n.shape.borderRadius},border:"none",margin:n.spacing(.5),"& .MuiToggleButton-root":{borderRadius:n.shape.borderRadius,color:n.palette.text.primary,transition:"transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease","&:hover":{transform:"translateY(-1px)",boxShadow:n.shadows[1]}},"& .MuiToggleButton-root.Mui-selected":{backgroundColor:n.palette.primary.main,color:n.palette.primary.contrastText,boxShadow:n.shadows[3],transform:"scale(1.03)","&:hover":{backgroundColor:n.palette.primary.dark}}}));function pG(n){return!1}const gG=n=>n.strokeColor===oo.strokeColor&&n.fillColor===oo.fillColor,mG=n=>n.type===Xt.RECTANGLE,vG=n=>{if(n.length!==1)return!1;const e=n[0];return mG(e)&&(!e?.rotation||e.rotation===0)&&gG(e)},yG=(n,e)=>{console.info("Implement target as string on fullSizeCanvas.");const t=n.target;return`${e}#${t.tend?`xywh=${t.fullCanvaXYWH}&t=${t.tstart},${t.tend}`:`xywh=${t.fullCanvaXYWH}`}`},bG=(n,e,t)=>{console.info("Implement target as string with one shape (rectangle)");let{x:r,y:i,width:a,height:s,scaleX:u,scaleY:c}=t;return a<0&&(a=-a,r-=a),s<0&&(s=-s,i-=s),`${e}#${n.tend?`xywh=${r},${i},${a*u},${s*c}&t=${n.tstart},${n.tend}`:`xywh=${r},${i},${a*u},${s*c}`}`},xG=(n,e)=>{const t=`${n.tend?`t=${n.tstart},${n.tend}`:""}`;return{selector:[{type:"SvgSelector",value:n.svg},{type:"FragmentSelector",value:`${e}#${t}`}],source:e}},SG=(n,e,t=null,r=null)=>{const i=n.target,{templateType:a}=n;switch(a){case er.IIIF_TYPE:return i;case er.TAGGING_TYPE:case er.TEXT_TYPE:case er.MULTIPLE_BODY_TYPE:case er.POI_TYPE:return vG(i.drawingState.shapes)?(console.info("Simple target detected"),bG(i,e,i.drawingState.shapes[0])):(console.info("Implement target as SVG/Fragment with shapes"),xG(i,e));default:return yG(n,e)}},CG=n=>{const e={purpose:"describing",type:"TextualBody",value:""},t=s=>{const u=structuredClone(e);return u.value=s.value||"",u},r=s=>{const u=structuredClone(e);return u.value=s||"",u};let i="",a={};return n["dbf:kind"]==="POI"?i=er.POI_TYPE:n["dbf:kind"]==="Journey"?i=er.JOURNEY_TYPE:n.motivation==="tagging"||Array.isArray(n.motivation)&&n.motivation.includes("tagging")?i=er.TAGGING_TYPE:(i=er.MULTIPLE_BODY_TYPE,n.bodyValue?a=r(n.bodyValue):n.body&&(a=Array.isArray(n.body)?n.body.map(t):t(n.body))),[i,a]},EG=n=>{const e=n.documentElement,t=document.createElement("div");t.style.position="absolute",t.style.left="-99999px",t.style.width="0",t.style.height="0",t.style.overflow="hidden",t.style.pointerEvents="none",document.body.appendChild(t);const r=document.importNode(e,!0),i="http://www.w3.org/2000/svg",a=document.createElementNS(i,"svg");for(const c of r.attributes||[])a.setAttribute(c.name,c.value);const s=document.createElementNS(i,"g");for(;r.firstChild;)s.appendChild(r.firstChild);a.appendChild(s),t.appendChild(a),t.offsetWidth;const u=s.getBBox();return document.body.removeChild(t),u},_G=({x:n,y:e,w:t,h:r,fullW:i=void 0,fullH:a=void 0})=>{n=parseFloat(n),e=parseFloat(e),t=parseFloat(t),r=parseFloat(r),a?a=parseFloat(a):i&&(i=parseFloat(i));const s=i&&a?`width='${i}' height='${a}'`:"";if([n,e,t,r].some(u=>typeof u!="number"))throw new Error(`xywhToSvg: x,y,w,h must be floats (got x=${n}, y=${e}, w=${t}, h=${r})`);return`<svg
10
10
  version='1.1'
11
11
  xmlns='http://www.w3.org/2000/svg'
12
12
  xmlns:xlink='http://www.w3.org/1999/xlink'