UNPKG

@aliconnect/sdk

Version:
4 lines 136 kB
/** Last modified 2021-09-21 18:16:35 */ eol='\n';function extend(selector,context){for(let [key,value] of Object.entries(context)){if(Array.isArray(value)){selector[key]=value}else if(typeof value==='object'){selector[key]=extend(selector[key]||{},value)}else{selector[key]=value}}return selector};function validSchemaName(schemaName){if(!schemaName)throw'invalid schemaname';return String(schemaName).replace(/^\d|\.|\s|-|\(|\)|,/g,'').replace(/\bLocation\b/,'Loc')}function urlToId(href){return btoa(href).replace(/[=]+Aim/g,'')}function idToUrl(id){return atob(id)}(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.Aim=factory())}(this,function(exports){const libUrl='https://aliconnect.nl/npm/@aliconnect/lib@0.0.0/dist';const self=this;const dmsOrigin='https://aliconnect.nl';const dmsUrl='https://dms.aliconnect.nl';const AUTHORIZATION_URL='https://login.aliconnect.nl/oauth';const AUTHORIZATION_TOKEN_URL='https://login.aliconnect.nl/token';let aimClient;console.msg=console.msg||console.info;today=new Date();dstart=0;maxdate=0;const meshitems=[];const zoneMappings={"Dateline Standard Time":"Etc/GMT+12","UTC-11":"Etc/GMT+11","Aleutian Standard Time":"America/Adak","Hawaiian Standard Time":"Pacific/Honolulu","Marquesas Standard Time":"Pacific/Marquesas","Alaskan Standard Time":"America/Anchorage","UTC-09":"Etc/GMT+9","Pacific Standard Time (Mexico)":"America/Tijuana","UTC-08":"Etc/GMT+8","Pacific Standard Time":"America/Los_Angeles","US Mountain Standard Time":"America/Phoenix","Mountain Standard Time (Mexico)":"America/Chihuahua","Mountain Standard Time":"America/Denver","Central America Standard Time":"America/Guatemala","Central Standard Time":"America/Chicago","Easter Island Standard Time":"Pacific/Easter","Central Standard Time (Mexico)":"America/Mexico_City","Canada Central Standard Time":"America/Regina","SA Pacific Standard Time":"America/Bogota","Eastern Standard Time (Mexico)":"America/Cancun","Eastern Standard Time":"America/New_York","Haiti Standard Time":"America/Port-au-Prince","Cuba Standard Time":"America/Havana","US Eastern Standard Time":"America/Indianapolis","Turks And Caicos Standard Time":"America/Grand_Turk","Paraguay Standard Time":"America/Asuncion","Atlantic Standard Time":"America/Halifax","Venezuela Standard Time":"America/Caracas","Central Brazilian Standard Time":"America/Cuiaba","SA Western Standard Time":"America/La_Paz","Pacific SA Standard Time":"America/Santiago","Newfoundland Standard Time":"America/St_Johns","Tocantins Standard Time":"America/Araguaina","E. South America Standard Time":"America/Sao_Paulo","SA Eastern Standard Time":"America/Cayenne","Argentina Standard Time":"America/Buenos_Aires","Greenland Standard Time":"America/Godthab","Montevideo Standard Time":"America/Montevideo","Magallanes Standard Time":"America/Punta_Arenas","Saint Pierre Standard Time":"America/Miquelon","Bahia Standard Time":"America/Bahia","UTC-02":"Etc/GMT+2","Azores Standard Time":"Atlantic/Azores","Cape Verde Standard Time":"Atlantic/Cape_Verde","UTC":"Etc/GMT","GMT Standard Time":"Europe/London","Greenwich Standard Time":"Atlantic/Reykjavik","Sao Tome Standard Time":"Africa/Sao_Tome","Morocco Standard Time":"Africa/Casablanca","W. Europe Standard Time":"Europe/Berlin","Central Europe Standard Time":"Europe/Budapest","Romance Standard Time":"Europe/Paris","Central European Standard Time":"Europe/Warsaw","W. Central Africa Standard Time":"Africa/Lagos","Jordan Standard Time":"Asia/Amman","GTB Standard Time":"Europe/Bucharest","Middle East Standard Time":"Asia/Beirut","Egypt Standard Time":"Africa/Cairo","E. Europe Standard Time":"Europe/Chisinau","Syria Standard Time":"Asia/Damascus","West Bank Standard Time":"Asia/Hebron","South Africa Standard Time":"Africa/Johannesburg","FLE Standard Time":"Europe/Kiev","Israel Standard Time":"Asia/Jerusalem","Kaliningrad Standard Time":"Europe/Kaliningrad","Sudan Standard Time":"Africa/Khartoum","Libya Standard Time":"Africa/Tripoli","Namibia Standard Time":"Africa/Windhoek","Arabic Standard Time":"Asia/Baghdad","Turkey Standard Time":"Europe/Istanbul","Arab Standard Time":"Asia/Riyadh","Belarus Standard Time":"Europe/Minsk","Russian Standard Time":"Europe/Moscow","E. Africa Standard Time":"Africa/Nairobi","Iran Standard Time":"Asia/Tehran","Arabian Standard Time":"Asia/Dubai","Astrakhan Standard Time":"Europe/Astrakhan","Azerbaijan Standard Time":"Asia/Baku","Russia Time Zone 3":"Europe/Samara","Mauritius Standard Time":"Indian/Mauritius","Saratov Standard Time":"Europe/Saratov","Georgian Standard Time":"Asia/Tbilisi","Volgograd Standard Time":"Europe/Volgograd","Caucasus Standard Time":"Asia/Yerevan","Afghanistan Standard Time":"Asia/Kabul","West Asia Standard Time":"Asia/Tashkent","Ekaterinburg Standard Time":"Asia/Yekaterinburg","Pakistan Standard Time":"Asia/Karachi","Qyzylorda Standard Time":"Asia/Qyzylorda","India Standard Time":"Asia/Calcutta","Sri Lanka Standard Time":"Asia/Colombo","Nepal Standard Time":"Asia/Katmandu","Central Asia Standard Time":"Asia/Almaty","Bangladesh Standard Time":"Asia/Dhaka","Omsk Standard Time":"Asia/Omsk","Myanmar Standard Time":"Asia/Rangoon","SE Asia Standard Time":"Asia/Bangkok","Altai Standard Time":"Asia/Barnaul","W. Mongolia Standard Time":"Asia/Hovd","North Asia Standard Time":"Asia/Krasnoyarsk","N. Central Asia Standard Time":"Asia/Novosibirsk","Tomsk Standard Time":"Asia/Tomsk","China Standard Time":"Asia/Shanghai","North Asia East Standard Time":"Asia/Irkutsk","Singapore Standard Time":"Asia/Singapore","W. Australia Standard Time":"Australia/Perth","Taipei Standard Time":"Asia/Taipei","Ulaanbaatar Standard Time":"Asia/Ulaanbaatar","Aus Central W. Standard Time":"Australia/Eucla","Transbaikal Standard Time":"Asia/Chita","Tokyo Standard Time":"Asia/Tokyo","North Korea Standard Time":"Asia/Pyongyang","Korea Standard Time":"Asia/Seoul","Yakutsk Standard Time":"Asia/Yakutsk","Cen. Australia Standard Time":"Australia/Adelaide","AUS Central Standard Time":"Australia/Darwin","E. Australia Standard Time":"Australia/Brisbane","AUS Eastern Standard Time":"Australia/Sydney","West Pacific Standard Time":"Pacific/Port_Moresby","Tasmania Standard Time":"Australia/Hobart","Vladivostok Standard Time":"Asia/Vladivostok","Lord Howe Standard Time":"Australia/Lord_Howe","Bougainville Standard Time":"Pacific/Bougainville","Russia Time Zone 10":"Asia/Srednekolymsk","Magadan Standard Time":"Asia/Magadan","Norfolk Standard Time":"Pacific/Norfolk","Sakhalin Standard Time":"Asia/Sakhalin","Central Pacific Standard Time":"Pacific/Guadalcanal","Russia Time Zone 11":"Asia/Kamchatka","New Zealand Standard Time":"Pacific/Auckland","UTC+12":"Etc/GMT-12","Fiji Standard Time":"Pacific/Fiji","Chatham Islands Standard Time":"Pacific/Chatham","UTC+13":"Etc/GMT-13","Tonga Standard Time":"Pacific/Tongatapu","Samoa Standard Time":"Pacific/Apia","Line Islands Standard Time":"Pacific/Kiritimati"};const pageHtml=`<!DOCTYPE HTML><html><head><link href="${dmsUrl}/css/web_debug.css" rel="stylesheet"/><script src="${dmsUrl}/js/aim_debug.js" libraries="web"></script></head><body></body></html>`;minimist=function(args,opts){if(!opts)opts={};var flags={bools:{},strings:{},unknownFn:null};if(typeof opts['unknown']==='function'){flags.unknownFn=opts['unknown']}if(typeof opts['boolean']==='boolean'&&opts['boolean']){flags.allBools=true}else{[].concat(opts['boolean']).filter(Boolean).forEach(function(key){flags.bools[key]=true})}var aliases={};Object.keys(opts.alias||{}).forEach(function(key){aliases[key]=[].concat(opts.alias[key]);aliases[key].forEach(function(x){aliases[x]=[key].concat(aliases[key].filter(function(y){return x!==y}))})});[].concat(opts.string).filter(Boolean).forEach(function(key){flags.strings[key]=true;if(aliases[key]){flags.strings[aliases[key]]=true}});var defaults=opts['default']||{};var argv={};Object.keys(flags.bools).forEach(function(key){setArg(key,defaults[key]===undefined?false:defaults[key])});var notFlags=[];if(args.indexOf('--')!==-1){notFlags=args.slice(args.indexOf('--')+1);args=args.slice(0,args.indexOf('--'))}function argDefined(key,arg){return(flags.allBools&&/^--[^=]+Aim/.test(arg))||flags.strings[key]||flags.bools[key]||aliases[key]}function setArg(key,val,arg){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg)===false)return}var value=!flags.strings[key]&&!isNaN(val)?Number(val):val;setKey(argv,key.split('-'),value);(aliases[key]||[]).forEach(function(x){setKey(argv,x.split('-'),value)})}function setKey(obj,keys,value){var o=obj;keys.slice(0,-1).forEach(function(key){if(o[key]===undefined)o[key]={};o=o[key]});var key=keys[keys.length-1];if(o[key]===undefined||flags.bools[key]||typeof o[key]==='boolean'){o[key]=value}else if(Array.isArray(o[key])){o[key].push(value)}else{o[key]=[o[key],value]}}function aliasIsBoolean(key){return aliases[key].some(function(x){return flags.bools[x]})}for(var i=0;i<args.length;i++){var arg=args[i];if(/^--.+=/.test(arg)){var m=arg.match(/^--([^=]+)=([\s\S]*)Aim/);var key=m[1];var value=m[2];if(flags.bools[key]){value=value!=='false'}setArg(key,value,arg)}else if(/^--no-.+/.test(arg)){var key=arg.match(/^--no-(.+)/)[1];setArg(key,false,arg)}else if(/^--.+/.test(arg)){var key=arg.match(/^--(.+)/)[1];var next=args[i+1];if(next!==undefined&&!/^-/.test(next)&&!flags.bools[key]&&!flags.allBools&&(aliases[key]?!aliasIsBoolean(key):true)){setArg(key,next,arg);i++}else if(/^(true|false)Aim/.test(next)){setArg(key,next==='true',arg);i++}else{setArg(key,flags.strings[key]?'':true,arg)}}else if(/^-[^-]+/.test(arg)){var letters=arg.slice(1,-1).split('');var broken=false;for(var j=0;j<letters.length;j++){var next=arg.slice(j+2);if(next==='-'){setArg(letters[j],next,arg);continue}if(/[A-Za-z]/.test(letters[j])&&/=/.test(next)){setArg(letters[j],next.split('=')[1],arg);broken=true;break}if(/[A-Za-z]/.test(letters[j])&&/-?\d+(\.\d*)?(e-?\d+)?Aim/.test(next)){setArg(letters[j],next,arg);broken=true;break}if(letters[j+1]&&letters[j+1].match(/\W/)){setArg(letters[j],arg.slice(j+2),arg);broken=true;break}else{setArg(letters[j],flags.strings[letters[j]]?'':true,arg)}}var key=arg.slice(-1)[0];if(!broken&&key!=='-'){if(args[i+1]&&!/^(-|--)[^-]/.test(args[i+1])&&!flags.bools[key]&&(aliases[key]?!aliasIsBoolean(key):true)){setArg(key,args[i+1],arg);i++}else if(args[i+1]&&/true|false/.test(args[i+1])){setArg(key,args[i+1]==='true',arg);i++}else{setArg(key,flags.strings[key]?'':true,arg)}}}else{if(!flags.unknownFn||flags.unknownFn(arg)!==false){}if(opts.stopEarly){argv._.push.apply(argv._,args.slice(i+1));break}}}Object.keys(defaults).forEach(function(key){if(!hasKey(argv,key.split('.'))){setKey(argv,key.split('.'),defaults[key]);(aliases[key]||[]).forEach(function(x){setKey(argv,x.split('.'),defaults[key])})}});if(opts['--']){argv['--']=new Array();notFlags.forEach(function(key){argv['--'].push(key)})}else{notFlags.forEach(function(key){argv._.push(key)})}return argv};function createParam(param,splitter){var result={};if(param)param.split(splitter||'&').forEach(function(val){var val=val.split('='),name=val.shift(),val=val.shift();result[name]=val?decodeURIComponent(val):val});return result};function dateText(date){const dateTime=new Date(date);dateTime.setHours(0,0,0,0);const now=new Date();now.setHours(0,0,0,0);const days=Math.round((dateTime.valueOf()-now.valueOf())/1000/60/60/24);if(days<-730)return'2 years ago';if(days<-365)return'1 year ago';if(days<-60)return'2 months ago';if(days<-30)return'1 month ago';if(days<-14)return'2 weeks ago';if(days<-7)return'1 weeks ago';if(days<-2)return'last week';if(days<-1)return'yesterday';if(days<0)return'today';if(days>730)return'after 2 years';if(days>365)return'after 1 year';if(days>60)return'after 2 months';if(days>30)return'after 1 month';if(days>14)return'over 2 weeks';if(days>7)return'next week';if(days>1)return'day after tomorrow';if(days>0)return'tomorrow'}function setPrototype(fn,prototype,properties){Object.assign(fn.prototype,prototype);for(let [name,property] of Object.entries(properties)){Object.defineProperty(fn.prototype,name,property)}}function uploadState(e){Aim.url(AUTHORIZATION_URL).query({response_type:'socket_id',state:e.type,socket_id:Aim.WebsocketClient.socket_id,id_token:Aim.his.cookie.id_token}).get()};function aDate(d){if(!d)return new Date();var resdate=new Date(d);if(d.length===10)resdate.setTime(resdate.getTime()+resdate.getTimezoneOffset()*60*1000);return resdate}function authSubmit(e){Aim().url(AUTHORIZATION_URL+document.location.search).post(e.target).then(checkResponse);return false}function dateTime0(date,days){date=new Date(date);date.setHours(0,0,0,0);if(days){date.setDate(date.getDate()+days)}return date}function focusSection(e,offset){if(e.clickEvent&&document.activeElement===document.body){const currentSection=e.clickEvent.path.find(elem=>elem.tagName==='SECTION');const children=[...document.body.getElementsByTagName('SECTION')];const index=children.indexOf(currentSection);const nextSection=children[index+offset];if(nextSection){nextSection.click()}e.preventDefault()}}function importXlsFile(file){const basePath=document.location.pathname.split(/\/(api|docs|om)/)[0];const sub=Aim.access.sub;const path=`/${sub}/config.json`;const config={app:{nav:{items:{List:{items:{}}}}}};const reader=new FileReader();reader.readAsBinaryString(file);reader.onload=e=>{const components=config.components=config.components||{};const schemas=components.schemas=components.schemas||{};const workbook=XLSX.read(e.target.result,{type:'binary'});function importSheet(sheetname){const wbsheet=workbook.Sheets[sheetname];const schema=schemas[sheetname]=schemas[sheetname]||{};const properties=schema.properties=schema.properties||{};const [start,end]=wbsheet['!ref'].split(':');const [end_colstr]=end.match(/[A-Z]+/);const col_index=XLSX.utils.decode_col(end_colstr);const types={s:'string'};for(var c=0;c<=col_index;c++){var cellstr=XLSX.utils.encode_cell({c:c,r:0});var cell=wbsheet[cellstr];if(!cell||!cell.v){break}properties[cell.v]=properties[cell.v]||{type:types[cell.t]||'string'}}}for(let sheetname in workbook.Sheets){importSheet(sheetname);config.app.nav.items.List.items[sheetname]={title:sheetname,href:'#/'+sheetname}}new Aim.HttpRequest(Aim.config.Aim,'post','/').query({append:true}).input(config).send().onload=e=>{}}}function getIanaFromWindows(windowsZoneName){return zoneMappings[windowsZoneName]||"Etc/GMT"}function _gotDevices(mediaDevices){select.innerHTML='';select.appendChild(document.createElement('option'));let count=1;mediaDevices.forEach(mediaDevice=>{if(mediaDevice.kind==='videoinput'){const option=document.createElement('option');option.value=mediaDevice.deviceId;const label=mediaDevice.label||`Camera ${count++}`;const textNode=document.createTextNode(label);option.appendChild(textNode);select.appendChild(option)}})}function pageClose(){colpage.innerText='';Aim.his.replaceUrl(document.location.href.replace(/\/id\/([^\?]*)/,''))}function stopMediaTracks(stream){stream.getTracks().forEach(track=>{track.stop()})}function swipedetect(el,callback){var touchsurface=el,swipedir,startX,startY,distX,distY,threshold=150,restraint=100,allowedTime=300,elapsedTime,startTime,handleswipe=callback||function(swipedir){};touchsurface.addEventListener('touchstart',function(e){var touchobj=e.changedTouches[0],swipedir='none',dist=0,startX=touchobj.pageX,startY=touchobj.pageY,startTime=new Date().getTime();e.preventDefault()},false);touchsurface.addEventListener('touchmove',function(e){e.preventDefault()},false);touchsurface.addEventListener('touchend',function(e){var touchobj=e.changedTouches[0],distX=touchobj.pageX-startX,distY=touchobj.pageY-startY,elapsedTime=new Date().getTime()-startTime;if(elapsedTime<=allowedTime){if(Math.abs(distX)>=threshold&&Math.abs(distY)<=restraint){swipedir=(distX<0)?'left':'right'}else if(Math.abs(distY)>=threshold&&Math.abs(distX)<=restraint){swipedir=(distY<0)?'up':'down'}}handleswipe(swipedir);e.preventDefault()},false)}function getId(id){return Number(id.split('-').shift())}function getUid(id){return id.replace(/^\d+-/,'')}Object.defineProperties(Array.prototype,{unique:{value:function(){return this.filter((e,i,arr)=>arr.indexOf(e)===i)}}});Object.defineProperties(Date.prototype,{addDays:{value:function addDays(days){var day=new Date(this);day.setDate(this.getDate()+days);return day}},getWeek:{value:function getWeek(){var d=new Date(+this);d.setHours(0,0,0,0);d.setDate(d.getDate()+4-(d.getDay()||7));return Math.ceil((((d-new Date(d.getFullYear(),0,1))/ 8.64e7)+1)/ 7)}},getWeekday:{value:function getWeekday(){return(this.getDay()+6)% 7}},monthDays:{value:function monthDays(){var d=new Date(this.getFullYear(),this.getMonth()+1,0);return d.getDate()}},toDateText:{value:function toDateText(full){let res='';if(this){const now=new Date();let dagen=Math.ceil((this.getTime()-now.getTime())/ 24 / 60 / 60 / 1000);let dayNames=['Monday','Tuesday','Wednesday','Thursday','Friday','Saterday','Sunday'];let monthNames=['Januari','Februari','March','April','May','June','July','August','September','November','December'];const time=this.toLocaleTimeString();return [ __(dagen===0?'Today':dagen===-1?'Yesterday':dayNames[this.getDay()-1]),this.getDate(),__(monthNames[this.getMonth()-1]),this.getFullYear(),time==='00:00:00'?'':time.substr(0,5),__('week'),this.getWeek()].filter(Boolean).join(' ')}return res}},toDateTimeText:{value:function toDateTimeText(full){var res=this.toDateText();if(this.getHours()||this.getMinutes())res+=this.toLocaleTimeString().substr(0,5)}},toDateTimeStr:{value:function toDateTimeStr(length){var s=this.getFullYear()+'-'+(this.getMonth()+1).pad(2)+'-'+this.getDate().pad(2);if(this.getHours()!=0&&this.getMinutes()!=0&&this.getSeconds()!=0)s+=' '+this.getHours().pad(2)+':'+this.getMinutes().pad(2)+':'+this.getSeconds().pad(2);+'.'+this.getMilliseconds().pad(3);return s.substring(0,length)}},toDateTimeStringT:{value:function toDateTimeStringT(){return this.getFullYear()+'-'+(this.getMonth()+1).pad(2)+'-'+this.getDate().pad(2)+'T'+this.getHours().pad(2)+':'+this.getMinutes().pad(2)+':'+this.getSeconds().pad(2)+'.'+this.getMilliseconds().pad(3)}},toDateTimeString:{value:function toDateTimeString(){return this.getFullYear()+'-'+(this.getMonth()+1).pad(2)+'-'+this.getDate().pad(2)+' '+this.getHours().pad(2)+':'+this.getMinutes().pad(2)+':'+this.getSeconds().pad(2)+'.'+this.getMilliseconds().pad(3)}},toLocal:{value:function toLocal(){this.setTime(this.getTime()-this.getTimezoneOffset()*60*1000);return this}},toLocalDBString:{value:function toLocalDBString(){this.setTime(this.getTime()-this.getTimezoneOffset()*60*1000);return this.toISOString().replace(/T|Z/g,' ')}},toShortStr:{value:function toShortStr(){return this.getDate().pad(2)+'-'+(this.getMonth()+1).pad(2)+' '+this.getHours().pad(2)+':'+this.getMinutes().pad(2)}},toWeekDay:{value:function toWeekDay(){return this.getFullYear()+'-'+this.getWeek()+' '+day[this.getDay()]}}});Object.defineProperties(Number.prototype,{formatMoney:{value:function(c,d,t){var n=this,c=isNaN(c=Math.abs(c))?2:c,d=d==undefined?', ':d,t=t==undefined?'.':t,s=n<0?'-':'',i=parseInt(n=Math.abs(+n||0).toFixed(c))+'',j=(j=i.length)>3?j % 3:0;return s+(j?i.substr(0,j)+t:'')+i.substr(j).replace(/(\d{3})(?=\d)/g,'$1'+t)+(c?d+Math.abs(n-i).toFixed(c).slice(2):'')}},pad:{value:function(size){var s=String(this);while(s.length<(size||2)){s='0'+s}return s}}});Object.defineProperties(String.prototype,{capitalize:{value:function(){return this.charAt(0).toUpperCase()+this.slice(1)}},stripTags:{value:function(){return this.replace(/(<([^>]+)>)/gi,"")}}});Object.defineProperties(Object,{extend:{value:extend}});Object.defineProperties(JSON,{stringifyReplacer:{value:function stringifyReplacer(data,space){const getCircularReplacer=()=>{const seen=new WeakSet();return(key,value)=>{if(typeof value==="object"&&value!==null){if(seen.has(value)){return}seen.add(value)}return value}};return JSON.stringify(data,getCircularReplacer(),space)}}});YAML={stringify(selector){return JSON.stringify(selector,null,2).replace(/^\{|^ /gm,'').replace(/,\n/gs,'\n').replace(/\[(.*?)\]/gs,(s,p1)=>p1.replace(/^(.*?)"(.*?)": "(.*?)"Aim/gm,'$1$2: $3').replace(/^(.*?)"(.*?)":/gm,'$1$2:').replace(/(.*?)\{(.*?)(\w+)/gs,'$1- $3').replace(/^(.*?)"(.*?)"$/gm,'$1- "$2"')).replace(/(\},|\}|\{|\])(?=\n|$)/gs,'').replace(/"(.*?)":/g,'$1:').replace(/: "(.+?)"/g,': $1').replace(/- "(.+?)"/g,'- $1').replace(/^\s*\n/gms,'')}};__=function(){const translate=Aim.his.translate||new Map();return [].concat(...arguments).map(text=>{if(translate.has(text))return translate.get(text);text=String(text||'').replace(/^\w/,v=>v.toUpperCase()).replace(/([a-z])([A-Z])/g,(v,p1,p2)=>p1+' '+p2.toLowerCase()).replace(/_/g,' ');return text&&translate.has(text)?translate.get(text):(text||'')}).join(' ')};Crypto={base64_encode:function(obj){return this.btoajson(JSON.stringify(obj))},jwt_signature:function(base64_header,base64_payload,secret){var message=[base64_header,base64_payload].join('.');var signature=this.btoaToJson(CryptoJS.HmacSHA256(message,secret).toString(CryptoJS.enc.Base64));return signature},jwt_encode:function(payload,secret){var base64_header=this.base64_encode({typ:"JWT",alg:"sha256"});var base64_payload=this.base64_encode(payload);return [base64_header,base64_payload,this.jwt_signature(base64_header,base64_payload,secret)].join('.')},btoajson:function(s){return this.btoaToJson(btoa(s))},btoaToJson:function(s){return s.replace(/\+/g,'-').replace(/\=/g,'').replace(/\//g,"_")},decodeId:function(Id){if(!Id)return{};var a=Id.split('.');return JSON.parse(atob(a[1]||a[0]))}};function Request(url,base){if(!(this instanceof Request))return new Request(...arguments);this.url=this.url||new URL(url||'',base||(self.document?self.document.location.href:dmsOrigin));this.url.headers=this.url.headers||{};this.input.data=null}Object.defineProperties(Request.prototype,{body:{value:function(){this.returnBody=true;return this}},delete:{value:function(){this.method='delete';return this.http()}},accept:{value:function(selector){return this.headers('Accept',selector)}},exec:{value:function(){for([key,value] of this.url.searchParams){if(typeof Aim[key]==='function'){return Aim[key].apply(Aim,value?value.split(', '):[])||true}};console.error('EXEC',this.url.pathname);const getPathname=path=>{var [dummy,basePath,folder,sep,id]=path.match(/(.*?\/om|\/api|^)(\/.*?)(\/id\/|Aim)(.*)/);return [basePath,folder,sep,id]};var basePath,path,sep,id,newPath=[basePath,path,sep,id]=getPathname(this.url.pathname);if(path&&path!=='/'){var [root,tag,propertyName,attr]=path.match(/.*?\/(\w+\(\d+\))\/([\w_]+?)\((\.*?)\)/)||[];const item=Aim.his.map.get(tag)||{};if(item[propertyName]){return item[propertyName].apply(item,attr.split(','))}if(Aim().paths){const paths=Aim().paths;let replaceLocation=false;if(id){replaceLocation=true;try{[id]=atob(Aim.id=id.replace(/(\/.*)/,'')).match(/\/\w+\(.+?\)/);Aim(id).details().then(item=>Aim('view').show(item))}catch(err){return console.error('Illegal requestPath.id',id,paths)}}const method=this.method||'get';const folderTag=path.replace(/\(.*?\)/g,'()');let pathKey=Object.keys(paths).find(key=>key.replace(/\(.*?\)/g,'()')===folderTag);let apiPath=paths[pathKey];if(apiPath&&apiPath.get){replaceLocation=true;Aim().list([],path);if(this.url.searchParams.has('$search')&&!this.url.searchParams.get('$search')){console.error('NO SEARCH')}aimClient.api(path).query(this.url.searchParams.toString()).get().then(async body=>{if(body){const items=body.value||await body.children;Aim().list(items)}})}if(replaceLocation&&typeof document!=='undefined'){if(document.location.protocol==='file:'){var currentPath=getPathname(document.location.hash.substr(1));[basePath,path,sep,id]=currentPath.map((value,i)=>newPath[i]||value);var replacePath=['#',path,sep,id]}else{var currentPath=getPathname(document.location.pathname);var replacePath=currentPath.map((value,i)=>newPath[i]||value)}const search=this.url.searchParams.toString();var replacePath=replacePath.join('')+(search?'?'+search:'');Aim.his.replaceUrl(replacePath)}}if(this.paths_){var args=[];let pathKey=path.replace(/\((.+?)\)/g,'()');pathKey=Object.keys(Aim.paths).find(key=>key.replace(/\(([^\)]+)\)/g,'()')===pathKey);if(pathKey){const def=Aim.paths[pathKey][req.method.toLowerCase()]||Aim.paths[pathKey][req.method.toUpperCase()];console.error('pathKey',pathKey,def);if(!def){return console.error(req.method.toUpperCase(),req.toString(),'Method not allowed')}if(req.search){req.search.forEach((value,key)=>req.path=req.path.replace(key,value))}var args=path.match(/\(([^\)]+)\)/g);for(var i=0,arr=def.operationId.split(/\/|\./),name,obj;name=arr[i];i++){var objName=name.split('(').shift();console.error('objName',objName,obj,self[objName]);var parentObj=obj?obj:(self[objName]?self:(Aim.operations&&Aim.operations[objName]?Aim.operations:Item.items));console.error('parentObj',objName,parentObj);var nextArgument=args?args.shift():null;var param=nextArgument?nextArgument.replace(/\(|\)/g,'').split(', '):[];if(typeof parentObj[objName]==='function'){obj=parentObj[objName](...param)}else{obj=parentObj[objName]}}if(obj){console.debug('obj',obj);return obj}}}}return;return this}},filter:{value:function(){return this.query('$filter',...arguments)}},get:{value:function(){this.method='get';return this.http()}},getPath:{value:function(path){path=path||(this.url?this.url.pathname:'');var [dummy,basePath,folder,sep,id]=path.match(/(.*?\/om|\/api|^)(\/.*?)(\/id\/|Aim)(.*)/)||[];return [basePath,folder,sep,id]}},headers:{value:function(selector,context){if(typeof selector==='object'){Object.assign(this.url.headers,selector)}else{this.url.headers[selector]=context}return this}},authProvider:{value:function(authProvider){this.getAccessToken=authProvider.getAccessToken;return this}},http:{value:function(){return Aim.promise('http',async(resolve,reject)=>{if(this.getAccessToken){const access_token=await this.getAccessToken();this.headers('Authorization','Bearer '+access_token)}return typeof XMLHttpRequest!=='undefined'?this.web(resolve,reject):this.node(resolve,reject)})}},item:{value:function(callback){this.promise.then(e=>callback(e.body));return this}},data:{value:function(callback){this.promise.then(e=>callback(JSON.parse(e.target.responseText)));return this}},input:{value:function(param,formData=false){if(!param){return this.input.data}switch(param.constructor.name){case'CustomEvent':case'SubmitEvent':{param.preventDefault();this.input.data=new FormData(param.target);if(param.submitter){this.input.data.append(param.submitter.name,param.submitter.value)};break}case'HTMLFormElement':{this.input.data=new FormData(param);break}case'Elem':{this.input.data=new FormData(param.elem);break}case'Object':{if(formData){this.input.data=new FormData();Object.entries(param).forEach(entry=>this.input.data.append(...entry))}else{this.headers('Content-Type','application/json');this.input.data=JSON.stringifyReplacer(param)}break}case'Array':{if(formData){this.input.data=new FormData();Object.entries(param).forEach(entry=>this.input.data.append(...entry))}else{this.headers('Content-Type','application/json');this.input.data=JSON.stringifyReplacer(param)}break}default:{this.input.data=param;break}}return this}},setmethod:{value:function(method){this.method=method;return this}},node:{value:function(resolve){this.resolve=resolve;const input=this.input();if(input){this.headers('Content-Length',input.length)}const options={method:this.method,hostname:this.url.hostname,path:this.url.pathname+'?'+this.url.searchParams.toString(),headers:this.url.headers,patch:input};const url=this.url.toString();const protocol=url.split(':').shift();const HTTP=require(protocol);const xhr=HTTP.request(options,e=>{e.target=xhr;e.target.request=this;e.target.responseText='';e.on('data',function(data){e.target.responseText+=data}).on('end',()=>{e.status=e.statusCode;e.statusText=e.statusMessage;try{e.body=e.headers['content-type'].includes('application/json')?JSON.parse(e.target.responseText):e.target.responseText;e.response=e.body=e.body}catch(err){console.debug('ERROR JSON',err,e.target.responseText.substr(0,1000))}resolve(e)})}).on('error',e=>{console.debug('ERROR')});if(input){xhr.write(input)}xhr.startTime=new Date();xhr.end();return xhr}},onerror:{value:function(e){console.msg('HTTP ON ERROR',e)}},onload:{value:function(e){((e.body||{}).responses||[e]).forEach(res=>res.body=Aim().evalData(res.body));if(this.statusElem){this.statusElem.remove()}if(Aim.config.debug&&e.target.status<400||isModule){console.debug(this.method.toUpperCase(),this.url.toString(),e.target.status,e.target.statusText,e.target.responseText.length,'bytes',new Date().valueOf()-e.target.startTime.valueOf(),'ms')}}},onprogress:{value:function(e){console.debug('onprogressssssssssssssssssssss',e.type,e);var msg=`%c${this.method} ${this.responseURL} ${this.status} (${this.statusText}) ${this.response.length} bytes ${new Date().valueOf() - this.startTime.valueOf()}ms`;if(this.elStatus){this.elStatus.innerText=decodeURIComponent(this.msg)+' '+e.loaded+'Bytes'}}},order:{value:function(){return this.query('$order',...arguments)}},post:{value:function(param){this.method='post';if(param){this.input(param,true)}return this.http()}},patch:{value:function(data){this.method='post';this.input(data);return this.http()}},query:{value:function(selector,context){if(selector instanceof Object){Object.entries(selector).forEach(entry=>this.query(...entry))}else if(arguments.length===1){const search=new URLSearchParams(selector);search.forEach((value,key)=>this.url.searchParams.set(key,value))}else{this.url.searchParams.set(...arguments)}return this}},setParam:{value:function(name,value){this.props=this.props||[];this.props[name]=value}},servers:{value:function(servers){if(servers&&servers.length){url(servers[0].url)}}},select:{value:function(){return this.query('$select',...arguments)}},toString:{value:function(){return this.url.toString()}},top:{value:function(){return this.query('$top',...arguments)}},web:{value:function(resolve,reject){const xhr=new XMLHttpRequest();xhr.request=this;const url=this.url.toString();xhr.open(this.method,url);xhr.addEventListener('load',e=>{if(xhr.elLoadlog){xhr.elLoadlog.appendTag('span','',new Date().toLocaleString())}if(xhr.waitfolder){self.collist.setAttribute('wait',Number(self.collist.getAttribute('wait'))-1)}e.body=xhr.response;if(this.url.headers.accept==='application/json'||xhr.getResponseHeader('content-type').includes('application/json')){try{e.body=JSON.parse(e.body)}catch(err){console.error('JSON error',xhr,xhr.response.substr(0,5000))}}if(xhr.status>=400){const elem=Aim(document.body).append(Aim('pre').class('message error').text(`${xhr.status} (${xhr.statusText})\n${e.body && e.body.error ? e.body.error.message : ''}\n${this.method.toUpperCase()} ${decodeURI(xhr.request.url.href)}`).on('click',e=>e.target.remove()));return reject(e)}this.onload(e);resolve(this.returnBody?e.body:e)});if(Aim.his.elem.statusbar){xhr.total=xhr.loaded=0;xhr.addEventListener('loadend',e=>{Aim().progress(-xhr.loaded,-xhr.total)});if(xhr.upload){xhr.addEventListener('progress',e=>{const loaded=e.loaded-xhr.loaded;xhr.loaded=e.loaded;if(!xhr.total){Aim().progress(0,xhr.total=e.total)}Aim().progress(loaded)})}}Object.entries(this.url.headers).forEach(entry=>xhr.setRequestHeader(...entry));xhr.startTime=new Date();xhr.send(this.input.data)}}});function Aim(selector,context){if(Aim.Elem&&selector instanceof Aim.Elem)return selector;if(!(this instanceof Aim))return new Aim(...arguments);if(selector){if(self.Item&&selector instanceof self.Item){return selector}this.selector=selector}selector=selector||'Aim';if(['string','number'].includes(typeof selector)){if(Aim.his.map.has(selector)){selector=Aim.his.map.get(selector);if(context)Aim(selector).extend(context);return selector}else if(self.document){const element=document.getElementById(selector);selector=element?element:(Aim.Elem&&Aim.Elem.tagnames.includes(selector)?document.createElement(selector):selector)}}if(self.Element&&selector instanceof self.Element){if(Aim.his.map.has(selector.id))return Aim.his.map.get(selector.id);if(Aim.Elem){selector=new Aim.Elem(selector,...[...arguments].slice(1));if(selector.elem.id){Aim.his.map.set(selector.elem.id,selector)}}return selector}if(typeof selector==='string'){if(selector.match(/\w+\(\d+\)/)){return Item.get(selector)}else{this.id(selector)}}else if(typeof Window!=='undefined'&&selector instanceof Window){return this}else if(selector.ID||selector.LinkID||selector.tag){return Item.get(selector)}this.extend(context)};Object.defineProperties(Aim.prototype,{access_token:{value:function(){return this.set('access_token',...arguments)}},auth:{value:function(context){console.error('AUTH',context);return this.get(AuthProvider,{auth:context})}},account_config:{value:function(config,extend,save){const panel=Aim('form').class('col').style('position:absolute;margin:auto;left:0;right:0;top:0;bottom:0;background-color:white;z-index:200;').parent(Aim('list'));const tabControl=Aim('div').parent(panel).class('row top btnbar');const pageControl=Aim('div').parent(panel).class('row aco').style('height:100%;');function upload(){configInput.elem.value=configText.elem.innerText;aimClient.api('/').post(panel).then(body=>{console.debug("API",body)})}const page=Aim('div').parent(pageControl).class('aco oa col').css('margin:auto;position:absolute;top:0;bottom:0;left:0;right:0;').css('background-color:var(--bg);');const configText=Aim('pre').parent(page).class('aco').css('margin:0;padding:0 10px;outline:none;').text(config.replace(/^---\n/,'').replace(/\n\.\.\./,'').trim()).contenteditable('').spellcheck(false).on('keydown',e=>{if(e.key==="s"&&e.ctrlKey){e.preventDefault();upload()}if(e.key=='Tab'&&!e.ctrlKey&&!e.shiftKey&&!e.altKey){document.execCommand('insertHTML',false,'&#009');e.preventDefault()}});const configInput=Aim('input').parent(page).name('config').type('hidden');function focus(){[...pageControl.elem.children].forEach(elem=>elem.style.display='none');page.elem.style.display=''}function close(){page.remove();tab.remove();if(!tabControl.elem.innerText){panel.remove()}}const tab=Aim('div').parent(tabControl).append(Aim('span').text('config.yaml').on('click',focus),Aim('input').type('checkbox').name('extend').id('expand').checked(extend),Aim('label').text('extend').for('expand'),Aim('button').class('abtn close').on('click',close));focus();if(save)upload()}},analytics:{value:function(){(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(self,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create',{trackingId:'UA-28018977-1',cookieDomain:'auto'});ga('send','pageview')}},copyFrom:{value:function(source,master,index){return Aim.promise('copyFrom',resolve=>{const [s,schemaName,sourceId]=source.tag.match(/(\w+)\((\d+)\)/);console.warn(schemaName,source,master);const item={header0:source.header0,Src:{LinkID:sourceId},Class:{LinkID:!source.Class||!source.Class.LinkID===0?sourceId:source.Class.LinkID}};if(master){master.attr('HasChildren',1,true);item.Master={LinkID:master.data.ID,Data:index===undefined?(master.items?master.items.length:0):index}}console.debug('COPY START',item);aimClient.api(`/${schemaName}`).input(item).post().then(item=>{item.details().then(async item=>{console.debug('COPY START',item);await item.clone();if(master){if(master.items){master.items.push(item);await master.reindex();if(master.elemTreeLi.elem.open){master.elemTreeLi.emit('toggle')}else{master.elemTreeLi.elem.open=true}}}console.debug('COPY END',item);resolve(item)})})})}},clone:{value:function(obj){return JSON.parse(JSON.stringify(obj))}},cam:{value:function(){const elem=document.head.appendChild(document.createElement('script'));elem.setAttribute('src',Aim.config.apiPath+'/js/cam.js')}},components:{value:function(components){return this.extend(components)}},connector:{value:function(){Object.assign(this,{external(name,args,callback){let params={to:{sid:Aim.Aliconnector.connector_id},external:{}};params.external[name]=Array.isArray(args)?args:(args?[args]:[]);Aim.Aliconnector.callback=callback;wsClient.send(JSON.stringify(params))},reply(par){if(Aim.Aliconnector.callback){Aim.Aliconnector.callback(par)}Aim.Aliconnector.callback=null},printurl(url){this.external('printurl',url,par=>{console.debug('PRINT REPLY',par)})},hide(){this.external('hide',null,par=>{console.debug('HIDE REPLY',par)})},show(){this.external('show',null,par=>{console.debug('SHOW REPLY',par)})},filedownload(par){this.external('filedownload',"http://alicon.nl"+par,par=>{console.debug('SHOW REPLY',par)})},mailimport(){this.external('show',null,par=>{console.debug('SHOW REPLY',par)})},contactimport(){this.external('show',null,par=>{console.debug('SHOW REPLY',par)})}})}},cookies:{value:function(){Aim().on({async load(){if(!localStorage.getItem('cookieSettings')){const elem=Aim('div').parent(document.body).class('cookieWarning').text('Opslag van uw gegevens').append(Aim('button').text('Werkende website').on('click',e=>{localStorage.setItem('cookieSettings','session');elem.remove()}),Aim('button').text('Allen voor u persoonlijk').on('click',e=>{localStorage.setItem('cookieWarning','private');elem.remove()}),Aim('button').text('Delen met onze organisatie').on('click',e=>{localStorage.setItem('cookieWarning','shared');elem.remove()}),Aim('a').text('Cookie beleid').href('#?l=//aliconnect.nl/aliconnect/wiki/Explore-Legal-Cookie-Policy'))}return this}})}},create:{value:function(){this.selector=this.selector.createElement(...arguments);return this}},client_get:{value:function(){return clients}},css:{value:function(selector,context){if(document){if(selector instanceof Object){Object.entries(selector).forEach(entry=>arguments.callee(...entry))}else{document.querySelector('html').style.setProperty('--'+selector,context)}}return this}},data:{value:function(data){Item.get(data);return this}},document:{value:function(mainElem,buttons){Aim('doc').append(this.pageElem=Aim('div').class('col doc').append(Aim('div').class('row top stickybar').append(Aim('span').class('aco'),Aim('button').class('abtn pdf').on('click',async e=>{const html='<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>'+this.docElem.elem.innerHTML;Aim().url(dmsUrl+'/?request_type=pdf').post(html).then(e=>{const elem=Aim('div').parent(this.pageElem).class('col abs').append(Aim('div').class('row top btnbar').append(Aim('button').class('abtn close').on('click',e=>elem.remove())),Aim('iframe').class('aco').src(e.body.src))})}),Aim('button').class('abtn close').on('click',e=>this.pageElem.remove())),Aim('div').class('row aco').append(this.leftElem=Aim('div').class('mc-menu left np oa').append(),Aim('div').class('aco col').on('click',e=>{const href=e.target.getAttribute('href');if(href&&href.match(/^http/)){e.stopPropagation();e.preventDefault();self.history.pushState('page','','?l='+url_string(href));const panel=Aim('div').parent(elem.docElem).class('col abs').append(elem.elemBar=Aim('div').class('row top abs btnbar').append(Aim('span').class('aco'),Aim('button').class('abtn close').on('click',e=>panel.remove())),Aim('iframe').src(href))}}).append(Aim('nav').class('row docpath').append(Aim('small').id('navDoc')),this.docNavTop=Aim('nav').class('row dir'),this.docElem=mainElem.class('doc-content aco')),Aim('div').class('mc-menu right np oa').append(Aim('div').class('ac-header').text('Table of contents'),this.indexElem=Aim('ul').index(this.docElem)))));this.pageElem.elem.doc=this;return this}},dashboard:{value:function(){const panel=Aim('div').panel();aimClient.api('/').query('request_type','personal_dashboard_data_domain').get().then(body=>{panel.elemMain.class('dashboard').append(Aim('div').class('row wrap').append(...body.map(row=>Aim('div').class('col').append(Aim('h1').text(row.schemaPath),...row.items.map(item=>Aim('a').text(item.header0).on('click',e=>Aim('view').show(Aim(`${row.schemaPath}(${item.id})`)))))),...[0,0,0,0,0,0,0,0,0].map(a=>Aim('div').class('ghost'))))})}},emit:{value:async function aimEmit(type,context){const selector=this.elem||this.selector||this;if(selector.addEventListener){let e;if(typeof(Event)==='function'){e=new Event(type)}else{e=document.createEvent('Event');e.initEvent(selector,true,true)}if(typeof context==='object'){delete context.path;Object.assign(e,context)}await selector.dispatchEvent(e)}else{if(selector.eventListeners&&selector.eventListeners.has(type)){const eventListener=selector.eventListeners.get(type);for(const i in eventListener){await eventListener[i](context||{})}}}return this}},evalData:{value:function(data){if(data instanceof Object){if(Array.isArray(data.value)){data.value=data.value.map(data=>Item.get(data))}else if(data['@id']){data=Item.get(data)}}return data}},eventHandle:{value:null},elements:{get(){if(isModule){return []}return this.props&&(this.props[0] instanceof Object)?Object.values(this.props[0]).filter(value=>value instanceof Element):[]}},extend:{value:function extend(){Aim.extend(this.elem||this.selector||this,...arguments);return this}},extendConfig:{value:function(yaml){return aimClient.api('/').query('extend',true).post({config:yaml})}},execQuery:{value:function(selector,context,replace){console.error('execQuery',selector,context,replace);const currentUrl=new URL(document.location.origin);var url=new URL(document.location);if(typeof selector==='object'){Object.entries(selector).forEach(entry=>url.searchParams.set(...entry))}else{url.searchParams.set(selector,context)}if(url_string(currentUrl.href)!==url_string(url.href)){this.execUrl(url_string(url.href));if(replace){self.history.replaceState('page','',url_string(url.href))}else{self.history.pushState('page','',url_string(url.href))}}return this}},execUrl:{value:function(url){console.warn('execUrl',url);const documentUrl=new URL(document.location);url=new URL(url,document.location);if(url.hash){if(this.execUrl(url.hash.substr(1))){Aim.his.mergeState(url.hash.substr(1));return}}if(url.searchParams.get('l')){documentUrl.searchParams.set('l',url.searchParams.get('l'));const listUrl=idToUrl(url.searchParams.get('l'));const hostname=new URL(listUrl).hostname;const client=Client.clients.get(hostname);if(client){client.api(listUrl).get().then(async body=>{const items=body.value||body.Children||await body.children;console.warn('BODY',body.value,body.Children,items);Aim().list(items)})}else{Aim('list').load(refurl.href)}}if(url.searchParams.get('v')&&url.searchParams.get('v')!==documentUrl.searchParams.get('v')){documentUrl.searchParams.set('v',url.searchParams.get('v'));if(url.searchParams.get('v')){var refurl=new URL(idToUrl(url.searchParams.get('v')),document.location);if(refurl.hostname.match(/^dms\./)){aimClient.api(refurl.href).get().then(async body=>Aim('view').show(body))}}else{Aim('view').text('')}}for([key,value] of url.searchParams){if(typeof Aim[key]==='function'){return Aim[key].apply(Aim,value?value.split(', '):[])||true}}self.history.replaceState('page','',documentUrl.href)}},forEach:{value:function(selector,context,fn){if(selector instanceof Object){Object.entries(selector).forEach(entry=>fn.call(this,...entry))}else{fn.call(this,selector,context)}return this}},ga:{value:function(){if(self.ga){ga(arguments)}return this}},get:{value:function(selector,options){this.props=this.props||new Map();if(!selector)return this.props;const name=selector.name||selector;if(!this.props.has(name)){options=typeof options==='string'?Aim(options):options}return this.props.get(name)}},getApi:{value:function getApi(url){return Aim.promise('getApi',resolve=>this.url(url).get().then(e=>{console.debug('GET',JSON.parse(e.target.responseText));Aim(this).extend(e.body);resolve(e)}))}},getObject:{value:function getObject(name,constructor,args){const props=this.props=this.props||new Map();if(!props.has(name)){props.set(name,new constructor(...args))}else if(!args.length){return props.get(name)}else{props.get(name).show(...args)}return this}},has:{value:function(selector){return this.props&&this.props.has(selector)}},id:{value:function(selector){this.key=selector;this.set('id',selector);Aim.his.map.set(selector,this);return this}},login:{value:async function(){var url=new URL(this.server?this.server.url:'/api',dmsOrigin);if(this.authProvider().access&&this.authProvider().access.iss){url.hostname=this.authProvider().access.iss}clients.set(url.hostname,this);if(this.ws().url){await this.ws().connect()}if(this.authProvider()){await this.authProvider().login(...arguments);if(this.ws()){await this.ws().login(this.authProvider().getAccessToken())}}return this}},list:{value:function(selector){return this.getObject(arguments.callee.name,Listview,[...arguments])}},message:{get(){const [basePath,folder,sep,id]=this.getPath();return{method:this.req.method,url:[folder,this.url.searchParams.toString()].filter(Boolean).join(''),body:this.req.input,to:this.to}}},msa:{value:function(){return Aim.msa=Aim.msa||new Msa(...arguments)}},nav:{value:function(){return nav}},notify:{value:function(title,options){return;if("Notification"in self){if(Notification.permission==="granted"){options={body:`Bla Bla`,url:'https://moba.aliconnect.nl?test=1',icon:'https://aliconnect.nl/favicon.ico',image:'https://aliconnect.nl/shared/265090/2020/07/09/5f0719fb8fa69.png',data:{href:document.location.href,url:document.location.href}};var notification=new Notification(title,options);notification.onclick=function(e){}}}}},noPost:{value:function(fn){Aim.his.noPost=true;fn();Aim.his.noPost=false}},on:{value:function(type,context,useCapture){const selector=this.elem||this.selector||this;this.forEach(type,context,(type,context)=>{if(selector.addEventListener){selector.addEventListener(type,context,useCapture)}else{const eventListeners=selector.eventListeners=selector.eventListeners||new Map();if(!eventListeners.has(type))eventListeners.set(type,[]);const eventListener=eventListeners.get(type);if(!eventListener.includes(context)){eventListener.push(context)}}});return this}},onload:{value:function(e){if(Aim.config.debug&&e.target.status<400||isModule){console.debug(this.props('method').toUpperCase(),this.props('url').toString(),e.target.status,e.target.statusText,e.target.responseText.length,'bytes',new Date().valueOf()-this.startTime.valueOf(),'ms')}(e.body.responses||[e]).forEach((res,i)=>{if(res&&res.body){}});this.resolve(e)}},pdfpages:{value:function(selector){return Aim.promise('pdf-pages',resolve=>{let pages=[];function read_pages(pdf){Aim().progress(0,pdf.numPages);(function getPage(pageNumber){pdf.getPage(pageNumber).then(function(page){page.getTextContent({normalizeWhitespace:true,disableCombineTextItems:false}).then(item=>{pages.push(item.items);if(pageNumber<pdf.numPages){Aim().progress(pageNumber);setTimeout(()=>getPage(++pageNumber),0)}else{resolve(pages)}})})})(1)}if(selector instanceof File){var fileReader=new FileReader();fileReader.onload=function(e){const array=new Uint8Array(e.target.result);pdfjsLib.getDocument({data:array}).promise.then(read_pages)};fileReader.readAsArrayBuffer(selector)}else{pdfjsLib.getDocument(selector).promise.then(read_pages)}})}},panel:{value:function(){return Aim('div').panel()}},procstate:{value:function(selector){return Aim('div').class('procstate').text(selector)}},progress:{value:function(value=0,max=0){if(Aim.his.elem.statusbar){value=Aim.his.elem.statusbar.progress.elem.value=(Aim.his.elem.statusbar.progress.elem.value||0)+value;max=Aim.his.elem.statusbar.progress.elem.max=(Aim.his.elem.statusbar.progress.elem.max||0)+max;Aim.his.elem.statusbar.progress.max(max).value(value||null).attr('proc',max?Math.round(value / max*100):null)}}},popupmenuitems:{value:function(item){return;var itemmenu=Aim.menuitems;if(item.attributes&&item.attributes.state&&item.attributes.state.options){itemmenu.state.menu=item.attributes.state.options}return itemmenu}},schemas:{value:function schemas(selector,context){if(!selector)return this.get('schemas');if(selector instanceof Object){return Object.entries(selector).forEach(entry=>this.schemas(...entry))}else{const schemas=this.get('schemas')||this.set('schemas',new Map()).get('schemas');selector=validSchemaName(selector);if(!schemas.has(selector)){if(!self[selector]){eval(`${selector} = function (){}`)}const constructor=self[selector];Object.values(context.properties=context.properties||{}).forEach(property=>{if(property.enum&&typeof property.enum==='object'){property.options=property.enum}if(property.options){property.options=Object.fromEntries(Object.entries(property.options).map(([optionName,option])=>[optionName,typeof option==='object'?option:{title:option}]));property.enum=Object.keys(property.options);if(property.enum.length===2&&Object.values(property.options).filter(Boolean).length===1){property.format='checkbox'}}});context.allOf=context.allOf||['Item'];const allOf=context.allOf||[];var allContext={};allOf.forEach(name=>{if(schemas.has(name)){allContext=extend(allContext,schemas.get(name))}});context=extend(allContext,context);this.schemas[selector]=context=extend(allContext,context);schemas.set(selector,context);if(selector!=='Item'){constructor.prototype=Object.create(Item.prototype,Object.getOwnPropertyDescriptors(Item.prototype))}for(let [propertyName,property] of Object.entries(context.properties||{})){property.name=propertyName;if(!constructor.prototype.hasOwnProperty(propertyName)){Object.defineProperty(constructor.prototype,propertyName,typeof property.value==='function'?{value:new Function(property.value.replace(/^value\(\) \{|\}Aim/g,''))}:{get(){return this.getValue(propertyName)},set(value){this.attr(propertyName,value,true)}})}}Object.defineProperties(constructor.prototype,{schema:{value:context,writable:true},schemaName:{value:selector,writable:true}})