nextcloud / calendar

📆 Calendar app for Nextcloud
https://apps.nextcloud.com/apps/calendar
GNU Affero General Public License v3.0
967 stars 236 forks source link

handle 500 of server when fetching events #359

Closed MisterCutely closed 7 years ago

MisterCutely commented 7 years ago

Steps to reproduce

  1. Login nextcloud
  2. Start calendar

Expected behaviour

Both calenders should be shown with all dates.

Actual behaviour

The dates of one calendar are missing and the circle befor the calendar name is spinning.

Server configuration

Operating system: Hoster is all-inkl, don´t know which OS.

Database: Myphp

PHP version: 7.1.1.

Server version: 11.0

Calendar version: 1.5.1 (also on 1.5.0 and 1.4.1)

Updated from an older installed version or fresh install: updated version

List of activated apps: Tasks, Mail, contacts,

Are you using encryption: no

Logs

Web server error log

Sabre\VObject\InvalidDataException: Unsupported VALUE parameter for DTEND property. You supplied "" /www/htdocs/.../cloud/3rdparty/sabre/vobject/lib/Parser/MimeDir.php - line 453: Sabre\VObject\Document->createProperty('DTEND', NULL, Array) /www/htdocs/.../cloud/3rdparty/sabre/vobject/lib/Parser/MimeDir.php - line 234: Sabre\VObject\Parser\MimeDir->readProperty('DTEND;TZID=Euro...') /www/htdocs/.../cloud/3rdparty/sabre/vobject/lib/Parser/MimeDir.php - line 217: Sabre\VObject\Parser\MimeDir->parseLine('DTEND;TZID=Euro...') /www/htdocs/.../cloud/3rdparty/sabre/vobject/lib/Parser/MimeDir.php - line 181: Sabre\VObject\Parser\MimeDir->parseLine('BEGIN VEVENT') /www/htdocs/.../cloud/3rdparty/sabre/vobject/lib/Parser/MimeDir.php - line 89: Sabre\VObject\Parser\MimeDir->parseDocument() /www/htdocs/.../cloud/3rdparty/sabre/vobject/lib/Reader.php - line 46: Sabre\VObject\Parser\MimeDir->parse('BEGIN VCALENDAR...', 0) /www/htdocs/.../cloud/3rdparty/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php - line 142: Sabre\VObject\Reader read('BEGIN VCALENDAR...') /www/htdocs/.../cloud/apps/dav/lib/CalDAV/CalDavBackend.php - line 1123: Sabre\CalDAV\Backend\AbstractBackend->validateFilterForObject(Array, Array) /www/htdocs/.../cloud/apps/dav/lib/CalDAV/Calendar.php - line 248: OCA\DAV\CalDAV\CalDavBackend->calendarQuery('2', Array) /www/htdocs/.../cloud/3rdparty/sabre/dav/lib/CalDAV/Plugin.php - line 624: OCA\DAV\CalDAV\Calendar->calendarQuery(Array) /www/htdocs/.../cloud/3rdparty/sabre/dav/lib/CalDAV/Plugin.php - line 250: Sabre\CalDAV\Plugin->calendarQueryReport(Object(Sabre\CalDAV\Xml\Request\CalendarQueryReport)) [internal function] Sabre\CalDAV\Plugin->report('{urn ietf param...', Object(Sabre\CalDAV\Xml\Request\CalendarQueryReport), 'calendars/Benny...') /www/htdocs/.../cloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array) /www/htdocs/.../cloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 718: Sabre\Event\EventEmitter->emit('report', Array) [internal function] Sabre\DAV\CorePlugin->httpReport(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response)) /www/htdocs/.../cloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array) /www/htdocs/.../cloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 479: Sabre\Event\EventEmitter->emit('method REPORT', Array) /www/htdocs/.../cloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response)) /www/htdocs/.../cloud/apps/dav/lib/Server.php - line 227: Sabre\DAV\Server->exec() /www/htdocs/.../cloud/apps/dav/appinfo/v2/remote.php - line 30: OCA\DAV\Server->exec() /www/htdocs/.../cloud/remote.php - line 165: require_once('/www/htdocs/w00...')

Also on: https://help.nextcloud.com/t/calendar-app-one-calendar-makes-an-error/9834

georgehrke commented 7 years ago

please provide javascript logs. That's especially important here.

MisterCutely commented 7 years ago

Sorry, don´t know how. Think i got it. {"reqId":"WL-7bVUNm@kAADQqKwoAAAAA","remoteAddr":"141.113.11.13","app":"webdav","message":"Exception: {\"Message\":\"Unsupported VALUE parameter for DTEND property. You supplied \\\"\\\"\",\"Exception\":\"Sabre\\\\VObject\\\\InvalidDataException\",\"Code\":0,\"Trace\":\"#0 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/vobject\\\/lib\\\/Parser\\\/MimeDir.php(453): Sabre\\\\VObject\\\\Document->createProperty('DTEND', NULL, Array)\\n#1 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/vobject\\\/lib\\\/Parser\\\/MimeDir.php(234): Sabre\\\\VObject\\\\Parser\\\\MimeDir->readProperty('DTEND;TZID=Euro...')\\n#2 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/vobject\\\/lib\\\/Parser\\\/MimeDir.php(217): Sabre\\\\VObject\\\\Parser\\\\MimeDir->parseLine('DTEND;TZID=Euro...')\\n#3 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/vobject\\\/lib\\\/Parser\\\/MimeDir.php(181): Sabre\\\\VObject\\\\Parser\\\\MimeDir->parseLine('BEGIN:VEVENT')\\n#4 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/vobject\\\/lib\\\/Parser\\\/MimeDir.php(89): Sabre\\\\VObject\\\\Parser\\\\MimeDir->parseDocument()\\n#5 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/vobject\\\/lib\\\/Reader.php(46): Sabre\\\\VObject\\\\Parser\\\\MimeDir->parse('BEGIN:VCALENDAR...', 0)\\n#6 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/CalDAV\\\/Backend\\\/AbstractBackend.php(142): Sabre\\\\VObject\\\\Reader::read('BEGIN:VCALENDAR...')\\n#7 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/apps\\\/dav\\\/lib\\\/CalDAV\\\/CalDavBackend.php(1123): Sabre\\\\CalDAV\\\\Backend\\\\AbstractBackend->validateFilterForObject(Array, Array)\\n#8 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/apps\\\/dav\\\/lib\\\/CalDAV\\\/Calendar.php(248): OCA\\\\DAV\\\\CalDAV\\\\CalDavBackend->calendarQuery('2', Array)\\n#9 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/CalDAV\\\/Plugin.php(624): OCA\\\\DAV\\\\CalDAV\\\\Calendar->calendarQuery(Array)\\n#10 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/CalDAV\\\/Plugin.php(250): Sabre\\\\CalDAV\\\\Plugin->calendarQueryReport(Object(Sabre\\\\CalDAV\\\\Xml\\\\Request\\\\CalendarQueryReport))\\n#11 [internal function]: Sabre\\\\CalDAV\\\\Plugin->report('{urn:ietf:param...', Object(Sabre\\\\CalDAV\\\\Xml\\\\Request\\\\CalendarQueryReport), 'calendars\\\/Benny...')\\n#12 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#13 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(718): Sabre\\\\Event\\\\EventEmitter->emit('report', Array)\\n#14 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpReport(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#15 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#16 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:REPORT', Array)\\n#17 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#18 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/apps\\\/dav\\\/lib\\\/Server.php(227): Sabre\\\\DAV\\\\Server->exec()\\n#19 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/apps\\\/dav\\\/appinfo\\\/v2\\\/remote.php(30): OCA\\\\DAV\\\\Server->exec()\\n#20 \\\/www\\\/htdocs\\\/...\\\/cloud\\\/remote.php(165): require_once('\\\/www\\\/htdocs\\\/w00...')\\n#21 {main}\",\"File\":\"\\\/www\\\/htdocs\\\/...\\\/cloud\\\/3rdparty\\\/sabre\\\/vobject\\\/lib\\\/Document.php\",\"Line\":220,\"User\":\"Benny\"}","level":4,"time":"2017-03-08T12:39:10+00:00","method":"REPORT","url":"\/remote.php\/dav\/calendars\/Benny\/bennyoccalendar\/","user":"Benny","version":"11.0.0.10"}

georgehrke commented 7 years ago

Would be easier to help you if you filled out the entire issue template and told us what browser you use ;)

georgehrke commented 7 years ago

Think i got it.

No, that looks like the nextcloud.log. That's wrong. What browser do you use? :)

georgehrke commented 7 years ago

Unsupported VALUE parameter for DTEND property.

Though this definitely looks related.

MisterCutely commented 7 years ago

Good morning, i´m using firefox (V 51) and also testet with internet explorer. Same problems on both.

config.php is the original. No changes.

GET https://.../index.php/apps/calendar/ [HTTP/1.1 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) 7ms] GET https://.../apps/calendar/css/public/app.min.css [HTTP/1.1 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) 6ms] GET https://.../apps/calendar/css/public/app.min.css [HTTP/1.1 407 Proxy Authentication Required ( Access is denied. ) 5ms] JQMIGRATE: Migrate is installed, version 1.4.0 jquery-migrate.min.js:2:542 "Deprecation warning: use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info." moment-with-locales.js:282:13 POST XHR https://.../index.php/apps/calendar/v1/config [HTTP/1.1 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) 6ms] POST XHR https://.../index.php/apps/calendar/v1/config [HTTP/1.1 407 Proxy Authentication Required ( Access is denied. ) 4ms] REPORT XHR https://.../remote.php/dav/calendars/Benny/pers%c3%b6nlich_shared_by_Hoppel/ [HTTP/1.1 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) 6ms] REPORT XHR https://.../remote.php/dav/calendars/Benny/pers%c3%b6nlich_shared_by_Hoppel/ [HTTP/1.1 407 Proxy Authentication Required ( Access is denied. ) 5ms] /remote.php/dav/calendars/Benny/bennyoccalendar/ 500

MisterCutely commented 7 years ago

Is it a good idea to update my nextcloud to 11.0.2? Or is it better to wait until the error is fixed? Maybee there is the need of some more tests or informations?

MisterCutely commented 7 years ago

Synchronising Data from my Smartphone via DavDroid is possible. I took a look in the Database and the new event is available.

georgehrke commented 7 years ago

Is it a good idea to update my nextcloud to 11.0.2?

It won't do anything about this bug. Feel free to update.

Maybee there is the need of some more tests or informations?

please provide proper javascript logs :) https://developer.mozilla.org/en-US/docs/Tools/Browser_Console#Opening_the_Browser_Console

MisterCutely commented 7 years ago

So here is the log :-) Hope it helps you.

"Deprecation warning: use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info." moment-with-locales.js:282 NS_BINDING_ABORTED: Component returned failure code: 0x804b0002 (NS_BINDING_ABORTED) [nsIStreamListener.onDataAvailable] WebRequest.jsm:231 Das textContent-Attribut von Attributen sollte nicht mehr verwendet werden. Verwenden Sie value stattdessen. app.min.js:2:4429 /remote.php/dav/calendars/Benny/bennyoccalendar/ 500 app.min.js:2 A promise chain failed to handle a rejection. Did you forget to '.catch', or did you forget to 'return'? See https://developer.mozilla.org/Mozilla/JavaScript_code_modules/Promise.jsm/Promise Date: Fri Mar 17 2017 07:29:31 GMT+0100 Full Message: Error: page-thumbnail:error Full Stack: observe@resource://gre/modules/BackgroundPageThumbs.jsm:116:22 BackgroundPageThumbs._onCaptureOrTimeout@resource://gre/modules/BackgroundPageThumbs.jsm:305:7 Capture.prototype._done/done@resource://gre/modules/BackgroundPageThumbs.jsm:451:7 Capture.prototype._done@resource://gre/modules/BackgroundPageThumbs.jsm:471:7 Capture.prototype.notify@resource://gre/modules/BackgroundPageThumbs.jsm:428:5 BackgroundPageThumbs.jsm:116

MisterCutely commented 7 years ago

Is there a workaround or something, so i can fix the problem?

georgehrke commented 7 years ago

app.min.js:2:4429 /remote.php/dav/calendars/Benny/bennyoccalendar/ 500

You have some terribly broken event in your database. The server is supposed to properly catch errors and not fail (as in return a 500).

Did you add some event or import events before the calendar stopped working?

Furthermore, please report a second bug in https://github.com/nextcloud/server about the 500 error.

MisterCutely commented 7 years ago

No, i updated the app and the calendar stopped working. But only direct in nextcloud. From my mobile phone there is no Problem. I checked it in the database. So new dates are in the database. I think there is an older event which makes the problem. But how will i find it?

georgehrke commented 7 years ago

Does the calendar load in other months?

MisterCutely commented 7 years ago

Yes, only march makes the problem, i think.

Is it possible, that an imported "apple" event makes the problem? So i should delet all events in this month and hope it works after that?

Edit: There are more months which have this error!

Edit 2: The error exists also in October 2016. From my mobilephone, i deleted all events in October 2016 but error is still available.

georgehrke commented 7 years ago

@MisterCutely Did you report a bug in the server repo yet?

georgehrke commented 7 years ago

Ah, I remember you did.

https://github.com/nextcloud/server/issues/4014

alexdtag commented 7 years ago

I had the same issue. I applied the following datafix to my nextcloud database which seemed to fix it:

UPDATE oc_calendarobjects SET calendardata = REPLACE(calendardata, 'DTEND;VALUE=;TZID', 'DTEND;TZID') WHERE calendardata LIKE '%DTEND;VALUE=;TZID%';

MisterCutely commented 7 years ago

Tried to update my database, but the code doesn´t channge anything. No Dataset is updated and the error is still available.

MisterCutely commented 7 years ago

Hi, i´ve updated the calendar app to version 1.5.3. and the error is still there. So i have do add code myself? Java console contains:

!function(e,r,n,a){"use strict";function i(e){return Array.isArray(e)?e:Array.from(e)}var o=e.module("Calendar",["ui.bootstrap"]),l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.config(["$provide","$httpProvider",function(t,a){a.defaults.headers.common.requesttoken=n,ICAL.design.defaultSet.param["x-oc-group-id"]={allowXName:!0},e.forEach(r.fullCalendar.locales,function(t,n){r.fullCalendar.locale(n,{timeFormat:t.mediumTimeFormat});var a=["extraSmallTimeFormat","hourFormat","mediumTimeFormat","noMeridiemTimeFormat","smallTimeFormat"];e.forEach(a,function(e){if(t[e]){var a={};a[e]=t[e].replace("HH","H"),r.fullCalendar.locale(n,a)}})});var i="yes"===e.element("#fullcalendar").attr("data-firstRun");t.constant("isFirstRun",i);var o="1"===e.element("#fullcalendar").attr("data-isPublic");t.constant("isPublic",o);var s="1"===e.element("#fullcalendar").attr("data-isEmbedded");t.constant("isEmbedded",s);var u="object"===l(OC.Share);t.constant("isSharingAPI",u);var c="yes"===e.element("#fullcalendar").attr("data-skipPopover"),d="yes"===e.element("#fullcalendar").attr("data-weekNumbers");t.constant("settings",{skipPopover:c,showWeekNr:d});var p=e.element("#fullcalendar").attr("data-initialView"),f=e.element("#fullcalendar").attr("data-emailAddress"),m=e.element("#fullcalendar").attr("data-defaultColor"),h="yes"===e.element("#fullcalendar").attr("data-webCalWorkaround"),v=e.element("#fullcalendar").attr("data-appVersion"),g=e.element("#fullcalendar").attr("data-publicSharingToken"),y="yes"===e.element("#fullcalendar").attr("data-shareeCanEditShares"),b="yes"===e.element("#fullcalendar").attr("data-shareeCanEditCalendarProperties");t.constant("constants",{initialView:p,emailAddress:f,fallbackColor:m,needsWebCalWorkaround:h,version:v,publicSharingToken:g,shareeCanEditShares:y,shareeCanEditCalendarProperties:b,SHARE_TYPE_USER:0,SHARE_TYPE_GROUP:1})}]),o.run(["$document","$rootScope","$window","isPublic",function(e,t,r,n){var a=r.location.origin;t.root=a+OC.linkTo("calendar","index.php")+"/",t.baseUrl=t.root+"v1/";try{if(!n){var i=t.root+"#subscribe_to_webcal?url=%s";navigator.registerProtocolHandler("webcal",i,"Nextcloud calendar")}}catch(e){console.log(e)}e.click(function(e){t.$broadcast("documentClicked",e)})}]),o.controller("AttendeeController",["$scope","AutoCompletionService",function(e,r){e.newAttendeeGroup=-1,e.cutstats=[{displayname:t("calendar","Individual"),val:"INDIVIDUAL"},{displayname:t("calendar","Group"),val:"GROUP"},{displayname:t("calendar","Resource"),val:"RESOURCE"},{displayname:t("calendar","Room"),val:"ROOM"},{displayname:t("calendar","Unknown"),val:"UNKNOWN"}],e.partstats=[{displayname:t("calendar","Required"),val:"REQ-PARTICIPANT"},{displayname:t("calendar","Optional"),val:"OPT-PARTICIPANT"},{displayname:t("calendar","Does not attend"),val:"NON-PARTICIPANT"}],e.$parent.registerPostHook(function(){e.properties.attendee=e.properties.attendee||[],e.properties.attendee.length>0&&null===e.properties.organizer&&(e.properties.organizer={value:"MAILTO:"+e.$parent.emailAddress,parameters:{cn:OC.getCurrentUser().displayName}})}),e.add=function(t){""!==t&&(e.properties.attendee=e.properties.attendee||[],e.properties.attendee.push({value:"MAILTO:"+t,group:e.newAttendeeGroup--,parameters:{role:"REQ-PARTICIPANT",rsvp:"TRUE",partstat:"NEEDS-ACTION",cutype:"INDIVIDUAL"}})),e.attendeeoptions=!1,e.nameofattendee=""},e.remove=function(t){e.properties.attendee=e.properties.attendee.filter(function(e){return e.group!==t.group})},e.search=function(e){return r.searchAttendee(e).then(function(e){var r=[];return e.forEach(function(e){var n=e.email.length;e.email.forEach(function(a){var i=void 0;i=1===n?e.name:t("calendar","{name} ({email})",{name:e.name,email:a}),r.push({displayname:i,email:a,name:e.name})})}),r})},e.selectFromTypeahead=function(t){e.properties.attendee=e.properties.attendee||[],e.properties.attendee.push({value:"MAILTO:"+t.email,parameters:{cn:t.name,role:"REQ-PARTICIPANT",rsvp:"TRUE",partstat:"NEEDS-ACTION",cutype:"INDIVIDUAL"}}),e.nameofattendee=""}}]),o.controller("CalController",["$scope","Calendar","CalendarService","VEventService","SettingsService","TimezoneService","VEvent","is","fc","EventsEditorDialogService","PopoverPositioningUtility","$window","isPublic","constants",function(r,n,a,i,o,l,s,u,c,d,p,f,m,h){function v(e){A.indexOf(e)===-1&&r.eventSource[e].isRendering===!1&&(A.push(e),c.elm.fullCalendar("removeEventSource",r.eventSource[e]),c.elm.fullCalendar("addEventSource",r.eventSource[e]))}function g(e){c.elm.fullCalendar("removeEventSource",r.eventSource[e]),A.indexOf(e)!==-1&&A.splice(A.indexOf(e),1)}function y(e,t,r,n,a){i.create(e,t).then(function(t){e.enabled&&c.elm.fullCalendar("refetchEventSources",e.fcEventSource)})}function b(e,t){i.delete(e).then(function(){c.elm.fullCalendar("removeEvents",t.id)})}u.loading=!0,r.calendars=[],r.eventSource={},r.defaulttimezone=l.current(),r.eventModal=null;var A=[];r.$watchCollection("calendars",function(e,t){e.filter(function(e){return t.indexOf(e)===-1}).forEach(function(e){r.eventSource[e.url]=e.fcEventSource,e.enabled&&v(e.url),e.register(n.hookEnabledChanged,function(t){t?v(e.url):g(e.url)}),e.register(n.hookColorChanged,function(){e.enabled&&(g(e.url),v(e.url))})}),t.filter(function(t){return e.indexOf(t)===-1}).forEach(function(e){var t=e.url;g(e.url),delete r.eventSource[t]})}),l.get(r.defaulttimezone).then(function(e){e&&ICAL.TimezoneService.register(r.defaulttimezone,e.jCal)}).catch(function(){OC.Notification.showTemporary(t("calendar","You are in an unknown timezone ({tz}), falling back to UTC",{tz:r.defaulttimezone})),r.defaulttimezone="UTC",r.fcConfig.timezone="UTC",c.elm.fullCalendar("option","timezone","UTC")}),m?r.calendarsPromise=a.getPublicCalendar(h.publicSharingToken).then(function(e){r.calendars=[e],u.loading=!1,r.$apply()}).catch(function(t){e.element("#header-right").css("display","none"),e.element("#emptycontent-container").css("display","block")}):r.calendarsPromise=a.getAll().then(function(e){r.calendars=e,u.loading=!1,r.$apply()}),r.fcConfig={timezone:r.defaulttimezone,select:function(n,a,i,o){var l=r.calendars.filter(function(e){return e.isWritable()});if(0===l.length)return void(m||OC.Notification.showTemporary(t("calendar","Please create a calendar first.")));n.add(n.toDate().getTimezoneOffset(),"minutes"),a.add(a.toDate().getTimezoneOffset(),"minutes");var u=s.fromStartEnd(n,a,r.defaulttimezone);u.calendar=l[0];var f=Date.now(),h="new-event-dummy-"+f;u.getFcEvent(o.start,o.end,r.defaulttimezone).then(function(n){var a=n[0];a.title=t("calendar","New event"),a.className.push(h),a.editable=!1,c.elm.fullCalendar("renderEvent",a),d.open(r,a,function(){var t=e.element("."+h),r=0!==e.element(t[0]).parents(".fc-limited").length;return r?p.calculate(i.clientX,i.clientY,i.clientX,i.clientY,o):p.calculateByTarget(t[0],o)},function(){return null},function(){c.elm.fullCalendar("removeEvents",function(e){return!!Array.isArray(e.className)&&e.className.indexOf(h)!==-1})}).then(function(e){y(e.calendar,e.vevent.data,o.start,o.end,r.defaulttimezone)}).catch(function(e){return null})})},eventClick:function(e,t,n){var a=e.vevent,o=a.calendar,l=e;d.open(r,e,function(){return p.calculateByTarget(t.currentTarget,n)},function(){l.editable=!1,c.elm.fullCalendar("updateEvent",l)},function(){l.editable=e.calendar.writable,c.elm.fullCalendar("updateEvent",l)}).then(function(t){t.calendar===o?i.update(a).then(function(){c.elm.fullCalendar("removeEvents",e.id),t.calendar.enabled&&c.elm.fullCalendar("refetchEventSources",t.calendar.fcEventSource)}):(b(a,e),y(t.calendar,t.vevent.data,n.start,n.end,r.defaulttimezone))}).catch(function(t){"delete"===t&&b(a,e)})},eventResize:function(e,t,r){e.resize(t),i.update(e.vevent).catch(function(){r()})},eventDrop:function(e,t,n){var a=!e.start.hasTime(),o=c.elm.fullCalendar("option","defaultAllDayEventDuration"),l=moment.duration(o),s=c.elm.fullCalendar("option","defaultTimedEventDuration"),u=moment.duration(s),d=r.defaulttimezone;e.drop(t,a,d,u,l),i.update(e.vevent).catch(function(){n()})},viewRender:function(t,n){e.element("#firstrow").find(".datepicker_current").html(t.title).text(),e.element("#datecontrol_date").datepicker("setDate",n.fullCalendar("getDate"));var a=t.name;a===r.defaultView||m||(o.setView(a),r.defaultView=a),"agendaDay"===a?e.element("td.fc-state-highlight").css("background-color","#ffffff"):e.element(".fc-bg td.fc-state-highlight").css("background-color","#ffa"),"agendaWeek"===a?n.fullCalendar("option","aspectRatio",.1):n.fullCalendar("option","aspectRatio",1.35)},eventRender:function(e,t){var r=e.getSimpleEvent().status;null!==r&&("TENTATIVE"===r.value?t.css({opacity:.5}):"CANCELLED"===r.value&&t.css({"text-decoration":"line-through",opacity:.5}))}}}]),o.controller("CalendarListController",["$scope","$rootScope","$window","HashService","CalendarService","WebCalService","is","CalendarListItem","Calendar","MailerService","ColorUtility","isSharingAPI","constants",function(n,a,i,o,l,s,u,c,d,p,f,m,h){n.calendarListItems=[],n.is=u,n.newCalendarInputVal="",n.newCalendarColorVal="",n.subscription={},n.subscription.newSubscriptionUrl="",n.subscription.newSubscriptionLocked=!1,n.publicdav="CalDAV",n.publicdavdesc=t("calendar","CalDAV address for clients"),n.isSharingAPI=m,n.$watchCollection("calendars",function(e,t){e=e||[],t=t||[],e.filter(function(e){return t.indexOf(e)===-1}).forEach(function(e){var t=c(e);t&&(n.calendarListItems.push(t),n.publicdavurl=n.$parent.calendars[0].caldav,e.register(d.hookFinishedRendering,function(){n.$$phase||n.$apply()}))}),t.filter(function(t){return e.indexOf(t)===-1}).forEach(function(e){n.calendarListItems=n.calendarListItems.filter(function(t){return t.calendar!==e})})}),n.create=function(t,r){l.create(t,r).then(function(e){n.calendars.push(e),a.$broadcast("createdCalendar",e),a.$broadcast("reloadCalendarList")}),n.newCalendarInputVal="",n.newCalendarColorVal="",e.element("#new-calendar-button").click()},n.createSubscription=function(r){n.subscription.newSubscriptionLocked=!0,s.get(r).then(function(a){var i=a.color||f.randomColor(),o=a.name||r;o.length>100&&(o=o.substr(0,100)),l.createWebCal(o,i,r).then(function(t){e.element("#new-subscription-button").click(),n.calendars.push(t),n.subscription.newSubscriptionUrl="",n.$digest(),n.$parent.$digest(),n.subscription.newSubscriptionLocked=!1}).catch(function(){OC.Notification.showTemporary(t("calendar","Error saving WebCal-calendar")),n.subscription.newSubscriptionLocked=!1})}).catch(function(e){e.error?(OC.Notification.showTemporary(e.message),n.subscription.newSubscriptionLocked=!1):e.redirect&&n.createSubscription(e.new_url)})},n.download=function(e){i.open(e.calendar.downloadUrl)},n.integration=function(e){return'<iframe width="400" height="215" src="'+e.publicEmbedURL+'"></iframe>'},n.$watch("publicdav",function(e){if(n.$parent.calendars[0])if("CalDAV"===e)n.publicdavurl=n.$parent.calendars[0].caldav,n.publicdavdesc=t("calendar","CalDAV address for clients");else{var r=n.$parent.calendars[0].url;"/"===r.slice(r.length-1)&&(r=r.slice(0,r.length-1)),r+="?export",n.publicdavurl=i.location.origin+r,n.publicdavdesc=t("calendar","WebDAV address for subscriptions")}}),n.sendMail=function(e){e.toggleSendingMail(),p.sendMail(e.email,e.publicSharingURL,e.calendar.displayname).then(function(r){200===r.status?(e.email="",OC.Notification.showTemporary(t("calendar","EMail has been sent."))):OC.Notification.showTemporary(t("calendar","There was an issue while sending your EMail."))})},n.goPublic=function(e){i.open(e.publicSharingURL)},n.toggleSharesEditor=function(e){e.toggleSharesEditor()},n.togglePublish=function(e){e.calendar.published?e.calendar.publish().then(function(t){t&&l.get(e.calendar.url).then(function(t){e.calendar.publicToken=t.publicToken,e.calendar.published=!0}),n.$apply()}):e.calendar.unpublish().then(function(t){t&&(e.calendar.published=!1),n.$apply()})},n.prepareUpdate=function(e){e.prepareUpdate()},n.onSelectSharee=function(e,t,r,a){a.selectedSharee="",a.share(e.type,e.identifier,!1,!1).then(function(){n.$apply()})},n.updateExistingUserShare=function(e,t,r){e.share(h.SHARE_TYPE_USER,t,r,!0).then(function(){n.$apply()})},n.updateExistingGroupShare=function(e,t,r){e.share(h.SHARE_TYPE_GROUP,t,r,!0).then(function(){n.$apply()})},n.unshareFromUser=function(e,t){e.unshare(h.SHARE_TYPE_USER,t).then(function(){n.$apply()})},n.unshareFromGroup=function(e,t){e.unshare(h.SHARE_TYPE_GROUP,t).then(function(){n.$apply()})},n.findSharee=function(e,n){return r.get(OC.linkToOCS("apps/files_sharing/api/v1")+"sharees",{format:"json",search:e.trim(),perPage:200,itemType:"principals"}).then(function(e){var r,a,i=e.ocs.data.exact.users.concat(e.ocs.data.users),o=e.ocs.data.exact.groups.concat(e.ocs.data.groups),l=n.shares.users,s=n.shares.groups,u=l.length,c=(s.length,i.length);for(r=0;r<c;r++)if(i[r].value.shareWith===OC.currentUser){i.splice(r,1);break}for(r=0;r<u;r++){var d=l[r];for(c=i.length,a=0;a<c;a++)if(i[a].value.shareWith===d.id){i.splice(a,1);break}}return i=i.map(function(e){return{display:e.label,type:h.SHARE_TYPE_USER,identifier:e.value.shareWith}}),o=o.map(function(e){return{display:e.label+" ("+t("calendar","group")+")",type:h.SHARE_TYPE_GROUP,identifier:e.value.shareWith}}),o.concat(i)})},n.performUpdate=function(e){e.saveEditor(),e.calendar.update().then(function(){a.$broadcast("updatedCalendar",e.calendar),a.$broadcast("reloadCalendarList")})},n.performUpdateShares=function(e){e.update().then(function(){e.dropPreviousState(),e.list.edit=!1,a.$broadcast("updatedCalendar",e),a.$broadcast("reloadCalendarList")})},n.triggerEnable=function(e){e.calendar.toggleEnabled(),e.calendar.update().then(function(){a.$broadcast("updatedCalendarsVisibility",e.calendar),a.$broadcast("reloadCalendarList")})},n.remove=function(e){e.calendar.delete().then(function(){n.$parent.calendars=n.$parent.calendars.filter(function(t){return t!==e.calendar}),n.$$phase||n.$apply()})},a.$on("reloadCalendarList",function(){n.$$phase||n.$apply()}),o.runIfApplicable("subscribe_to_webcal",function(t){t.has("url")&&!function(){var r=t.get("url");n.subscription.newSubscriptionUrl=r,n.subscription.newSubscriptionLocked=!0,e.element("#new-subscription-button").click(),n.calendarsPromise.then(function(){n.createSubscription(r)})}()})}]),o.controller("DatePickerController",["$scope","fc","uibDatepickerConfig","constants",function(t,r,n,a){function i(){switch(t.selectedView){case"agendaDay":return"day";case"agendaWeek":return"week";case"month":return"month"}}t.datepickerOptions={formatDay:"d"},t.dt=new Date,t.visibility=!1,t.selectedView=a.initialView,e.extend(n,{showWeeks:!1,startingDay:parseInt(moment().startOf("week").format("d"))}),t.today=function(){t.dt=new Date},t.prev=function(){t.dt=moment(t.dt).subtract(1,i()).toDate()},t.next=function(){t.dt=moment(t.dt).add(1,i()).toDate()},t.toggle=function(){t.visibility=!t.visibility},t.$watch("dt",function(e){r&&r.elm.fullCalendar("gotoDate",e)}),t.$watch("selectedView",function(e){r&&r.elm.fullCalendar("changeView",e)})}]),o.controller("EditorController",["$scope","TimezoneService","AutoCompletionService","$timeout","$window","$uibModalInstance","vevent","simpleEvent","calendar","isNew","emailAddress",function(n,a,i,o,l,s,u,c,d,p,f){n.properties=c,n.is_new=p,n.calendar=d,n.oldCalendar=p?d:u.calendar,n.readOnly=!u.calendar.isWritable(),n.accessibleViaCalDAV=u.calendar.eventsAccessibleViaCalDAV(),n.selected=0,n.timezones=[],n.emailAddress=f,n.edittimezone="floating"!==n.properties.dtstart.parameters.zone&&n.properties.dtstart.parameters.zone!==n.defaulttimezone||"floating"!==n.properties.dtend.parameters.zone&&n.properties.dtend.parameters.zone!==n.defaulttimezone,n.preEditingHooks=[],n.postEditingHooks=[],n.tabs=[{title:t("calendar","Details"),value:0},{title:t("calendar","Attendees"),value:1},{title:t("calendar","Reminders"),value:2},{title:t("calendar","Repeating"),value:3}],n.classSelect=[{displayname:t("calendar","When shared show full event"),type:"PUBLIC"},{displayname:t("calendar","When shared show only busy"),type:"CONFIDENTIAL"},{displayname:t("calendar","When shared hide this event"),type:"PRIVATE"}],n.statusSelect=[{displayname:t("calendar","Confirmed"),type:"CONFIRMED"},{displayname:t("calendar","Tentative"),type:"TENTATIVE"},{displayname:t("calendar","Cancelled"),type:"CANCELLED"}],n.registerPreHook=function(e){n.preEditingHooks.push(e)},s.rendered.then(function(){n.properties.allDay&&(n.properties.dtend.value=moment(n.properties.dtend.value.subtract(1,"days"))),autosize(r(".advanced--textarea")),autosize(r(".events--textarea")),o(function(){autosize.update(r(".advanced--textarea")),autosize.update(r(".events--textarea"))},50),e.forEach(n.preEditingHooks,function(e){e()}),n.tabopener(0)}),n.registerPostHook=function(e){n.postEditingHooks.push(e)},n.proceed=function(){n.prepareClose(),s.close({action:"proceed",calendar:n.calendar,simple:n.properties,vevent:u})},n.save=function(){n.validate()&&(n.prepareClose(),n.properties.patch(),s.close({action:"save",calendar:n.calendar,simple:n.properties,vevent:u}))},n.validate=function(){var e=!1;return null!==n.properties.summary&&""!==n.properties.summary.value.trim()||(OC.Notification.showTemporary(t("calendar","Please add a title!")),e=!0),null!==n.calendar&&"undefined"!=typeof n.calendar||(OC.Notification.showTemporary(t("calendar","Please select a calendar!")),e=!0),n.properties.checkDtStartBeforeDtEnd()||(OC.Notification.showTemporary(t("calendar","The event ends before it starts!")),e=!0),!e},n.prepareClose=function(){n.properties.allDay&&n.properties.dtend.value.add(1,"days"),e.forEach(n.postEditingHooks,function(e){e()})},n.cancel=function(){s.dismiss("cancel")},n.delete=function(){s.dismiss("delete")},n.export=function(){l.open(n.oldCalendar.url+u.uri)},n.tabopener=function(e){n.selected=e,0===e?(n.eventsdetailsview=!0,n.eventsattendeeview=!1,n.eventsalarmview=!1,n.eventsrepeatview=!1):1===e?(n.eventsdetailsview=!1,n.eventsattendeeview=!0,n.eventsalarmview=!1,n.eventsrepeatview=!1):2===e?(n.eventsdetailsview=!1,n.eventsattendeeview=!1,n.eventsalarmview=!0,n.eventsrepeatview=!1):3===e&&(n.eventsdetailsview=!1,n.eventsattendeeview=!1,n.eventsalarmview=!1,n.eventsrepeatview=!0)},n.selectedCalendarChanged=function(){n.calendar.enabled===!1&&(n.calendar.enabled=!0,n.calendar.update())},n.showCalendarSelection=function(){var e=n.calendars.filter(function(e){return e.isWritable()});return e.length>1},n.$watch("properties.dtstart.value",function(e,t){var r=e.diff(t,"seconds");0!==r&&(n.properties.dtend.value=moment(n.properties.dtend.value.add(r,"seconds")))}),n.toggledAllDay=function(){n.properties.allDay||(n.properties.dtstart.value.isSame(n.properties.dtend.value)&&(n.properties.dtend.value=moment(n.properties.dtend.value.add(1,"hours"))),"floating"===n.properties.dtstart.parameters.zone&&"floating"===n.properties.dtend.parameters.zone&&(n.properties.dtstart.parameters.zone=n.defaulttimezone,n.properties.dtend.parameters.zone=n.defaulttimezone))},n.$watch("properties.allDay",n.toggledAllDay),a.listAll().then(function(r){"floating"!==n.properties.dtstart.parameters.zone&&r.indexOf(n.properties.dtstart.parameters.zone)===-1&&r.push(n.properties.dtstart.parameters.zone),"floating"!==n.properties.dtend.parameters.zone&&r.indexOf(n.properties.dtend.parameters.zone)===-1&&r.push(n.properties.dtend.parameters.zone),e.forEach(r,function(e){"GMT"!==e&&"Z"!==e&&(1===e.split("/").length?n.timezones.push({displayname:e,group:t("calendar","Global"),value:e}):n.timezones.push({displayname:e.split("/").slice(1).join("/"),group:e.split("/",1),value:e}))}),n.timezones.push({displayname:t("calendar","None"),group:t("calendar","Global"),value:"floating"})}),n.loadTimezone=function(e){a.get(e).then(function(t){ICAL.TimezoneService.register(e,t.jCal)})},n.searchLocation=function(e){return i.searchLocation(e)},n.selectLocationFromTypeahead=function(e){n.properties.location.value=e.label},n.setClassToDefault=function(){null===n.properties.class&&(n.properties.class={type:"string",value:"PUBLIC"})},n.setStatusToDefault=function(){null===n.properties.status&&(n.properties.status={type:"string",value:"CONFIRMED"})}}]),o.controller("ImportController",["$scope","$filter","CalendarService","VEventService","$uibModalInstance","files","ImportFileWrapper","ColorUtility",function(t,r,n,a,i,o,l,s){t.nameSize=25,t.rawFiles=o,t.files=[],t.showCloseButton=!1,t.writableCalendars=t.calendars.filter(function(e){return e.isWritable()}),t.import=function(r){r.state=l.stateScheduled;var i=function(t){var n=r.splittedICal.objects;e.forEach(n,function(e){a.create(t,e,!1).then(function(e){r.state=l.stateImporting,r.progress++,e||r.errors++}).catch(function(e){r.state=l.stateImporting,r.progress++,r.errors++})})};if("new"===r.selectedCalendar){var o=r.splittedICal.name||r.file.name,u=r.splittedICal.color||s.randomColor(),c=[];r.splittedICal.vevents.length>0&&(c.push("vevent"),c.push("vtodo")),r.splittedICal.vjournals.length>0&&c.push("vjournal"),r.splittedICal.vtodos.length>0&&c.indexOf("vtodo")===-1&&c.push("vtodo"),n.create(o,u,c).then(function(e){e.components.vevent&&(t.calendars.push(e),t.writableCalendars.push(e)),i(e),r.selectedCalendar=e.url})}else{var d=t.calendars.filter(function(e){return e.url===r.selectedCalendar})[0];i(d)}},t.preselectCalendar=function(e){var n=r("importCalendarFilter")(t.writableCalendars,e);0===n.length?e.selectedCalendar="new":e.selectedCalendar=n[0].url},t.changeCalendar=function(e){if("new"===e.selectedCalendar)e.incompatibleObjectsWarning=!1;else{var n=r("importCalendarFilter")(t.writableCalendars,e);e.incompatibleObjectsWarning=n.indexOf(e.selectedCalendar)===-1}},e.forEach(t.rawFiles,function(e){var r=l(e);r.read(function(){t.preselectCalendar(r),t.$apply()}),r.register(l.hookProgressChanged,function(){t.$apply()}),r.register(l.hookDone,function(){t.$apply(),t.closeIfNecessary();var e=t.calendars.find(function(e){return e.url===r.selectedCalendar});e&&e.enabled&&(e.enabled=!1,e.enabled=!0)}),r.register(l.hookErrorsChanged,function(){t.$apply()}),t.files.push(r)}),t.closeIfNecessary=function(){var e=t.files.filter(function(e){return!e.wasCanceled()&&!e.isDone()&&!e.isEmpty()}),r=t.files.filter(function(e){return e.isDone()&&e.hasErrors()}),n=t.files.filter(function(e){return e.isEmpty()});0===e.length&&0===r.length&&0===n.length?i.close():0!==e.length||0===r.length&&0===n.length||(t.showCloseButton=!0,t.$apply())},t.close=function(){i.close()},t.cancelFile=function(e){e.state=l.stateCanceled,t.closeIfNecessary()}}]),o.controller("RecurrenceController",["$scope",function(e){e.rruleNotSupported=!1,e.repeat_options_simple=[{val:"NONE",displayname:t("calendar","None")},{val:"DAILY",displayname:t("calendar","Every day")},{val:"WEEKLY",displayname:t("calendar","Every week")},{val:"MONTHLY",displayname:t("calendar","Every month")},{val:"YEARLY",displayname:t("calendar","Every year")}],e.selected_repeat_end="NEVER",e.repeat_end=[{val:"NEVER",displayname:t("calendar","never")},{val:"COUNT",displayname:t("calendar","after")}],e.$parent.registerPreHook(function(){if("NONE"!==e.properties.rrule.freq){var t=["SECONDLY","MINUTELY","HOURLY"];if(t.indexOf(e.properties.rrule.freq)!==-1&&(e.rruleNotSupported=!0),"undefined"!=typeof e.properties.rrule.parameters){var r=Object.getOwnPropertyNames(e.properties.rrule.parameters);r.length>0&&(e.rruleNotSupported=!0)}null!==e.properties.rrule.count?e.selected_repeat_end="COUNT":null!==e.properties.rrule.until&&(e.rruleNotSupported=!0),null===e.properties.rrule.interval&&(e.properties.rrule.interval=1)}}),e.$parent.registerPostHook(function(){e.properties.rrule.dontTouch=e.rruleNotSupported,"NEVER"===e.selected_repeat_end&&(e.properties.rrule.count=null,e.properties.rrule.until=null)}),e.resetRRule=function(){e.selected_repeat_end="NEVER",e.properties.rrule.freq="NONE",e.properties.rrule.count=null,e.properties.rrule.interval=1,e.rruleNotSupported=!1,e.properties.rrule.parameters={}}}]),o.controller("SettingsController",["$scope","$uibModal","$timeout","SettingsService","fc","isFirstRun","settings",function(r,n,a,i,o,l,s){r.settingsCalDavLink=OC.linkToRemote("dav")+"/",r.settingsCalDavPrincipalLink=OC.linkToRemote("dav")+"/principals/users/"+escapeHTML(encodeURIComponent(oc_current_user))+"/",r.skipPopover=s.skipPopover?"yes":"no",r.settingsShowWeekNr=s.showWeekNr?"yes":"no",a(function(){l&&(e.element(".settings-button").click(),e.element("#import-button-overlay").tooltip({animation:!0,placement:"bottom",title:t("calendar","How about getting started by importing some calendars?")}),a(function(){e.element("#import-button-overlay").tooltip("toggle")},500),a(function(){e.element("#import-button-overlay").tooltip("toggle")},10500),i.passedFirstRun())},1500),e.element("#import").on("change",function(){for(var t=[],a=0;a<this.files.length;a++)t.push(this.files[a]);t.length>0&&n.open({templateUrl:"import.html",controller:"ImportController",windowClass:"import",backdropClass:"import-backdrop",keyboard:!1,appendTo:e.element("#importpopover-container"),resolve:{files:function(){return t}},scope:r}),e.element("#import").val(null)}),r.updateSkipPopover=function(){var e=r.skipPopover;s.skipPopover="yes"===e,i.setSkipPopover(e)},r.updateShowWeekNr=function(){var e=r.settingsShowWeekNr;s.showWeekNr="yes"===e,i.setShowWeekNr(e),o.elm&&o.elm.fullCalendar("option","weekNumbers","yes"===e)}}]),o.controller("SubscriptionController",["$scope",function(e){}]),o.controller("VAlarmController",["$scope",function(r){r.newReminderId=-1,r.alarmFactors=[60,60,24,7],r.reminderSelect=[{displayname:t("calendar","At time of event"),trigger:0},{displayname:t("calendar","5 minutes before"),trigger:-300},{displayname:t("calendar","10 minutes before"),trigger:-600},{displayname:t("calendar","15 minutes before"),trigger:-900},{displayname:t("calendar","30 minutes before"),trigger:-1800},{displayname:t("calendar","1 hour before"),trigger:-3600},{displayname:t("calendar","2 hours before"),trigger:-7200},{displayname:t("calendar","Custom"),trigger:"custom"}],r.reminderSelectTriggers=r.reminderSelect.map(function(e){return e.trigger}).filter(function(e){return"number"==typeof e}),r.reminderTypeSelect=[{displayname:t("calendar","Audio"),type:"AUDIO"},{displayname:t("calendar","E Mail"),type:"EMAIL"},{displayname:t("calendar","Pop up"),type:"DISPLAY"}],r.timeUnitReminderSelect=[{displayname:t("calendar","sec"),factor:1},{displayname:t("calendar","min"),factor:60},{displayname:t("calendar","hours"),factor:3600},{displayname:t("calendar","days"),factor:86400},{displayname:t("calendar","week"),factor:604800}],r.timePositionReminderSelect=[{displayname:t("calendar","before"),factor:-1},{displayname:t("calendar","after"),factor:1}],r.startEndReminderSelect=[{displayname:t("calendar","start"),type:"start"},{displayname:t("calendar","end"),type:"end"}],r.$parent.registerPreHook(function(){e.forEach(r.properties.alarm,function(e){r._addEditorProps(e)})}),r.$parent.registerPostHook(function(){e.forEach(r.properties.alarm,function(e){"absolute"===e.editor.triggerType&&(e.trigger.value=e.editor.absMoment)})}),r._addEditorProps=function(t){e.extend(t,{editor:{triggerValue:0,triggerBeforeAfter:-1,triggerTimeUnit:1,absMoment:moment(),editing:!1}}),t.editor.reminderSelectValue=r.reminderSelectTriggers.indexOf(t.trigger.value)!==-1?t.editor.reminderSelectValue=t.trigger.value:t.editor.reminderSelectValue="custom",t.editor.triggerType="duration"===t.trigger.type?"relative":"absolute","relative"===t.editor.triggerType?r._prepareRelativeVAlarm(t):r._prepareAbsoluteVAlarm(t),r._prepareRepeat(t)},r._prepareRelativeVAlarm=function(t){var n=r._getUnitAndValue(Math.abs(t.trigger.value));e.extend(t.editor,{triggerBeforeAfter:t.trigger.value<0?-1:1,triggerTimeUnit:n[0],triggerValue:n[1]})},r._prepareAbsoluteVAlarm=function(e){e.editor.absMoment=e.trigger.value},r._prepareRepeat=function(t){var n=r._getUnitAndValue(t.duration&&t.duration.value?t.duration.value:0);e.extend(t.editor,{repeat:!(!t.repeat.value||0===t.repeat.value),repeatNTimes:t.editor.repeat?t.repeat.value:0,repeatTimeUnit:n[0],repeatNValue:n[1]})},r._getUnitAndValue=function(e){for(var t=1,r=[60,60,24,7],n=0;n<r.length&&0!==e;n++){var a=e%r[n];if(0!==a)break;t*=r[n],e/=r[n]}return[t,e]},r.add=function(){var t=[];e.forEach(r.properties.alarm,function(e){e.trigger&&"duration"===e.trigger.type&&t.push(e.trigger.value)});var n=[];e.forEach(r.reminderSelect,function(e){"number"!=typeof e.trigger||e.trigger>-900||n.push(e.trigger)});for(var a=null,i=0;i<n.length;i++)if(t.indexOf(n[i])===-1){a=n[i];break}null===a&&(a=n[n.length-1]);var o={id:r.newReminderId--,action:{type:"text",value:"AUDIO"},trigger:{type:"duration",value:a,related:"start"},repeat:{},duration:{}};r._addEditorProps(o),r.properties.alarm.push(o)},r.remove=function(e){r.properties.alarm=r.properties.alarm.filter(function(t){return t!==e})},r.triggerEdit=function(e){e.editor.editing===!0?e.editor.editing=!1:r.isEditingReminderSupported(e)?e.editor.editing=!0:OC.Notification.showTemporary(t("calendar","Editing reminders of unknown type not supported."))},r.isEditingReminderSupported=function(e){return["AUDIO","DISPLAY","EMAIL"].indexOf(e.action.value)!==-1},r.updateReminderSelectValue=function(e){var t=e.editor.reminderSelectValue;"custom"!==t&&(e.duration={},e.repeat={},e.trigger.related="start",e.trigger.type="duration",e.trigger.value=parseInt(t),r._addEditorProps(e))},r.updateReminderRelative=function(e){e.trigger.value=parseInt(e.editor.triggerBeforeAfter)*parseInt(e.editor.triggerTimeUnit)*parseInt(e.editor.triggerValue),e.trigger.type="duration"},r.updateReminderAbsolute=function(e){moment.isMoment(e.trigger.value)||(e.trigger.value=moment()),e.trigger.type="date-time"},r.updateReminderRepeat=function(e){e.repeat.type="string",e.repeat.value=e.editor.repeatNTimes,e.duration.type="duration",e.duration.value=parseInt(e.editor.repeatNValue)*parseInt(e.editor.repeatTimeUnit)}}]),o.directive("avatar",function(){return{restrict:"A",scope:{},link:function(e,t,n){var a=n.size?parseInt(n.size,10):32;r(t).avatar(n.user,a)}}}),o.directive("colorpicker",["ColorUtility",function(e){return{scope:{selected:"=",customizedColors:"=colors"},restrict:"AE",templateUrl:OC.filePath("calendar","templates","colorpicker.html"),link:function(t,r,n){t.colors=t.customizedColors||e.colors,t.selected=t.selected||t.colors[0],t.random="#000000";var a=document.createElement("input");a.setAttribute("type","color"),t.supportsColorPicker="color"===a.type,t.randomizeColour=function(){t.random=e.randomColor(),t.pick(t.random)},t.pick=function(e){t.selected=e}}}}]),o.directive("confirmation",function(){return{priority:-1,restrict:"A",templateUrl:"confirmation.html",scope:{confirmationFunction:"&confirmation",confirmationMessage:"&confirmationMessage"},controller:"ConfirmationController"}}),o.controller("ConfirmationController",["$scope","$rootScope","$element","$attrs","$compile","$document","$window","$timeout",function(e,t,r,n,a,i,o,l){var s=function(){function t(t,r,n,a,i,o,l,s){this._$scope=t,this._$scope.countdown=3,n.bind("click",function(e){t.countdown=3,n.removeClass("active");var r=t.confirmationMessage()?t.confirmationMessage():"Are you sure?";n.hasClass("confirmed")||(e.stopPropagation(),t.activate(),n.children(".confirmation-confirm").tooltip({title:r,container:"body",placement:"right"}),n.addClass("confirmed"))}),n.children(".confirmation-confirm").bind("click",function(e){return n.hasClass("confirmed active")?void t.confirmationFunction():void e.stopPropagation()}),this._$scope.documentClick=function(){n.removeClass("confirmed")},this._$scope.activate=function(){t.countdown?(n.find(".countdown").html(t.countdown+" s"),s(function(){t.activate()},1e3),t.countdown--):n.addClass("active")},o.bind("click",t.documentClick),o.bind("touchend",t.documentClick),e.$on("$destroy",function(){o.unbind("click",t.documentClick),o.unbind("touchend",t.documentClick); })}return t}();return new s(e,t,r,n,a,i,o,l)}]),o.directive("ocdatetimepicker",["$compile","$timeout",function(t,r){return{restrict:"E",require:"ngModel",scope:{disabletime:"=disabletime",date_tabindex:"=datetabindex",time_tabindex:"=timetabindex",readonly:"=readonly"},link:function(n,a,i,o){function l(){var e=a.find(".events--date").datepicker("getDate"),t=0,r=0;n.disabletime||(t=a.find(".events--time").timepicker("getHour"),r=a.find(".events--time").timepicker("getMinute"));var i=moment(e);i.hours(t),i.minutes(r),i.seconds(0),a.find(".events--time").timepicker("hide"),o.$setViewValue(i)}function s(){a.find(".events--date").datepicker({dateFormat:p.longDateFormat("L").toLowerCase().replace("yy","y").replace("yyy","yy"),monthNames:moment.months(),monthNamesShort:moment.monthsShort(),dayNames:moment.weekdays(),dayNamesMin:moment.weekdaysMin(),dayNamesShort:moment.weekdaysShort(),firstDay:+p.firstDayOfWeek(),minDate:null,showOtherMonths:!0,selectOtherMonths:!0,onClose:l})}function u(){a.find(".events--time").timepicker({showPeriodLabels:p.longDateFormat("LT").toLowerCase().indexOf("a")!==-1,showLeadingZero:!0,showPeriod:p.longDateFormat("LT").toLowerCase().indexOf("a")!==-1,duration:0,onClose:l})}var c='<input type="text" ng-model="date" class="events--date" tabindex="{{ date_tabindex }}"/>';c+='<span class="events--time--wrapper" ng-click="disableAllDayIfNecessary()"><input type="text" ng-model="time" class="events--time" ng-disabled="disabletime" tabindex="{{ time_tabindex }}"/></span>';var d=e.element(c);n.date=null,n.time=null,n.disableAllDayIfNecessary=function(){n.disabletime&&!n.readonly&&r(function(){n.$apply(function(){n.disabletime=!1}),a.find(".events--time").timepicker("show")})},t(d)(n),a.append(d);var p=moment.localeData();s(),u(),n.$watch(function(){return o.$modelValue},function(e){moment.isMoment(e)&&(a.find(".events--date").datepicker("setDate",e.toDate()),a.find(".events--time").timepicker("setTime",e.toDate()))}),a.on("$destroy",function(){a.find(".events--date").datepicker("destroy"),a.find(".events--time").timepicker("destroy")})}}}]),o.constant("fc",{}).directive("fc",["fc","$window",function(t,n){return{restrict:"A",scope:{},link:function(a,i,o){for(var l=moment.localeData(),s=moment.localeData("en"),u=[],c=[],d=0;d<12;d++){var p=l.months(moment([0,d]),""),f=l.monthsShort(moment([0,d]),"");p?u.push(p):u.push(s.months(moment([0,d]),"")),f?c.push(f):c.push(s.monthsShort(moment([0,d]),""))}var m=[],h=[],v=moment().startOf("week");v.subtract(v.format("d"));for(var g=0;g<7;g++){var y=l.weekdays(v),b=l.weekdaysShort(v);y?m.push(y):m.push(s.weekdays(v)),b?h.push(b):h.push(s.weekdaysShort(v)),v.add(1,"days")}var A=+moment().startOf("week").format("d"),S=e.element("#header").height(),C=e.element(n);C.bind("resize",_.debounce(function(){var e=C.height()-S;t.elm.fullCalendar("option","height",e)},150));var E="1"===o.ispublic,w={dayNames:m,dayNamesShort:h,defaultView:o.initialView,editable:!E,firstDay:A,forceEventDuration:!0,header:!1,height:C.height()-S,locale:moment.locale(),monthNames:u,monthNamesShort:c,nowIndicator:!0,weekNumbers:"yes"===o.weeknumbers,weekNumbersWithinDays:!0,selectable:!E},P=a.$parent.fcConfig,T=e.extend({},w,P);t.elm=r(i).fullCalendar(T)}}}]),o.directive("loading",[function(){return{restrict:"E",replace:!0,template:"<div id='loading' class='icon-loading'></div>",link:function(e,t,n){e.$watch("loading",function(e){e?r(t).show():r(t).hide()})}}}]),o.directive("openDialog",function(){return{restrict:"A",link:function(e,t,n,a){var i="#"+n.openDialog;t.bind("click",function(e){r(i).dialog("open")})}}}),o.directive("onToggleShow",function(){return{restrict:"A",scope:{onToggleShow:"@"},link:function(e,t){t.click(function(){var t=r(e.onToggleShow);t.toggle()}),e.$on("documentClicked",function(n,a){var i=r(e.onToggleShow);a.target!==t[0]&&i.hide()})}}});var s=function(){function e(e,t){var r=[],n=!0,i=!1,o=a;try{for(var l,s=e[Symbol.iterator]();!(n=(l=s.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();o.service("CalendarFactory",["$window","DavClient","Calendar","WebCal","constants",function(t,r,n,i,o){var l={},u="principal:principals/users/",c="principal:principals/groups/";l.acl=function(e,t){var n=e["{"+r.NS_DAV+"}acl"]||[],a=!1;return n.forEach(function(e){var n=e.getElementsByTagNameNS(r.NS_DAV,"href");if(0!==n.length&&n[0].textContent===t){var i=e.getElementsByTagNameNS(r.NS_DAV,"write");i.length>0&&(a=!0)}}),a},l.color=function(t){var n=t["{"+r.NS_APPLE+"}calendar-color"],a=o.fallbackColor;return e.isString(n)&&n.length>0?9===n.length?n.substr(0,7):n:a},l.components=function(e){var t=e["{"+r.NS_IETF+"}supported-calendar-component-set"]||[],n={vevent:!1,vjournal:!1,vtodo:!1};return t.forEach(function(e){var t=e.attributes.getNamedItem("name").textContent.toLowerCase();n.hasOwnProperty(t)&&(n[t]=!0)}),n},l.displayname=function(e){return e["{"+r.NS_DAV+"}displayname"]},l.enabled=function(t,n,a){return e.isDefined(t["{"+r.NS_OWNCLOUD+"}calendar-enabled"])?"1"===t["{"+r.NS_OWNCLOUD+"}calendar-enabled"]:!!n&&n===a},l.order=function(e){var t=e["{"+r.NS_APPLE+"}calendar-order"];return t?parseInt(t):a},l.owner=function(e){var t=e["{"+r.NS_DAV+"}owner"];if(Array.isArray(t)&&0!==t.length){var n=t[0].textContent.slice(0,-1),a=n.indexOf("/remote.php/dav/principals/users/");if(a!==-1)return n.substr(a+33)}return null},l.sharesAndOwnerDisplayname=function(e,t){var n=e["{"+r.NS_OWNCLOUD+"}invite"],a={users:[],groups:[]},i=null,o=e["{"+r.NS_NEXTCLOUD+"}owner-displayname"];return o&&(i=o),Array.isArray(n)?(n.forEach(function(e){var n=e.getElementsByTagNameNS(r.NS_DAV,"href");if(0!==n.length){n=n[0].textContent;var o=e.getElementsByTagNameNS(r.NS_OWNCLOUD,"common-name");o=0===o.length?n.startsWith(u)?n.substr(u.length):n.substr(c.length):o[0].textContent;var l=e.getElementsByTagNameNS(r.NS_OWNCLOUD,"access");if(0!==l.length){l=l[0];var s=l.getElementsByTagNameNS(r.NS_OWNCLOUD,"read-write");s=0!==s.length,n.startsWith(u)?n.substr(u.length)===t?i||(i=o):a.users.push({id:n.substr(u.length),displayname:o,writable:s}):n.startsWith(c)&&a.groups.push({id:n.substr(c.length),displayname:o,writable:s})}}}),[a,i]):[a,null]},l.shareableAndPublishable=function(e,t,n){var i=!1,o=!1;if(n||!t)return[i,o];var l=e["{"+r.NS_CALENDARSERVER+"}allowed-sharing-modes"];if(!Array.isArray(l)||0===l.length)return[t,o];var s=!0,u=!1,c=a;try{for(var d,p=l[Symbol.iterator]();!(s=(d=p.next()).done);s=!0){var f=d.value;i=i||"can-be-shared"===f.localName,o=o||"can-be-published"===f.localName}}catch(e){u=!0,c=e}finally{try{!s&&p.return&&p.return()}finally{if(u)throw c}}return[i,o]},l.publishedAndPublicToken=function(t){var n=!1,a=null;if(e.isDefined(t["{"+r.NS_CALENDARSERVER+"}publish-url"])){n=!0;var i=t["{"+r.NS_CALENDARSERVER+"}publish-url"][0].textContent;"/"===i.substr(-1)&&(i=i.substr(0,i.length-1));var o=i.lastIndexOf("/");a=i.substr(o+1)}return[n,a]},l.webcal=function(e){var t=e["{"+r.NS_CALENDARSERVER+"}source"];if(Array.isArray(t)){var n=t.find(function(e){return r.getNodesFullName(e)==="{"+r.NS_DAV+"}href"});return n?n.textContent:null}return null},l.calendarSkeleton=function(e,t,r){var n={},a=l.getUserFromUserPrincipal(t);n.color=l.color(e),n.displayname=l.displayname(e),n.components=l.components(e),n.order=l.order(e),n.writable=l.acl(e,t),n.owner=l.owner(e),n.enabled=l.enabled(e,n.owner,a);var i=l.sharesAndOwnerDisplayname(e,n.owner),u=s(i,2),c=u[0],d=u[1];n.shares=c,n.ownerDisplayname=d;var p=l.shareableAndPublishable(e,n.writable,r),f=s(p,2),m=f[0],h=f[1];n.shareable=m,n.publishable=h,n.owner===a||o.shareeCanEditShares||(n.shareable=!1,n.publishable=!1);var v=l.publishedAndPublicToken(e),g=s(v,2),y=g[0],b=g[1];return n.published=y,n.publicToken=b,r&&(n.enabled=!0,n.writable=!1,n.color=o.fallbackColor),r?n.writableProperties=!1:n.owner===a?n.writableProperties=n.writable:n.writableProperties=o.shareeCanEditCalendarProperties||!1,n},l.getUserFromUserPrincipal=function(e){e.endsWith("/")&&(e=e.slice(0,-1));var t=e.lastIndexOf("/");return e.substr(t+1)},this.calendar=function(e,t,r){var i=arguments.length>3&&arguments[3]!==a&&arguments[3],o=t.href,s=t.propStat[0].properties,u=l.calendarSkeleton(s,r,i);return n(e,o,u)},this.webcal=function(e,t,r){var n=arguments.length>3&&arguments[3]!==a&&arguments[3],o=t.href,s=t.propStat[0].properties,u=l.getUserFromUserPrincipal(r),c=l.calendarSkeleton(s,r,n);return c.href=l.webcal(s),c.writable=!1,c.writableProperties=u===c.owner,c.publishable=!1,c.shareable=!1,i(e,o,c)}}]),o.service("ICalFactory",["constants",function(e){var t=this;this.new=function(){var t=new ICAL.Component(["vcalendar",[],[]]);return t.updatePropertyWithValue("prodid","-//Nextcloud calendar v"+e.version),t.updatePropertyWithValue("version","2.0"),t.updatePropertyWithValue("calscale","GREGORIAN"),t},this.newEvent=function(e){var r=t.new(),n=new ICAL.Component("vevent");return r.addSubcomponent(n),n.updatePropertyWithValue("created",ICAL.Time.now()),n.updatePropertyWithValue("dtstamp",ICAL.Time.now()),n.updatePropertyWithValue("last-modified",ICAL.Time.now()),n.updatePropertyWithValue("uid",e),n.updatePropertyWithValue("dtstart",ICAL.Time.now()),r}}]);var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.factory("ImportFileWrapper",["Hook","ICalSplitterUtility",function(e,t){function r(n){var a={file:n,splittedICal:null,selectedCalendar:null,state:0,errors:0,progress:0,progressToReach:-1},i={_isAImportFileWrapperObject:!0};return a.checkIsDone=function(){a.progress===a.progressToReach&&(a.state=r.stateDone,i.emit(r.hookDone))},Object.defineProperties(i,{file:{get:function(){return a.file}},splittedICal:{get:function(){return a.splittedICal}},selectedCalendar:{get:function(){return a.selectedCalendar},set:function(e){a.selectedCalendar=e}},state:{get:function(){return a.state},set:function(e){"number"==typeof e&&(a.state=e)}},errors:{get:function(){return a.errors},set:function(e){if("number"==typeof e){var t=a.errors;a.errors=e,i.emit(r.hookErrorsChanged,e,t)}}},progress:{get:function(){return a.progress},set:function(e){if("number"==typeof e){var t=a.progress;a.progress=e,i.emit(r.hookProgressChanged,e,t),a.checkIsDone()}}},progressToReach:{get:function(){return a.progressToReach}}}),i.wasCanceled=function(){return a.state===r.stateCanceled},i.isAnalyzing=function(){return a.state===r.stateAnalyzing},i.isAnalyzed=function(){return a.state===r.stateAnalyzed},i.isScheduled=function(){return a.state===r.stateScheduled},i.isImporting=function(){return a.state===r.stateImporting},i.isDone=function(){return a.state===r.stateDone},i.hasErrors=function(){return a.errors>0},i.isEmpty=function(){return 0===a.progressToReach},i.read=function(e){var o=new FileReader;o.onload=function(n){a.splittedICal=t.split(n.target.result),a.progressToReach=a.splittedICal.vevents.length+a.splittedICal.vjournals.length+a.splittedICal.vtodos.length,0===a.progressToReach?(i.state=r.stateEmpty,i.emit(r.hookDone)):(i.state=r.stateAnalyzed,e())},o.readAsText(n)},Object.assign(i,e(a)),i}return r.isImportWrapper=function(e){return e instanceof r||"object"===("undefined"==typeof e?"undefined":l(e))&&null!==e&&null!==e._isAImportFileWrapperObject},r.stateEmpty=-2,r.stateCanceled=-1,r.stateAnalyzing=0,r.stateAnalyzed=1,r.stateScheduled=2,r.stateImporting=3,r.stateDone=4,r.hookProgressChanged=1,r.hookDone=2,r.hookErrorsChanged=3,r}]);var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.factory("CalendarListItem",["$rootScope","$window","Calendar","WebCal","isSharingAPI",function(e,t,r,n,a){function i(t){var i={calendar:t,isEditingShares:!1,isEditingProperties:!1,isDisplayingCalDAVUrl:!1,isDisplayingWebCalUrl:!1,isSendingMail:!1},o={_isACalendarListItemObject:!0};return r.isCalendar(t)?(Object.defineProperties(o,{calendar:{get:function(){return i.calendar}},publicSharingURL:{get:function(){return e.root+"p/"+i.calendar.publicToken}},publicEmbedURL:{get:function(){return e.root+"embed/"+i.calendar.publicToken}}}),o.displayCalDAVUrl=function(){return i.isDisplayingCalDAVUrl},o.showCalDAVUrl=function(){i.isDisplayingCalDAVUrl=!0},o.displayWebCalUrl=function(){return i.isDisplayingWebCalUrl},o.hideCalDAVUrl=function(){i.isDisplayingCalDAVUrl=!1},o.showWebCalUrl=function(){i.isDisplayingWebCalUrl=!0},o.hideWebCalUrl=function(){i.isDisplayingWebCalUrl=!1},o.showSharingIcon=function(){var e=i.calendar.isShareable(),t=i.calendar.isShared(),r=i.calendar.isPublishable();return!!r||(!(a||!t||!e)||a&&e)},o.isEditingShares=function(){return i.isEditingShares},o.isSendingMail=function(){return i.isSendingMail},o.toggleEditingShares=function(){i.isEditingShares=!i.isEditingShares},o.toggleSendingMail=function(){i.isSendingMail=!i.isSendingMail},o.isEditing=function(){return i.isEditingProperties},o.displayActions=function(){return!o.isEditing()},o.displayColorIndicator=function(){return!o.isEditing()&&!i.calendar.isRendering()},o.displaySpinner=function(){return!o.isEditing()&&i.calendar.isRendering()},o.openEditor=function(){o.color=i.calendar.color,o.displayname=i.calendar.displayname,i.isEditingProperties=!0},o.cancelEditor=function(){o.color="",o.displayname="",i.isEditingProperties=!1},o.saveEditor=function(){i.calendar.color=o.color,i.calendar.displayname=o.displayname,o.color="",o.displayname="",i.isEditingProperties=!1},o.isWebCal=function(){return n.isWebCal(i.calendar)},o.getOwnerName=function(){return i.calendar.ownerDisplayname||i.calendar.owner},o.getPublicDisplayname=function(){var e="("+i.calendar.owner+")",t=i.calendar.displayname.lastIndexOf(e);return i.calendar.displayname.substr(0,t-1)},o.color="",o.displayname="",o.order=0,o.selectedSharee="",o):null}return i.isCalendarListItem=function(e){return"object"===("undefined"==typeof e?"undefined":l(e))&&null!==e&&e._isACalendarListItemObject===!0},i}]);var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=function(){function e(e,t){var r=[],n=!0,i=!1,o=a;try{for(var l,s=e[Symbol.iterator]();!(n=(l=s.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();o.factory("Calendar",["$window","Hook","VEventService","TimezoneService","ColorUtility","StringUtility",function(e,t,r,n,a,i){function o(l,u,c){u=u||"",c=c||{};var d={calendarService:l,fcEventSource:{},components:c.components,mutableProperties:{color:c.color,displayname:c.displayname,enabled:c.enabled,order:c.order,published:c.published},updatedProperties:[],tmpId:i.uid(),url:u,owner:c.owner,ownerDisplayname:c.ownerDisplayname,shares:c.shares,publicToken:c.publicToken,publishable:c.publishable,warnings:[],shareable:c.shareable,writable:c.writable,writableProperties:c.writableProperties},p={_isACalendarObject:!0};return d.fcEventSource.events=function(e,t,a,i){var l=this;d.fcEventSource.isRendering=!0,p.emit(o.hookFinishedRendering),e=moment(e.stripZone().format()),t=moment(t.stripZone().format());var u=n.get(a),c=r.getAll(p,e,t);Promise.all([u,c]).then(function(r){var n=s(r,2),a=n[0],u=n[1],c=[],f=[];return u.forEach(function(r){var n=r.getFcEvent(e,t,a).then(function(e){f=f.concat(e)}).catch(function(e){p.addWarning(e),console.log(r,e)});c.push(n)}),Promise.all(c).then(function(){i(f),l.reportEventChange(),d.fcEventSource.isRendering=!1,p.emit(o.hookFinishedRendering)})}).catch(function(r){if("Unknown timezone"===r&&"UTC"!==a){var n=p.fcEventSource.events.bind(l);n(e,t,"UTC",i)}p.addWarning(r),d.fcEventSource.isRendering=!1,p.emit(o.hookFinishedRendering),console.log(d.url,r)})},d.fcEventSource.editable=d.writable,d.fcEventSource.calendar=p,d.fcEventSource.isRendering=!1,d.setUpdated=function(e){d.updatedProperties.indexOf(e)===-1&&d.updatedProperties.push(e)},Object.defineProperties(p,{color:{get:function(){return d.mutableProperties.color},set:function(e){var t=d.mutableProperties.color;e!==t&&(d.mutableProperties.color=e,d.setUpdated("color"),p.emit(o.hookColorChanged,e,t))}},textColor:{get:function(){var e=a.extractRGBFromHexString(d.mutableProperties.color);return a.generateTextColorFromRGB(e.r,e.g,e.b)}},displayname:{get:function(){return d.mutableProperties.displayname},set:function(e){var t=d.mutableProperties.displayname;e!==t&&(d.mutableProperties.displayname=e,d.setUpdated("displayname"),p.emit(o.hookDisplaynameChanged,e,t))}},enabled:{get:function(){return d.mutableProperties.enabled},set:function(e){var t=d.mutableProperties.enabled;e!==t&&(d.mutableProperties.enabled=e,d.setUpdated("enabled"),p.emit(o.hookEnabledChanged,e,t))}},order:{get:function(){return d.mutableProperties.order},set:function(e){var t=d.mutableProperties.order;e!==t&&(d.mutableProperties.order=e,d.setUpdated("order"),p.emit(o.hookOrderChanged,e,t))}},components:{get:function(){return d.components}},url:{get:function(){return d.url}},downloadUrl:{get:function(){var e=d.url;return"/"===e.slice(e.length-1)&&(e=e.slice(0,e.length-1)),e+="?export"},configurable:!0},caldav:{get:function(){return e.location.origin+d.url}},publicToken:{get:function(){return d.publicToken},set:function(e){d.publicToken=e}},published:{get:function(){return d.mutableProperties.published},set:function(e){d.mutableProperties.published=e}},publishable:{get:function(){return d.publishable}},fcEventSource:{get:function(){return d.fcEventSource}},shares:{get:function(){return d.shares}},tmpId:{get:function(){return d.tmpId}},warnings:{get:function(){return d.warnings}},owner:{get:function(){return d.owner}},ownerDisplayname:{get:function(){return d.ownerDisplayname}}}),p.hasUpdated=function(){return 0!==d.updatedProperties.length},p.getUpdated=function(){return d.updatedProperties},p.resetUpdated=function(){d.updatedProperties=[]},p.addWarning=function(e){d.warnings.push(e)},p.hasWarnings=function(){return d.warnings.length>0},p.resetWarnings=function(){d.warnings=[]},p.toggleEnabled=function(){d.mutableProperties.enabled=!d.mutableProperties.enabled,d.setUpdated("enabled"),p.emit(o.hookEnabledChanged,d.mutableProperties.enabled,!d.mutableProperties.enabled)},p.isShared=function(){return 0!==d.shares.groups.length||0!==d.shares.users.length},p.isPublished=function(){return d.mutableProperties.published},p.isPublishable=function(){return d.publishable},p.isShareable=function(){return d.shareable},p.isRendering=function(){return d.fcEventSource.isRendering},p.isWritable=function(){return d.writable},p.arePropertiesWritable=function(){return d.writableProperties},p.eventsAccessibleViaCalDAV=function(){return!0},p.refresh=function(){},p.update=function(){return d.calendarService.update(p)},p.delete=function(){return d.calendarService.delete(p)},p.share=function(e,t,r,n){return d.calendarService.share(p,e,t,r,n)},p.unshare=function(e,t,r,n){return d.calendarService.unshare(p,e,t,r,n)},p.publish=function(){return d.calendarService.publish(p)},p.unpublish=function(){return d.calendarService.unpublish(p)},Object.assign(p,t(d)),p}return o.isCalendar=function(e){return"object"===("undefined"==typeof e?"undefined":l(e))&&null!==e&&e._isACalendarObject===!0},o.hookFinishedRendering=1,o.hookColorChanged=2,o.hookDisplaynameChanged=3,o.hookEnabledChanged=4,o.hookOrderChanged=5,o}]);var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.factory("FcEvent",["SimpleEvent",function(e){function t(t,r,n,a){var i={vevent:t,event:r};i.iCalEvent=new ICAL.Event(r);var o=i.vevent.uri;r.hasProperty("recurrence-id")&&(o+=i.event.getFirstPropertyValue("recurrence-id").toICALString());var l="date"===n.icaltype&&"date"===a.icaltype;i.allDay=l;var s={_isAFcEventObject:!0,id:o,allDay:l,start:n.toJSDate(),end:a.toJSDate(),repeating:i.iCalEvent.isRecurring(),className:["fcCalendar-id-"+t.calendar.tmpId],editable:t.calendar.isWritable(),backgroundColor:t.calendar.color,borderColor:t.calendar.color,textColor:t.calendar.textColor,title:r.getFirstPropertyValue("summary")};return Object.defineProperties(s,{vevent:{get:function(){return i.vevent},enumerable:!0},event:{get:function(){return i.event},enumerable:!0},calendar:{get:function(){return i.vevent.calendar},enumerable:!0}}),s.getSimpleEvent=function(){return e(i.event)},s.drop=function(e,t,r,n,a){e=(new ICAL.Duration).fromSeconds(e.asSeconds());var o=(new ICAL.Duration).fromSeconds(n.asSeconds()),l=(new ICAL.Duration).fromSeconds(a.asSeconds()),s=i.event.getFirstProperty("dtstart"),u=s.getFirstValue();if(u.isDate=t,u.addDuration(e),u.zone=t?"floating":u.zone,i.allDay&&!t){var c=ICAL.TimezoneService.get(r);"UTC"===r&&(r="Z"),u.zone=c,"Z"!==r&&(s.setParameter("tzid",r),i.event.parent&&i.event.parent.addSubcomponent(c.component))}if(!i.allDay&&t&&s.removeParameter("tzid"),i.event.updatePropertyWithValue("dtstart",u),i.allDay!==t)if(i.event.hasProperty("duration"))i.event.updatePropertyWithValue("duration",t?l:o);else{var d=u.clone();d.addDuration(t?l:o);var p=i.event.updatePropertyWithValue("dtend",d),f=s.getParameter("tzid");f?p.setParameter("tzid",f):p.removeParameter("tzid")}else if(i.event.hasProperty("dtend")){var m=i.event.getFirstPropertyValue("dtend");m.addDuration(e),i.event.updatePropertyWithValue("dtend",m)}i.allDay=t,i.vevent.touch()},s.resize=function(e){if(e=(new ICAL.Duration).fromSeconds(e.asSeconds()),i.event.hasProperty("duration")){var t=i.event.getFirstPropertyValue("duration");t.fromSeconds(e.toSeconds()+t.toSeconds()),i.event.updatePropertyWithValue("duration",t)}else if(i.event.hasProperty("dtend")){var n=i.event.getFirstPropertyValue("dtend");n.addDuration(e),i.event.updatePropertyWithValue("dtend",n)}else if(i.event.hasProperty("dtstart")){var a=r.getFirstProperty("dtstart"),o=a.getFirstValue().clone();o.addDuration(e);var l=i.event.addPropertyWithValue("dtend",o),s=a.getParameter("tzid");s&&l.setParameter("tzid",s)}i.vevent.touch()},s.lock=function(){i.lock=!0},s.unlock=function(){i.lock=!1},s}return t.isFcEvent=function(e){return"object"===("undefined"==typeof e?"undefined":l(e))&&null!==e&&e._isAFcEventObject===!0},t}]),o.factory("Hook",function(){return function(e){e.hooks={};var t={};return t.emit=function(t,r,n){Array.isArray(e.hooks[t])&&e.hooks[t].forEach(function(e){e(r,n)})},t.register=function(t,r){e.hooks[t]=e.hooks[t]||[],e.hooks[t].push(r)},t}});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.factory("SimpleEvent",function(){function t(e,t){if(e.allDay&&(e[t].parameters.zone="floating"),e[t].parameters.zone=e[t].parameters.zone||"floating","floating"!==e[t].parameters.zone&&!ICAL.TimezoneService.has(e[t].parameters.zone))throw new Error("Requested timezone not found ("+e[t].parameters.zone+")");var r=ICAL.Time.fromJSDate(e[t].value.toDate(),!1);return r.isDate=e.allDay,"floating"!==e[t].parameters.zone&&(r.zone=ICAL.TimezoneService.get(e[t].parameters.zone)),r}function r(r){var a={event:r,patched:!1,oldProperties:{}},i={_isASimpleEventObject:!0};e.extend(i,n),a.generateOldProperties=function(){a.oldProperties={};for(var t in n)a.oldProperties[t]=e.copy(i[t])},i.checkDtStartBeforeDtEnd=function(){var e=t(i,"dtstart"),r=t(i,"dtend");return r.compare(e)!==-1},i.patch=function(){if(a.patched)throw new Error("SimpleEvent was already patched, patching not possible");for(var e in u){var t=u[e],r=t.reader,n=t.parameters;a.oldProperties[e]!==i[e]&&(null===i[e]?a.event.removeAllProperties(e):r(a.event,a.oldProperties,i,e,n))}for(var o in d){var l=d[o];l(a.event,a.oldProperties,i)}a.patched=!0};for(var o in u){var l=u[o],s=l.parser,p=l.parameters;a.event.hasProperty(o)&&s(i,a.event,o,p)}for(var f in c){var m=c[f];m(i,a.event)}return a.generateOldProperties(),i}var n={summary:null,location:null,organizer:null,class:null,description:null,status:null,alarm:null,attendee:null,dtstart:null,dtend:null,repeating:null,rdate:null,rrule:null,exdate:null},a=["role","rsvp","partstat","cutype","cn","delegated-from","delegated-to"],i=["cn"],o={date:function(e,t,r,n){n=(n||[]).concat(["tzid"]),o._parseSingle(e,t,r,n,function(e){var t=e.getFirstValue();return"duration"===e.type?t.toSeconds():moment(t.toJSDate())})},dates:function(e,t,r,n){n=(n||[]).concat(["tzid"]),o._parseMultiple(e,t,r,n,function(e){var t=e.getValues(),r=[];return t.forEach(function(t){"duration"===e.type?r.push(t.toSeconds()):r.push(moment(t.toJSDate()))}),r})},string:function(e,t,r,n){o._parseSingle(e,t,r,n,function(e){return e.isMultiValue?e.getValues():e.getFirstValue()})},strings:function(e,t,r,n){o._parseMultiple(e,t,r,n,function(e){return e.isMultiValue?e.getValues():e.getFirstValue()})},_parseSingle:function(e,t,r,n,a){var i=t.getFirstProperty(r);i&&(e[r]={parameters:o._parseParameters(i,n),type:i.type},i.isMultiValue?e[r].values=a(i):e[r].value=a(i))},_parseMultiple:function(e,t,r,n,a){e[r]=e[r]||[];var i=t.getAllProperties(r),l=0;i.forEach(function(t){var i={group:l,parameters:o._parseParameters(t,n),type:t.type};t.isMultiValue?i.values=a(t):i.value=a(t),e[r].push(i),t.setParameter("x-nc-group-id",l.toString()),l++})},_parseParameters:function(e,t){var r={};return t?(t.forEach(function(t){r[t]=e.getParameter(t)}),r):r}},s={date:function(e,t,r,n,a){a=(a||[]).concat(["tzid"]),s._readSingle(e,t,r,n,a,function(e,t){return"duration"===e.type?ICAL.Duration.fromSeconds(e.value):ICAL.Time.fromJSDate(e.value.toDate())})},dates:function(e,t,r,n,a){a=(a||[]).concat(["tzid"]),s._readMultiple(e,t,r,n,a,function(e,t){var r=[];return e.values.forEach(function(t){"duration"===e.type?r.push(ICAL.Duration.fromSeconds(t)):r.push(ICAL.Time.fromJSDate(t.toDate()))}),r})},string:function(e,t,r,n,a){s._readSingle(e,t,r,n,a,function(e,t){return t?e.values:e.value})},strings:function(e,t,r,n,a){s._readMultiple(e,t,r,n,a,function(e,t){return t?e.values:e.value})},_readSingle:function(e,t,r,n,a,i){if(r[n]&&(r[n].hasOwnProperty("value")||r[n].hasOwnProperty("values"))){var o=r[n].hasOwnProperty("values"),l=e.updatePropertyWithValue(n,i(r[n],o));s._readParameters(l,r[n],a)}},_readMultiple:function(e,t,r,n,a,i){var o=[],l=void 0,u=void 0,c=void 0;t[n]=t[n]||[],t[n].forEach(function(e){o.push(e.group)}),r[n]=r[n]||[],r[n].forEach(function(t){var r=t.hasOwnProperty("values"),d=i(t,r);if(o.indexOf(t.group)===-1){var p=new ICAL.Property(n);s._setProperty(p,d,r),s._readParameters(p,t,a),e.addProperty(p)}else{o.splice(o.indexOf(t.group),1),l=e.getAllProperties(n);for(u in l)l.hasOwnProperty(u)&&(c=l[u].getParameter("x-nc-group-id"),null!==c&&parseInt(c)===t.group&&(s._setProperty(l[u],d,r),s._readParameters(l[u],t,a)))}}),l=e.getAllProperties(n),l.forEach(function(t){c=t.getParameter("x-nc-group-id"),o.indexOf(parseInt(c))!==-1&&e.removeProperty(t),t.removeParameter("x-nc-group-id")})},_readParameters:function(e,t,r){r&&t.parameters&&r.forEach(function(r){t.parameters[r]?e.setParameter(r,t.parameters[r]):e.removeParameter(t.parameters[r])})},_setProperty:function(e,t,r){r?e.setValues(t):e.setValue(t)}},u={summary:{parser:o.string,reader:s.string},location:{parser:o.string,reader:s.string},attendee:{parser:o.strings,reader:s.strings,parameters:a},organizer:{parser:o.string,reader:s.string,parameters:i},class:{parser:o.string,reader:s.string},description:{parser:o.string,reader:s.string},status:{parser:o.string,reader:s.string}},c={alarm:function(e,t){e.alarm=e.alarm||[];var r=t.getAllSubcomponents("valarm"),n=0;r.forEach(function(t){var r={group:n,action:{},trigger:{},repeat:{},duration:{},attendee:[]};if(o.string(r,t,"action"),o.date(r,t,"trigger"),o.string(r,t,"repeat"),o.date(r,t,"duration"),o.strings(r,t,"attendee",a),"duration"===r.trigger.type&&t.hasProperty("trigger")){var i=t.getFirstProperty("trigger"),l=i.getParameter("related");l?r.trigger.related=l:r.trigger.related="start"}e.alarm.push(r),t.getFirstProperty("action").setParameter("x-nc-group-id",n.toString()),n++})},date:function(e,t){var r=t.getFirstPropertyValue("dtstart"),n=void 0;t.hasProperty("dtend")?n=t.getFirstPropertyValue("dtend"):t.hasProperty("duration")?(n=r.clone(),n.addDuration(t.getFirstPropertyValue("duration"))):n=r.clone(),e.dtstart={parameters:{zone:r.zone.toString()},value:moment({years:r.year,months:r.month-1,date:r.day,hours:r.hour,minutes:r.minute,seconds:r.seconds})},e.dtend={parameters:{zone:n.zone.toString()},value:moment({years:n.year,months:n.month-1,date:n.day,hours:n.hour,minutes:n.minute,seconds:n.seconds})},e.allDay="date"===r.icaltype&&"date"===n.icaltype},repeating:function(e,t){var r=new ICAL.Event(t);e.repeating=r.isRecurring();var n=t.getFirstPropertyValue("rrule");n?e.rrule={count:n.count,freq:n.freq,interval:n.interval,parameters:n.parts,until:null}:e.rrule={freq:"NONE"}}},d={alarm:function(e,t,r){function n(e){return e.group}var i={},o="alarm";t[o]=t[o]||[];var l=t[o].map(n);r[o]=r[o]||[];var u=r[o].map(n),c=l.filter(function(e){return u.indexOf(e)===-1});e.getAllSubcomponents("valarm").forEach(function(e){var t=e.getFirstProperty("action").getParameter("x-nc-group-id");i[t]=e}),c.forEach(function(t){i[t]&&(e.removeSubcomponent(i[t]),delete i[t])}),r[o].forEach(function(r){var n=void 0,o=void 0;l.indexOf(r.group)===-1?(n=new ICAL.Component("VALARM"),e.addSubcomponent(n),o={}):(n=i[r.group],o=t.alarm.find(function(e){return e.group===r.group})),s.string(n,o,r,"action",[]),s.date(n,o,r,"trigger",[]),s.string(n,o,r,"repeat",[]),s.date(n,o,r,"duration",[]),s.strings(n,o,r,"attendee",a),n.getFirstProperty("action").removeParameter("x-nc-group-id")})},date:function(e,t,r){if(e.removeAllProperties("dtstart"),e.removeAllProperties("dtend"),e.removeAllProperties("duration"),r.allDay&&(r.dtstart.parameters.zone="floating",r.dtend.parameters.zone="floating"),r.dtstart.parameters.zone=r.dtstart.parameters.zone||"floating",r.dtend.parameters.zone=r.dtend.parameters.zone||"floating","floating"!==r.dtstart.parameters.zone&&!ICAL.TimezoneService.has(r.dtstart.parameters.zone))throw new Error("Requested timezone not found ("+r.dtstart.parameters.zone+")");if("floating"!==r.dtend.parameters.zone&&!ICAL.TimezoneService.has(r.dtend.parameters.zone))throw new Error("Requested timezone not found ("+r.dtend.parameters.zone+")");var n=ICAL.Time.fromJSDate(r.dtstart.value.toDate(),!1);n.isDate=r.allDay;var a=ICAL.Time.fromJSDate(r.dtend.value.toDate(),!1);a.isDate=r.allDay;var i=["UTC"],o=e.parent.getAllSubcomponents("vtimezone");o.forEach(function(e){i.push(e.getFirstPropertyValue("tzid"))});var l=new ICAL.Property("dtstart",e);if("floating"!==r.dtstart.parameters.zone){"UTC"!==r.dtstart.parameters.zone&&l.setParameter("tzid",r.dtstart.parameters.zone);var s=ICAL.TimezoneService.get(r.dtstart.parameters.zone);n.zone=s,i.indexOf(r.dtstart.parameters.zone)===-1&&(e.parent.addSubcomponent(s.component),i.push(r.dtstart.parameters.zone))}l.setValue(n);var u=new ICAL.Property("dtend",e);if("floating"!==r.dtend.parameters.zone){"UTC"!==r.dtend.parameters.zone&&u.setParameter("tzid",r.dtend.parameters.zone);var c=ICAL.TimezoneService.get(r.dtend.parameters.zone);a.zone=c,i.indexOf(r.dtend.parameters.zone)===-1&&e.parent.addSubcomponent(c.component)}u.setValue(a),e.addProperty(l),e.addProperty(u)},repeating:function(e,t,r){if(null===r.rrule||"NONE"===r.rrule.freq)return e.removeAllProperties("rdate"), e.removeAllProperties("rrule"),void e.removeAllProperties("exdate");if(!r.rrule.dontTouch){var n={interval:r.rrule.interval,freq:r.rrule.freq};r.rrule.count&&(n.count=r.rrule.count);var a=new ICAL.Recur(n);e.updatePropertyWithValue("rrule",a)}}};return r.isSimpleEvent=function(e){return"object"===("undefined"==typeof e?"undefined":l(e))&&null!==e&&e._isASimpleEventObject===!0},r});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.factory("SplittedICal",function(){function e(e,t){var r={name:e,color:t,vevents:[],vjournals:[],vtodos:[]},n={_isASplittedICalObject:!0};return Object.defineProperties(n,{name:{get:function(){return r.name}},color:{get:function(){return r.color}},vevents:{get:function(){return r.vevents}},vjournals:{get:function(){return r.vjournals}},vtodos:{get:function(){return r.vtodos}},objects:{get:function(){return[].concat(r.vevents).concat(r.vjournals).concat(r.vtodos)}}}),n.addObject=function(e,t){switch(e){case"vevent":r.vevents.push(t);break;case"vjournal":r.vjournals.push(t);break;case"vtodo":r.vtodos.push(t)}},n}return e.isSplittedICal=function(t){return t instanceof e||"object"===("undefined"==typeof t?"undefined":l(t))&&null!==t&&null!==t._isASplittedICalObject},e}),o.factory("Timezone",function(){var t=function(t){if(e.extend(this,{_props:{}}),t instanceof ICAL.Timezone)this._props.jCal=t,this._props.name=t.tzid;else if("string"==typeof t){var r=ICAL.parse(t),n=new ICAL.Component(r),a=null;a="vtimezone"===n.name?new ICAL.Timezone(n):new ICAL.Timezone(n.getFirstSubcomponent("vtimezone")),this._props.jCal=a,this._props.name=a.tzid}};return t.prototype={get jCal(){return this._props.jCal},get name(){return this._props.name}},t});var s=function(){function e(e,t){var r=[],n=!0,i=!1,o=a;try{for(var l,s=e[Symbol.iterator]();!(n=(l=s.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.factory("VEvent",["TimezoneService","FcEvent","SimpleEvent","ICalFactory","StringUtility",function(e,t,r,n,o){function u(n,i,o){var l=arguments.length>3&&arguments[3]!==a?arguments[3]:"",s={calendar:n,comp:i,uri:o,etag:l},u={_isAVEventObject:!0};if(!s.comp||!s.comp.jCal||0===s.comp.jCal.length)throw new TypeError("Given comp is not a valid calendar");var c=i.getAllSubcomponents("vtimezone");if(c.forEach(function(e){var t=new ICAL.Timezone(e);ICAL.TimezoneService.register(t.tzid,t)}),!o){var d=s.comp.getFirstSubcomponent("vevent");s.uri=d.getFirstPropertyValue("uid")}return s.calculateDTEnd=function(e){if(e.hasProperty("dtend"))return e.getFirstPropertyValue("dtend");if(e.hasProperty("duration")){var t=e.getFirstPropertyValue("dtstart").clone();return t.addDuration(e.getFirstPropertyValue("duration")),t}return e.getFirstPropertyValue("dtstart").clone()},s.convertTz=function(e,t){return s.needsTzConversion(e)&&t&&(e=e.convertToZone(t)),e},s.needsTzConversion=function(e){return"date"!==e.icaltype&&e.zone!==ICAL.Timezone.utcTimezone&&e.zone!==ICAL.Timezone.localTimezone},s.getMissingEventTimezones=function(){var e=[],t=["dtstart","dtend"],r=s.comp.getAllSubcomponents("vevent");return r.forEach(function(r){t.forEach(function(t){if(r.hasProperty(t)){var n=r.getFirstProperty(t),a=n.getParameter("tzid");a&&!ICAL.TimezoneService.has(a)&&e.indexOf(a)===-1&&e.push(a)}})}),e},Object.defineProperties(u,{calendar:{get:function(){return s.calendar},set:function(e){s.calendar=e}},comp:{get:function(){return s.comp}},data:{get:function(){return s.comp.toString()}},etag:{get:function(){return s.etag},set:function(e){s.etag=e}},uri:{get:function(){return s.uri}}}),u.getFcEvent=function(r,n,a){return new Promise(function(i,o){var l=ICAL.Time.fromJSDate(r.toDate()),c=ICAL.Time.fromJSDate(n.toDate()),d=[],p=s.getMissingEventTimezones(),f=[];p.forEach(function(t){var r=e.get(t).then(function(e){return e}).catch(function(e){return null});f.push(r)}),Promise.all(f).then(function(e){e.forEach(function(e){if(e){var t=new ICAL.Timezone(e.jCal);ICAL.TimezoneService.register(e.name,t)}})}).then(function(){var e=s.comp.getAllSubcomponents("vevent"),r=e.filter(function(e){return e.hasProperty("recurrence-id")}),n=e.find(function(e){return!e.hasProperty("recurrence-id")}),o=new ICAL.Event(n,{exceptions:r});n.hasProperty("dtstart")||i([]);var p=n.getFirstProperty("dtstart"),f=p.getFirstValue("dtstart"),m=s.calculateDTEnd(n);if(o.isRecurring())for(var h=new ICAL.RecurExpansion({component:n,dtstart:f}),v=void 0;v=h.next();){var g=o.getOccurrenceDetails(v);if(!(g.endDate.compare(l)<0)){if(g.startDate.compare(c)>0)break;var y=s.convertTz(g.startDate,a.jCal),b=s.convertTz(g.endDate,a.jCal),A=t(u,g.item.component,y,b);d.push(A)}}else{var S=s.convertTz(f,a.jCal),C=s.convertTz(m,a.jCal),E=t(u,n,S,C);d.push(E)}i(d)})})},u.getSimpleEvent=function(e){for(var t=s.comp.getAllSubcomponents("vevent"),n=t.length,a=0;a<n;a++){var i=t[a],o=i.hasProperty("recurrence-id"),l=null;if(o&&(l=i.getFirstPropertyValue("recurrence-id").toICALString()),!o&&!e||o&&e===l)return r(i)}throw new Error("Event not found")},u.touch=function(){var e=s.comp.getFirstSubcomponent("vevent");e.updatePropertyWithValue("last-modified",ICAL.Time.now())},u}return u.isVEvent=function(e){return"object"===("undefined"==typeof e?"undefined":l(e))&&null!==e&&e._isAVEventObject===!0},u.sanDate=function(e){return e.split("\n").forEach(function(t,r){var n=["DTSTART","DTEND"],a=/[^:]*/.exec(t)[0],i=null;n.indexOf(a)>=0&&"T::"===t.trim().substr(-3)&&(i=t.replace(/[^0-9]/g,""),e=e.replace(t,a+";VALUE=DATE:"+i))}),e},u.sanNoDateValue=function(e){return e.split("\n").forEach(function(t,r){if(t.indexOf(";VALUE=DATE")===-1){var n=["DTSTART","DTEND"],a=t.split(":"),o=s(a,2),l=o[0],u=o[1],c=l.split(";"),d=i(c),p=d[0],f=d.slice(1);n.indexOf(p)>=0&&f.indexOf("VALUE=DATE")===-1&&8===u.length&&(e=e.replace(t,l+";VALUE=DATE:"+u))}}),e},u.sanTrigger=function(e){var t=/^TRIGGER:P$/gm;return e.match(t)&&(e=e.replace(t,"TRIGGER:P0D")),e},u.fromRawICS=function(e,t,r){var n=arguments.length>3&&arguments[3]!==a?arguments[3]:"",i=void 0;t.search("T::")>0&&(t=u.sanDate(t)),t.search("TRIGGER:P")>0&&(t=u.sanTrigger(t)),t=u.sanNoDateValue(t);try{var o=ICAL.parse(t);i=new ICAL.Component(o)}catch(e){throw console.log(e),new TypeError("given ics data was not valid")}return u(e,i,r,n)},u.fromStartEnd=function(e,t,r){var a=o.uid(),i=n.newEvent(a),l=o.uid("Nextcloud","ics"),s=u(null,i,l),c=s.getSimpleEvent();return c.allDay=!e.hasTime()&&!t.hasTime(),c.dtstart={type:e.hasTime()?"datetime":"date",value:e,parameters:{zone:r}},c.dtend={type:t.hasTime()?"datetime":"date",value:t,parameters:{zone:r}},c.patch(),s},u}]);var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=function(){function e(e,t){var r=[],n=!0,i=!1,o=a;try{for(var l,s=e[Symbol.iterator]();!(n=(l=s.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();o.factory("WebCal",["$http","Calendar","VEvent","TimezoneService","WebCalService","WebCalUtility",function(e,t,r,n,a,i){function o(e,o,l){var u={calendarService:e,updatedProperties:[],storedUrl:l.href,url:i.fixURL(l.href)},c=t(e,o,l);c._isAWebCalObject=!0,u.setUpdated=function(e){u.updatedProperties.indexOf(e)===-1&&u.updatedProperties.push(e)},Object.defineProperties(c,{downloadUrl:{get:function(){return u.url}},storedUrl:{get:function(){return u.storedUrl}}}),c.fcEventSource.events=function(e,i,o,l){var d=this;c.fcEventSource.isRendering=!0,c.emit(t.hookFinishedRendering);var p=!u.storedUrl.startsWith("https://"),f=n.get(o),m=a.get(u.url,p);Promise.all([f,m]).then(function(n){var a=s(n,2),o=a[0],u=a[1],p=[],f=[];return u.vevents.forEach(function(t){try{var n=r.fromRawICS(c,t),a=n.getFcEvent(e,i,o).then(function(e){f=f.concat(e)}).catch(function(e){c.addWarning(e),console.log(event,e)});p.push(a)}catch(e){console.log(e)}}),Promise.all(p).then(function(){l(f),d.reportEventChange(),c.fcEventSource.isRendering=!1,c.emit(t.hookFinishedRendering)})}).catch(function(r){if("Unknown timezone"===r&&"UTC"!==o){var n=c.fcEventSource.events.bind(d);n(e,i,"UTC",l)}else if(r.redirect===!0){if(u.storedUrl===r.new_url)return Promise.reject("Fatal error. Redirected URL matched original URL. Aborting");u.storedUrl=r.new_url,u.url=r.new_url,u.setUpdated("storedUrl"),c.update();var a=c.fcEventSource.events.bind(d);a(e,i,o,l)}else c.addWarning(r),console.log(r),c.fcEventSource.isRendering=!1,c.emit(t.hookFinishedRendering)})},c.eventsAccessibleViaCalDAV=function(){return!1};var d=c.getUpdated;c.getUpdated=function(){var e=d();return e.concat(u.updatedProperties)};var p=c.resetUpdated;return c.resetUpdated=function(){p(),u.updatedProperties=[]},c.delete=function(){return localStorage.removeItem(c.storedUrl),u.calendarService.delete(c)},c}return o.isWebCal=function(e){return"object"===("undefined"==typeof e?"undefined":l(e))&&null!==e&&e._isAWebCalObject===!0},o}]),o.filter("calendarListFilter",["CalendarListItem",function(e){return function(t){return Array.isArray(t)?t.filter(function(t){return!!e.isCalendarListItem(t)&&t.calendar.isWritable()}):[]}}]),o.filter("subscriptionListFilter",["CalendarListItem",function(e){return function(t){return Array.isArray(t)?t.filter(function(t){return!!e.isCalendarListItem(t)&&!t.calendar.isWritable()}):[]}}]);var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.filter("attendeeFilter",function(){return function(e){return"object"===("undefined"==typeof e?"undefined":l(e))&&e?"object"===l(e.parameters)&&"string"==typeof e.parameters.cn?e.parameters.cn:"string"==typeof e.value&&e.value.startsWith("MAILTO:")?e.value.substr(7):e.value||"":""}});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.filter("attendeeNotOrganizerFilter",function(){return function(e,t){if("string"!=typeof t||""===t)return Array.isArray(e)?e:[];if(!Array.isArray(e))return[];var r="MAILTO:"+t;return e.filter(function(e){return"object"===("undefined"==typeof e?"undefined":l(e))&&e.value!==r})}});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.filter("calendarFilter",function(){return function(e){return Array.isArray(e)?e.filter(function(e){return"object"===("undefined"==typeof e?"undefined":l(e))&&e.isWritable()}):[]}});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.filter("calendarSelectorFilter",function(){return function(e,t){if(!Array.isArray(e))return[];var r=e.filter(function(e){return e.isWritable()});return"object"===("undefined"==typeof t?"undefined":l(t))&&t?t.isWritable()?(r.indexOf(t)===-1&&r.push(t),r):[t]:r}}),o.filter("datepickerFilter",function(){return function(e,r){if(!(e instanceof Date)||"string"!=typeof r)return"";switch(r){case"agendaDay":return moment(e).format("ll");case"agendaWeek":return t("calendar","Week {number} of {year}",{number:moment(e).week(),year:1===moment(e).week()?moment(e).add(1,"week").year():moment(e).year()});case"month":return 1===moment(e).week()?moment(e).add(1,"week").format("MMMM GGGG"):moment(e).format("MMMM GGGG");default:return""}}});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.filter("importCalendarFilter",function(){return function(e,t){if(!Array.isArray(e)||"object"!==("undefined"==typeof t?"undefined":l(t))||!t||"object"!==l(t.splittedICal)||!t.splittedICal)return[];var r=t.splittedICal.vevents.length,n=t.splittedICal.vjournals.length,a=t.splittedICal.vtodos.length;return e.filter(function(e){return!(0!==r&&!e.components.vevent)&&(!(0!==n&&!e.components.vjournal)&&!(0!==a&&!e.components.vtodo))})}});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.filter("importErrorFilter",function(){return function(e){if("object"!==("undefined"==typeof e?"undefined":l(e))||!e||"number"!=typeof e.errors)return"";switch(e.errors){case 0:return t("calendar","Successfully imported");case 1:return t("calendar","Partially imported, 1 failure");default:return t("calendar","Partially imported, {n} failures",{n:e.errors})}}});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.filter("simpleReminderDescription",function(){function e(e){var t=e.action.value;return t&&r.hasOwnProperty(t)?r[t]:t}var r={AUDIO:t("calendar","Audio alarm"),DISPLAY:t("calendar","Pop-up"),EMAIL:t("calendar","E-Mail"),NONE:t("calendar","None")};return function(r){if("object"!==("undefined"==typeof r?"undefined":l(r))||!r||"object"!==l(r.trigger)||!r.trigger)return"";var n="duration"===r.trigger.type,a="start"===r.trigger.related;if(n){var i=moment.duration(Math.abs(r.trigger.value),"seconds").humanize();return r.trigger.value<0?a?t("calendar","{type} {time} before the event starts",{type:e(r),time:i}):t("calendar","{type} {time} before the event ends",{type:e(r),time:i}):r.trigger.value>0?a?t("calendar","{type} {time} after the event starts",{type:e(r),time:i}):t("calendar","{type} {time} after the event ends",{type:e(r),time:i}):a?t("calendar","{type} at the event's start",{type:e(r)}):t("calendar","{type} at the event's end",{type:e(r)})}return r.editor&&moment.isMoment(r.editor.absMoment)?t("calendar","{type} at {time}",{type:e(r),time:r.editor.absMoment.format("LLLL")}):""}});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.filter("subscriptionFilter",function(){return function(e){return Array.isArray(e)?e.filter(function(e){return"object"===("undefined"==typeof e?"undefined":l(e))&&!e.isWritable()}):[]}}),o.filter("timezoneFilter",["$filter",function(e){return function(t){if("string"!=typeof t)return"";t=t.split("_").join(" ");var r=t.split("/");if(1===r.length)return r[0];var n=r[0],a=e("timezoneWithoutContinentFilter")(r.slice(1).join("/"));return a+" ("+n+")"}}]),o.filter("timezoneWithoutContinentFilter",function(){return function(e){return e=e.split("_").join(" "),e=e.replace("St ","St. "),e.split("/").join(" - ")}}),o.service("AutoCompletionService",["$rootScope","$http",function(e,t){this.searchAttendee=function(r){return t.get(e.baseUrl+"autocompletion/attendee",{params:{search:r}}).then(function(e){return e.data})},this.searchLocation=function(r){return t.get(e.baseUrl+"autocompletion/location",{params:{location:r}}).then(function(e){return e.data})}}]);var s=function(){function e(e,t){var r=[],n=!0,i=!1,o=a;try{for(var l,s=e[Symbol.iterator]();!(n=(l=s.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();o.service("CalendarService",["DavClient","StringUtility","XMLUtility","CalendarFactory","isPublic","constants",function(e,r,i,o,l,u){var c={self:this,calendarHome:null,userPrincipal:null,usedURLs:[]},d={};this.privateAPI=d;var p=["{"+e.NS_DAV+"}displayname","{"+e.NS_DAV+"}resourcetype","{"+e.NS_IETF+"}calendar-description","{"+e.NS_IETF+"}calendar-timezone","{"+e.NS_APPLE+"}calendar-order","{"+e.NS_APPLE+"}calendar-color","{"+e.NS_IETF+"}supported-calendar-component-set","{"+e.NS_CALENDARSERVER+"}publish-url","{"+e.NS_CALENDARSERVER+"}allowed-sharing-modes","{"+e.NS_OWNCLOUD+"}calendar-enabled","{"+e.NS_DAV+"}acl","{"+e.NS_DAV+"}owner","{"+e.NS_OWNCLOUD+"}invite","{"+e.NS_CALENDARSERVER+"}source","{"+e.NS_NEXTCLOUD+"}owner-displayname"],f="{"+e.NS_IETF+"}calendar",m="{"+e.NS_CALENDARSERVER+"}subscribed",h=["color","displayname","enabled","order","storedUrl"],v={color:[e.NS_APPLE,"a:calendar-color"],displayname:[e.NS_DAV,"d:displayname"],enabled:[e.NS_OWNCLOUD,"o:calendar-enabled"],order:[e.NS_APPLE,"a:calendar-order"]},g=u.SHARE_TYPE_USER,y=u.SHARE_TYPE_GROUP;c.bootPromise=function(){if(l)return Promise.resolve(!0);var t=e.buildUrl(OC.linkToRemoteBase("dav")),r=["{"+e.NS_DAV+"}current-user-principal"],n=0,a={requesttoken:OC.requestToken};return e.propFind(t,r,n,a).then(function(t){if(!e.wasRequestSuccessful(t.status)||t.body.propStat.length<1)throw new Error("current-user-principal could not be determined");var r=t.body.propStat[0].properties;c.userPrincipal=r["{"+e.NS_DAV+"}current-user-principal"][0].textContent;var n=c.userPrincipal,a=["{"+e.NS_IETF+"}calendar-home-set"],i=0,o={requesttoken:OC.requestToken};return e.propFind(n,a,i,o).then(function(t){if(!e.wasRequestSuccessful(t.status)||t.body.propStat.length<1)throw new Error("calendar-home-set could not be determind");var r=t.body.propStat[0].properties;c.calendarHome=r["{"+e.NS_IETF+"}calendar-home-set"][0].textContent})})}(),c.getResourceType=function(t){var r=t.propStat[0].properties["{"+e.NS_DAV+"}resourcetype"];if(!r)return!1;var n=r.find(function(t){var r=e.getNodesFullName(t);return[f,m].indexOf(r)!==-1});return!!n&&e.getNodesFullName(n)},c.getShareValue=function(e,t){if(e!==g&&e!==y)throw new Error("Unknown shareType given");var r=void 0;return r=e===g?"principal:principals/users/":"principal:principals/groups/",r+=t},c.isURIAvailable=function(e){var t=c.calendarHome+e+"/";return c.usedURLs.indexOf(t)===-1},this.getAll=function(){return c.bootPromise.then(function(){var t=e.buildUrl(c.calendarHome),r=1,n={requesttoken:OC.requestToken};return e.propFind(t,p,r,n).then(function(t){if(!e.wasRequestSuccessful(t.status))throw new Error("Loading calendars failed");var r=[];return t.body.forEach(function(t){if(!(t.propStat.length<1)){c.usedURLs.push(t.href);var n=e.getResponseCodeFromHTTPResponse(t.propStat[0].status);if(e.wasRequestSuccessful(n)){var a=c.getResourceType(t);if(a===f){var i=o.calendar(d,t,c.userPrincipal);r.push(i)}else if(a===m){var l=o.webcal(d,t,c.userPrincipal);r.push(l)}}}}),r.filter(function(e){return e.components.vevent===!0})})})},this.get=function(t){return c.bootPromise.then(function(){var r=e.buildUrl(t),n=0,a={requesttoken:OC.requestToken};return e.propFind(r,p,n,a).then(function(t){var r=t.body;if(r.propStat.length<1)throw new Error("Loading requested calendar failed");var n=e.getResponseCodeFromHTTPResponse(r.propStat[0].status);if(!e.wasRequestSuccessful(n))throw new Error("Loading requested calendar failed");var a=c.getResourceType(r);return a===f?o.calendar(d,r,c.userPrincipal):a===m?o.webcal(d,r,c.userPrincipal):void 0}).then(function(e){if(e.components.vevent===!1)throw new Error("Requested calendar exists, but does not qualify for storing events");return e})})},this.getPublicCalendar=function(t){var r=OC.linkToRemoteBase("dav")+"/public-calendars/"+t,n=e.buildUrl(r),a=0,i={requesttoken:OC.requestToken};return e.propFind(n,p,a,i).then(function(t){var r=t.body;if(r.propStat.length<1)throw new Error("Loading requested calendar failed");var n=e.getResponseCodeFromHTTPResponse(r.propStat[0].status);if(!e.wasRequestSuccessful(n))throw new Error("Loading requested calendar failed");return o.calendar(d,r,"",!0)}).then(function(e){if(e.components.vevent===!1)throw new Error("Requested calendar exists, but does not qualify for storing events");return e})},this.create=function(t,n){var o=arguments.length>2&&arguments[2]!==a?arguments[2]:["vevent","vtodo"];return c.bootPromise.then(function(){var a=i.getRootSkeleton([e.NS_DAV,"d:mkcol"],[e.NS_DAV,"d:set"],[e.NS_DAV,"d:prop"]),l=s(a,2),u=l[0],d=l[1];d.push({name:[e.NS_DAV,"d:resourcetype"],children:[{name:[e.NS_DAV,"d:collection"]},{name:[e.NS_IETF,"c:calendar"]}]}),d.push({name:[e.NS_DAV,"d:displayname"],value:t}),d.push({name:[e.NS_APPLE,"a:calendar-color"],value:n}),d.push({name:[e.NS_OWNCLOUD,"o:calendar-enabled"],value:"1"}),d.push({name:[e.NS_IETF,"c:supported-calendar-component-set"],children:o.map(function(t){return{name:[e.NS_IETF,"c:comp"],attributes:[["name",t.toUpperCase()]]}})});var p="MKCOL",f=r.uri(t,c.isURIAvailable),m=c.calendarHome+f+"/",h={"Content-Type":"application/xml; charset=utf-8",requesttoken:OC.requestToken},v=i.serialize(u);return e.request(p,m,h,v).then(function(e){if(201!==e.status)throw new Error("Creating a calendar failed");return c.usedURLs.push(m),c.self.get(m)})})},this.createWebCal=function(t,n,a){return c.bootPromise.then(function(){var o=i.getRootSkeleton([e.NS_DAV,"d:mkcol"],[e.NS_DAV,"d:set"],[e.NS_DAV,"d:prop"]),l=s(o,2),d=l[0],p=l[1];p.push({name:[e.NS_DAV,"d:resourcetype"],children:[{name:[e.NS_DAV,"d:collection"]},{name:[e.NS_CALENDARSERVER,"cs:subscribed"]}]}),p.push({name:[e.NS_DAV,"d:displayname"],value:t}),p.push({name:[e.NS_APPLE,"a:calendar-color"],value:n}),p.push({name:[e.NS_OWNCLOUD,"o:calendar-enabled"],value:"1"}),p.push({name:[e.NS_CALENDARSERVER,"cs:source"],children:[{name:[e.NS_DAV,"d:href"],value:a}]});var f="MKCOL",m=r.uri(t,c.isURIAvailable),h=c.calendarHome+m+"/",v={"Content-Type":"application/xml; charset=utf-8",requesttoken:OC.requestToken},g=i.serialize(d);return e.request(f,h,v,g).then(function(e){if(201!==e.status)throw new Error("Creating a webcal subscription failed");return c.usedURLs.push(h),c.self.get(h).then(function(e){return u.needsWebCalWorkaround?(e.enabled=!0,e.displayname=t,e.color=n,e.update()):e})})})},d.get=function(e){},d.update=function(t){var r=t.getUpdated();if(0===r.length)return Promise.resolve(t);var n=i.getRootSkeleton([e.NS_DAV,"d:propertyupdate"],[e.NS_DAV,"d:set"],[e.NS_DAV,"d:prop"]),a=s(n,2),o=a[0],l=a[1];r.forEach(function(r){if(h.indexOf(r)!==-1){var n=t[r];"enabled"===r&&(n=n?"1":"0"),"storedUrl"===r?l.push({name:[e.NS_CALENDARSERVER,"cs:source"],children:[{name:[e.NS_DAV,"d:href"],value:n}]}):l.push({name:v[r],value:n})}}),t.resetUpdated();var u="PROPPATCH",c=t.url,d={"Content-Type":"application/xml; charset=utf-8",requesttoken:OC.requestToken},p=i.serialize(o);return e.request(u,c,d,p).then(function(r){if(!e.wasRequestSuccessful(r.status))throw new Error("Updating calendar failed");return t})},d.delete=function(t){var r="DELETE",n=t.url,a={requesttoken:OC.requestToken};return e.request(r,n,a).then(function(t){if(!e.wasRequestSuccessful(t.status))throw new Error("Deleting calendar failed");var r=c.usedURLs.indexOf(n);c.usedURLs.splice(r,1)})},d.share=function(r,n,a,o,l){var u=i.getRootSkeleton([e.NS_OWNCLOUD,"o:share"],[e.NS_OWNCLOUD,"o:set"]),d=s(u,2),p=d[0],f=d[1],m=c.getShareValue(n,a);f.push({name:[e.NS_DAV,"d:href"],value:m}),f.push({name:[e.NS_OWNCLOUD,"o:summary"],value:t("calendar","{calendar} shared by {owner}",{calendar:r.displayname,owner:r.owner})}),o&&f.push({name:[e.NS_OWNCLOUD,"o:read-write"]});var h="POST",v=r.url,y={"Content-Type":"application/xml; charset=utf-8",requesttoken:OC.requestToken},b=i.serialize(p);return e.request(h,v,y,b).then(function(t){if(!e.wasRequestSuccessful(t.status))throw new Error("Sharing calendar failed");l||(n===g?r.shares.users.push({id:a,displayname:a,writable:o}):r.shares.groups.push({id:a,displayname:a,writable:o}))})},d.unshare=function(t,r,n){var a=i.getRootSkeleton([e.NS_OWNCLOUD,"o:share"],[e.NS_OWNCLOUD,"o:remove"]),o=s(a,2),l=o[0],u=o[1],d=c.getShareValue(r,n);u.push({name:[e.NS_DAV,"d:href"],value:d});var p="POST",f=t.url,m={"Content-Type":"application/xml; charset=utf-8",requesttoken:OC.requestToken},h=i.serialize(l);return e.request(p,f,m,h).then(function(a){if(!e.wasRequestSuccessful(a.status))throw new Error("Sharing calendar failed");if(r===g){var i=t.shares.users.findIndex(function(e){return e.id===n});t.shares.users.splice(i,1)}else{var o=t.shares.groups.findIndex(function(e){return e.id===n});t.shares.groups.splice(o,1)}})},d.publish=function(t){var r=i.getRootSkeleton([e.NS_CALENDARSERVER,"cs:publish-calendar"]),a=s(r,1),o=a[0],l="POST",u=t.url,c={"Content-Type":"application/xml; charset=utf-8",requesttoken:n},d=i.serialize(o);return e.request(l,u,c,d).then(function(t){return!!e.wasRequestSuccessful(t.status)})},d.unpublish=function(t){var r=i.getRootSkeleton([e.NS_CALENDARSERVER,"cs:unpublish-calendar"]),a=s(r,1),o=a[0],l="POST",u=t.url,c={"Content-Type":"application/xml; charset=utf-8",requesttoken:n},d=i.serialize(o);return e.request(l,u,c,d).then(function(t){return!!e.wasRequestSuccessful(t.status)})}}]),o.service("DavClient",["$window",function(e){var t=new dav.Client({baseUrl:OC.linkToRemote("dav/calendars"),xmlNamespaces:{"DAV:":"d","urn:ietf:params:xml:ns:caldav":"c","http://apple.com/ns/ical/":"aapl","http://owncloud.org/ns":"oc","http://nextcloud.com/ns":"nc","http://calendarserver.org/ns/":"cs"}});return t.NS_DAV="DAV:",t.NS_IETF="urn:ietf:params:xml:ns:caldav",t.NS_APPLE="http://apple.com/ns/ical/",t.NS_OWNCLOUD="http://owncloud.org/ns",t.NS_NEXTCLOUD="http://nextcloud.com/ns",t.NS_CALENDARSERVER="http://calendarserver.org/ns/",t.buildUrl=function(t){return"/"!==t.substr(0,1)&&(t="/"+t),e.location.origin+t},t.getNodesFullName=function(e){return"{"+e.namespaceURI+"}"+e.localName},t.getResponseCodeFromHTTPResponse=function(e){return parseInt(e.split(" ")[1])},t.wasRequestSuccessful=function(e){return e>=200&&e<=299},t}]),o.service("EventsEditorDialogService",["$uibModal","constants","settings",function(t,r,n){var a="eventspopovereditor.html",i="eventssidebareditor.html",o={fcEvent:null,promise:null,eventModal:null};o.cleanup=function(){o.fcEvent=null,o.promise=null,o.eventModal=null},o.showPopover=function(){return e.element(window).width()>768},o.positionPopover=function(t){e.element("#popover-container").css("display","none"),e.forEach(t,function(t){e.element(".modal").css(t.name,t.value)}),e.element("#popover-container").css("display","block")},o.openDialog=function(n,l,s,u,c,d,p,f,m){o.fcEvent=p,o.eventModal=t.open({appendTo:n===a?e.element("#popover-container"):e.element("#app-content"),controller:"EditorController",resolve:{vevent:function(){return p.vevent},simpleEvent:function(){return f},calendar:function(){return m},isNew:function(){return null===p.vevent.etag||""===p.vevent.etag},emailAddress:function(){return r.emailAddress}},scope:d,templateUrl:n,windowClass:n===a?"popover":null}),n===i&&e.element("#app-content").addClass("with-app-sidebar"),o.eventModal.rendered.then(function(){return o.positionPopover(c)}),o.eventModal.result.then(function(t){"proceed"===t.action?o.openDialog(i,l,s,u,[],d,p,f,t.calendar):(n===i&&e.element("#app-content").removeClass("with-app-sidebar"),u(),o.cleanup(),l({calendar:t.calendar,vevent:t.vevent}))}).catch(function(t){n===i&&e.element("#app-content").removeClass("with-app-sidebar"),"superseded"!==t&&o.cleanup(),u(),s(t)})},o.openRepeatQuestion=function(){},this.open=function(e,t,r,l,s){return o.fcEvent===t?o.promise:(o.fcEvent&&o.eventModal.dismiss("superseded"),o.promise=new Promise(function(u,c){var d=r();l();var p=t.vevent?t.vevent.calendar:null,f=t.getSimpleEvent();o.showPopover()&&!n.skipPopover?o.openDialog(a,u,c,s,d,e,t,f,p):o.openDialog(i,u,c,s,[],e,t,f,p)}),o.promise)}}]);var s=function(){function e(e,t){var r=[],n=!0,i=!1,o=a;try{for(var l,s=e[Symbol.iterator]();!(n=(l=s.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();o.service("HashService",["$location",function(e){var t={hashId:null,parameters:new Map};!function(){var r=e.url();if(r&&""!==r&&(r.startsWith("#")&&(r=r.substr(1)),r.startsWith("/")&&(r=r.substr(1)),r.includes("?"))){var n=r.indexOf("?");t.hashId=r.substr(0,n);var a=r.substr(n+1);a.split("&").forEach(function(e){var r=e.split("="),n=s(r,2),a=n[0],i=n[1];t.parameters.set(a,decodeURIComponent(i))})}}(),this.runIfApplicable=function(e,r){e===t.hashId&&r(t.parameters)}}]),o.factory("is",function(){return{loading:!1}}),o.service("MailerService",["$rootScope","DavClient",function(e,t){this.sendMail=function(r,a,i){var o={"Content-Type":"application/json; charset=utf-8",requesttoken:n},l={to:r,url:a,name:i};return t.request("POST",e.baseUrl+"public/sendmail",o,JSON.stringify(l))}}]),o.service("SettingsService",["$rootScope","$http",function(e,t){this.getView=function(){return t({method:"GET",url:e.baseUrl+"config",params:{key:"view"}}).then(function(e){return e.data.value})},this.setView=function(r){return t({method:"POST",url:e.baseUrl+"config",data:{key:"view",value:r}}).then(function(){return!0})},this.getSkipPopover=function(){return t({method:"GET",url:e.baseUrl+"config",params:{key:"skipPopover"}}).then(function(e){return e.data.value})},this.setSkipPopover=function(r){return t({method:"POST",url:e.baseUrl+"config",data:{key:"skipPopover",value:r}}).then(function(){return!0})},this.getShowWeekNr=function(){return t({method:"GET",url:e.baseUrl+"config",params:{key:"showWeekNr"}}).then(function(e){return e.data.value})},this.setShowWeekNr=function(r){return t({method:"POST",url:e.baseUrl+"config",data:{key:"showWeekNr",value:r}}).then(function(){return!0})},this.passedFirstRun=function(){return t({method:"POST",url:e.baseUrl+"config",data:{key:"firstRun"}}).then(function(){return!0})}}]),o.service("TimezoneService",["$rootScope","$http","Timezone",function(e,t,r){var n={map:{},self:this,timezones:{},timezonesBeingLoaded:{}};n.map["Etc/UTC"]="UTC",n.timezones.UTC=new r(ICAL.TimezoneService.get("UTC")),n.timezones.GMT=n.timezones.UTC,n.timezones.Z=n.timezones.UTC,n.timezones.FLOATING=new r(ICAL.Timezone.localTimezone);var i=["Africa/Abidjan","Africa/Accra","Africa/Addis_Ababa","Africa/Algiers","Africa/Asmara","Africa/Asmera","Africa/Bamako","Africa/Bangui","Africa/Banjul","Africa/Bissau","Africa/Blantyre","Africa/Brazzaville","Africa/Bujumbura","Africa/Cairo","Africa/Casablanca","Africa/Ceuta","Africa/Conakry","Africa/Dakar","Africa/Dar_es_Salaam","Africa/Djibouti","Africa/Douala","Africa/El_Aaiun","Africa/Freetown","Africa/Gaborone","Africa/Harare","Africa/Johannesburg","Africa/Juba","Africa/Kampala","Africa/Khartoum","Africa/Kigali","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Lome","Africa/Luanda","Africa/Lubumbashi","Africa/Lusaka","Africa/Malabo","Africa/Maputo","Africa/Maseru","Africa/Mbabane","Africa/Mogadishu","Africa/Monrovia","Africa/Nairobi","Africa/Ndjamena","Africa/Niamey","Africa/Nouakchott","Africa/Ouagadougou","Africa/Porto-Novo","Africa/Sao_Tome","Africa/Timbuktu","Africa/Tripoli","Africa/Tunis","Africa/Windhoek","America/Adak","America/Anchorage","America/Anguilla","America/Antigua","America/Araguaina","America/Argentina/Buenos_Aires","America/Argentina/Catamarca","America/Argentina/ComodRivadavia","America/Argentina/Cordoba","America/Argentina/Jujuy","America/Argentina/La_Rioja","America/Argentina/Mendoza","America/Argentina/Rio_Gallegos","America/Argentina/Salta","America/Argentina/San_Juan","America/Argentina/San_Luis","America/Argentina/Tucuman","America/Argentina/Ushuaia","America/Aruba","America/Asuncion","America/Atikokan","America/Bahia","America/Bahia_Banderas","America/Barbados","America/Belem","America/Belize","America/Blanc-Sablon","America/Boa_Vista","America/Bogota","America/Boise","America/Cambridge_Bay","America/Campo_Grande","America/Cancun","America/Caracas","America/Cayenne","America/Cayman","America/Chicago","America/Chihuahua","America/Costa_Rica","America/Creston","America/Cuiaba","America/Curacao","America/Danmarkshavn","America/Dawson","America/Dawson_Creek","America/Denver","America/Detroit","America/Dominica","America/Edmonton","America/Eirunepe","America/El_Salvador","America/Fortaleza","America/Glace_Bay","America/Godthab","America/Goose_Bay","America/Grand_Turk","America/Grenada","America/Guadeloupe","America/Guatemala","America/Guayaquil","America/Guyana","America/Halifax","America/Havana","America/Hermosillo","America/Indiana/Indianapolis","America/Indiana/Knox","America/Indiana/Marengo","America/Indiana/Petersburg","America/Indiana/Tell_City","America/Indiana/Vevay","America/Indiana/Vincennes","America/Indiana/Winamac","America/Inuvik","America/Iqaluit","America/Jamaica","America/Juneau","America/Kentucky/Louisville","America/Kentucky/Monticello","America/Kralendijk","America/La_Paz","America/Lima","America/Los_Angeles","America/Louisville","America/Lower_Princes","America/Maceio","America/Managua","America/Manaus","America/Marigot","America/Martinique","America/Matamoros","America/Mazatlan","America/Menominee","America/Merida","America/Metlakatla","America/Mexico_City","America/Miquelon","America/Moncton","America/Monterrey","America/Montevideo","America/Montreal","America/Montserrat","America/Nassau","America/New_York","America/Nipigon","America/Nome","America/Noronha","America/North_Dakota/Beulah","America/North_Dakota/Center","America/North_Dakota/New_Salem","America/Ojinaga","America/Panama","America/Pangnirtung","America/Paramaribo","America/Phoenix","America/Port-au-Prince","America/Port_of_Spain","America/Porto_Velho","America/Puerto_Rico","America/Rainy_River","America/Rankin_Inlet","America/Recife","America/Regina","America/Resolute","America/Rio_Branco","America/Santa_Isabel","America/Santarem","America/Santiago","America/Santo_Domingo","America/Sao_Paulo","America/Scoresbysund","America/Shiprock","America/Sitka","America/St_Barthelemy","America/St_Johns","America/St_Kitts","America/St_Lucia","America/St_Thomas","America/St_Vincent","America/Swift_Current","America/Tegucigalpa","America/Thule","America/Thunder_Bay","America/Tijuana","America/Toronto","America/Tortola","America/Vancouver","America/Whitehorse","America/Winnipeg","America/Yakutat","America/Yellowknife","Antarctica/Casey","Antarctica/Davis","Antarctica/DumontDUrville","Antarctica/Macquarie","Antarctica/Mawson","Antarctica/McMurdo","Antarctica/Palmer","Antarctica/Rothera","Antarctica/South_Pole","Antarctica/Syowa","Antarctica/Vostok","Arctic/Longyearbyen","Asia/Aden","Asia/Almaty","Asia/Amman","Asia/Anadyr","Asia/Aqtau","Asia/Aqtobe","Asia/Ashgabat","Asia/Baghdad","Asia/Bahrain","Asia/Baku","Asia/Bangkok","Asia/Beirut","Asia/Bishkek","Asia/Brunei","Asia/Calcutta","Asia/Choibalsan","Asia/Chongqing","Asia/Colombo","Asia/Damascus","Asia/Dhaka","Asia/Dili","Asia/Dubai","Asia/Dushanbe","Asia/Gaza","Asia/Harbin","Asia/Hebron","Asia/Ho_Chi_Minh","Asia/Hong_Kong","Asia/Hovd","Asia/Irkutsk","Asia/Istanbul","Asia/Jakarta","Asia/Jayapura","Asia/Jerusalem","Asia/Kabul","Asia/Kamchatka","Asia/Karachi","Asia/Kashgar","Asia/Kathmandu","Asia/Katmandu","Asia/Khandyga","Asia/Kolkata","Asia/Krasnoyarsk","Asia/Kuala_Lumpur","Asia/Kuching","Asia/Kuwait","Asia/Macau","Asia/Magadan","Asia/Makassar","Asia/Manila","Asia/Muscat","Asia/Nicosia","Asia/Novokuznetsk","Asia/Novosibirsk","Asia/Omsk","Asia/Oral","Asia/Phnom_Penh","Asia/Pontianak","Asia/Pyongyang","Asia/Qatar","Asia/Qyzylorda","Asia/Rangoon","Asia/Riyadh","Asia/Saigon","Asia/Sakhalin","Asia/Samarkand","Asia/Seoul","Asia/Shanghai","Asia/Singapore","Asia/Taipei","Asia/Tashkent","Asia/Tbilisi","Asia/Tehran","Asia/Thimphu","Asia/Tokyo","Asia/Ulaanbaatar","Asia/Urumqi","Asia/Ust-Nera","Asia/Vientiane","Asia/Vladivostok","Asia/Yakutsk","Asia/Yekaterinburg","Asia/Yerevan","Atlantic/Azores","Atlantic/Bermuda","Atlantic/Canary","Atlantic/Cape_Verde","Atlantic/Faeroe","Atlantic/Faroe","Atlantic/Jan_Mayen","Atlantic/Madeira","Atlantic/Reykjavik","Atlantic/South_Georgia","Atlantic/St_Helena","Atlantic/Stanley","Australia/Adelaide","Australia/Brisbane","Australia/Broken_Hill","Australia/Currie","Australia/Darwin","Australia/Eucla","Australia/Hobart","Australia/Lindeman","Australia/Lord_Howe","Australia/Melbourne","Australia/Perth","Australia/Sydney","Europe/Amsterdam","Europe/Andorra","Europe/Athens","Europe/Belfast","Europe/Belgrade","Europe/Berlin","Europe/Bratislava","Europe/Brussels","Europe/Bucharest","Europe/Budapest","Europe/Busingen","Europe/Chisinau","Europe/Copenhagen","Europe/Dublin","Europe/Gibraltar","Europe/Guernsey","Europe/Helsinki","Europe/Isle_of_Man","Europe/Istanbul","Europe/Jersey","Europe/Kaliningrad","Europe/Kiev","Europe/Lisbon","Europe/Ljubljana","Europe/London","Europe/Luxembourg","Europe/Madrid","Europe/Malta","Europe/Mariehamn","Europe/Minsk","Europe/Monaco","Europe/Moscow","Europe/Nicosia","Europe/Oslo","Europe/Paris","Europe/Podgorica","Europe/Prague","Europe/Riga","Europe/Rome","Europe/Samara","Europe/San_Marino","Europe/Sarajevo","Europe/Simferopol","Europe/Skopje","Europe/Sofia","Europe/Stockholm","Europe/Tallinn","Europe/Tirane","Europe/Uzhgorod","Europe/Vaduz","Europe/Vatican","Europe/Vienna","Europe/Vilnius","Europe/Volgograd","Europe/Warsaw","Europe/Zagreb","Europe/Zaporozhye","Europe/Zurich","Indian/Antananarivo","Indian/Chagos","Indian/Christmas","Indian/Cocos","Indian/Comoro","Indian/Kerguelen","Indian/Mahe","Indian/Maldives","Indian/Mauritius","Indian/Mayotte","Indian/Reunion","Pacific/Apia","Pacific/Auckland","Pacific/Chatham","Pacific/Chuuk","Pacific/Easter","Pacific/Efate","Pacific/Enderbury","Pacific/Fakaofo","Pacific/Fiji","Pacific/Funafuti","Pacific/Galapagos","Pacific/Gambier","Pacific/Guadalcanal","Pacific/Guam","Pacific/Honolulu","Pacific/Johnston","Pacific/Kiritimati","Pacific/Kosrae","Pacific/Kwajalein","Pacific/Majuro","Pacific/Marquesas","Pacific/Midway","Pacific/Nauru","Pacific/Niue","Pacific/Norfolk","Pacific/Noumea","Pacific/Pago_Pago","Pacific/Palau","Pacific/Pitcairn","Pacific/Pohnpei","Pacific/Ponape","Pacific/Port_Moresby","Pacific/Rarotonga","Pacific/Saipan","Pacific/Tahiti","Pacific/Tarawa","Pacific/Tongatapu","Pacific/Truk","Pacific/Wake","Pacific/Wallis","Pacific/Yap"],o=["UTC","GMT","Z"]; n.knowsTimezone=function(e){e=e.toUpperCase();var t=i.find(function(t){return e===t.toUpperCase()}),r=o.find(function(t){return e===t.toUpperCase()});return t!==a||r!==a},n.buildUrl=function(t){return e.baseUrl+"timezones/"+t+".ics"},this.current=function(){var e=jstz.determine(),t=e?e.name():"UTC";return n.map[t]&&(t=n.map[t]),t},this.get=function(e){return e=e.toUpperCase(),n.knowsTimezone(e)?n.timezones[e]?Promise.resolve(n.timezones[e]):n.timezonesBeingLoaded[e]?n.timezonesBeingLoaded[e]:(n.timezonesBeingLoaded[e]=t({method:"GET",url:n.buildUrl(e)}).then(function(t){var a=new r(t.data);return n.timezones[e]=a,delete n.timezonesBeingLoaded[e],a}),n.timezonesBeingLoaded[e]):Promise.reject("Unknown timezone")},this.listAll=function(){return Promise.resolve(i.concat(o))}}]);var s=function(){function e(e,t){var r=[],n=!0,i=!1,o=a;try{for(var l,s=e[Symbol.iterator]();!(n=(l=s.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();o.service("VEventService",["DavClient","StringUtility","XMLUtility","VEvent",function(e,t,r,n){var i={calendarDataPropName:"{"+e.NS_IETF+"}calendar-data",eTagPropName:"{"+e.NS_DAV+"}getetag",self:this};i.getEventUrl=function(e){return e.calendar.url+e.uri},i.getTimeRangeString=function(e){var t=e.utc();return t.format("YYYYMMDD")+"T"+t.format("HHmmss")+"Z"},this.getAll=function(t,a,o){var l=r.getRootSkeleton([e.NS_IETF,"c:calendar-query"]),u=s(l,2),c=u[0],d=u[1];d.push({name:[e.NS_DAV,"d:prop"],children:[{name:[e.NS_DAV,"d:getetag"]},{name:[e.NS_IETF,"c:calendar-data"]}]}),d.push({name:[e.NS_IETF,"c:filter"],children:[{name:[e.NS_IETF,"c:comp-filter"],attributes:[["name","VCALENDAR"]],children:[{name:[e.NS_IETF,"c:comp-filter"],attributes:[["name","VEVENT"]],children:[{name:[e.NS_IETF,"c:time-range"],attributes:[["start",i.getTimeRangeString(a)],["end",i.getTimeRangeString(o)]]}]}]}]});var p=t.url,f={"Content-Type":"application/xml; charset=utf-8",Depth:1,requesttoken:OC.requestToken},m=r.serialize(c);return e.request("REPORT",p,f,m).then(function(r){if(!e.wasRequestSuccessful(r.status))return Promise.reject(r.status);var a=[];for(var o in r.body)if(r.body.hasOwnProperty(o)){var l=r.body[o],s=l.propStat[0].properties,u=s[i.calendarDataPropName],c=s[i.eTagPropName],d=l.href.substr(l.href.lastIndexOf("/")+1);try{var p=n.fromRawICS(t,u,d,c);a.push(p)}catch(e){console.log(e)}}return a})},this.get=function(t,r){var a=t.url+r,i={requesttoken:OC.requestToken};return e.request("GET",a,i,"").then(function(a){if(!e.wasRequestSuccessful(a.status))return Promise.reject(a.status);var i=a.body,o=a.xhr.getResponseHeader("ETag");try{return n.fromRawICS(t,i,r,o)}catch(e){return console.log(e),Promise.reject(e)}})},this.create=function(r,n){var o=!(arguments.length>2&&arguments[2]!==a)||arguments[2],l={"Content-Type":"text/calendar; charset=utf-8",requesttoken:OC.requestToken},s=t.uid("Nextcloud","ics"),u=r.url+s;return e.request("PUT",u,l,n).then(function(t){return e.wasRequestSuccessful(t.status)?!o||i.self.get(r,s):Promise.reject(t.status)})},this.update=function(t){var r=i.getEventUrl(t),n={"Content-Type":"text/calendar; charset=utf-8","If-Match":t.etag,requesttoken:OC.requestToken},a=t.data;return e.request("PUT",r,n,a).then(function(r){return e.wasRequestSuccessful(r.status)?(t.etag=r.xhr.getResponseHeader("ETag"),!0):Promise.reject(r.status)})},this.delete=function(t){var r=i.getEventUrl(t),n={"If-Match":t.etag,requesttoken:OC.requestToken};return e.request("DELETE",r,n,"").then(function(t){return!!e.wasRequestSuccessful(t.status)||Promise.reject(t.status)})}}]),o.service("WebCalService",["$http","ICalSplitterUtility","WebCalUtility","SplittedICal",function(e,r,n,i){var o=this,l={cachedSplittedICals:{}};this.get=function(s,u){if(l.cachedSplittedICals.hasOwnProperty(s))return Promise.resolve(l.cachedSplittedICals[s]);u===a&&(u=n.allowDowngrade(s)),s=n.fixURL(s);var c=n.buildProxyURL(s),d=JSON.parse(localStorage.getItem(s));return d&&d.timestamp>(new Date).getTime()?Promise.resolve(r.split(d.value)):e.get(c).then(function(e){var n=r.split(e.data);return i.isSplittedICal(n)?(l.cachedSplittedICals[s]=n,localStorage.setItem(s,JSON.stringify({value:e.data,timestamp:(new Date).getTime()+72e5})),n):Promise.reject(t("calendar","Please enter a valid WebCal-URL"))}).catch(function(e){if(n.downgradePossible(s,u)){var r=n.downgradeURL(s);return o.get(r,!1).then(function(e){return l.cachedSplittedICals[s]=e,e})}return 422===e.status?Promise.reject({error:!0,redirect:!1,message:e.data.message}):400===e.status?Promise.reject({error:!1,redirect:!0,new_url:e.data.new_url}):Promise.reject({error:!0,redirect:!1,message:t("calendar","Severe error in webcal proxy. Please contact administrator for more information.")})})}}]);var s=function(){function e(e,t){var r=[],n=!0,i=!1,o=a;try{for(var l,s=e[Symbol.iterator]();!(n=(l=s.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();o.service("ColorUtility",function(){var t=this;if(this.colors=[],this.generateTextColorFromRGB=function(e,t,r){var n=(299*e+587*t+114*r)/1e3;return n>130?"#000000":"#FAFAFA"},this.extractRGBFromHexString=function(e){var t,r={r:255,g:255,b:255};if("string"!=typeof e)return r;switch(e.length){case 4:return t=e.match(/^#([0-9a-f]{3})$/i),Array.isArray(t)&&t[1]?{r:17*parseInt(t[1].charAt(0),16),g:17*parseInt(t[1].charAt(1),16),b:17*parseInt(t[1].charAt(2),16)}:r;case 7:case 9:var n=new RegExp("^#([0-9a-f]{"+(e.length-1)+"})$","i");return t=e.match(n),Array.isArray(t)&&t[1]?{r:parseInt(t[1].substr(0,2),16),g:parseInt(t[1].substr(2,2),16),b:parseInt(t[1].substr(4,2),16)}:r;default:return r}},this._ensureTwoDigits=function(e){return 1===e.length?"0"+e:e},this.rgbToHex=function(e,t,r){if(Array.isArray(e)){var n=e,a=s(n,3);e=a[0],t=a[1],r=a[2]}return"#"+this._ensureTwoDigits(parseInt(e,10).toString(16))+this._ensureTwoDigits(parseInt(t,10).toString(16))+this._ensureTwoDigits(parseInt(r,10).toString(16))},this._hslToRgb=function(e,t,r){if(Array.isArray(e)){var n=e,a=s(n,3);e=a[0],t=a[1],r=a[2]}return t/=100,r/=100,hslToRgb(e,t,r)},this.randomColor=function(){if("function"==typeof String.prototype.toHsl){var e=Math.random().toString().toHsl();return t.rgbToHex(t._hslToRgb(e))}return t.colors[Math.floor(Math.random()*t.colors.length)]},"function"==typeof String.prototype.toHsl){var r=["15","9","4","b","6","11","74","f","57"];e.forEach(r,function(e){var r=e.toHsl();t.colors.push(t.rgbToHex(t._hslToRgb(r)))})}else this.colors=["#31CC7C","#317CCC","#FF7A66","#F1DB50","#7C31CC","#CC317C","#3A3B3D","#CACBCD"]}),o.service("ICalSplitterUtility",["ICalFactory","SplittedICal",function(e,t){var r="x-apple-calendar-color",n="x-wr-calname",a=["vevent","vjournal","vtodo"];this.split=function(i){var o=ICAL.parse(i),l=new ICAL.Component(o),s={},u=l.getAllSubcomponents("vtimezone");a.forEach(function(e){var t=l.getAllSubcomponents(e);s[e]={},t.forEach(function(t){var r=t.getFirstPropertyValue("uid");s[e][r]=s[e][r]||[],s[e][r].push(t)})});var c=l.getFirstPropertyValue(n),d=l.getFirstPropertyValue(r),p=t(c,d);return a.forEach(function(t){var r=function(r){if(!s[t].hasOwnProperty(r))return"continue";var n=e.new();u.forEach(function(e){n.addSubcomponent(e)}),s[t][r].forEach(function(e){n.addSubcomponent(e)}),p.addObject(t,n.toString())};for(var n in s[t]){r(n)}}),p}}]),o.service("PopoverPositioningUtility",["$window",function(t){var r={popoverHeight:300,popoverWidth:450};Object.defineProperties(r,{headerHeight:{get:function(){return e.element("#header").height()}},navigationWidth:{get:function(){return e.element("#app-navigation").width()}},windowX:{get:function(){return t.innerWidth-r.navigationWidth}},windowY:{get:function(){return t.innerHeight-r.headerHeight}}}),r.isAgendaDayView=function(e){return"agendaDay"===e.name},r.isAgendaView=function(e){return e.name.startsWith("agenda")},r.isInTheUpperPart=function(e){return(e-r.headerHeight)/r.windowY<.5},r.isInTheLeftQuarter=function(e){return(e-r.navigationWidth)/r.windowX<.25},r.isInTheRightQuarter=function(e){return(e-r.navigationWidth)/r.windowX>.75},this.calculate=function(e,t,n,a,i){var o=[],l=n-e;return r.isInTheUpperPart(t)?r.isAgendaView(i)?o.push({name:"top",value:t-r.headerHeight+30}):o.push({name:"top",value:a-r.headerHeight+20}):o.push({name:"top",value:t-r.headerHeight-r.popoverHeight-20}),r.isAgendaDayView(i)?o.push({name:"left",value:e-r.popoverWidth/2-20+l/2}):r.isInTheLeftQuarter(e)?o.push({name:"left",value:e-20+l/2}):r.isInTheRightQuarter(e)?o.push({name:"left",value:e-r.popoverWidth-20+l/2}):o.push({name:"left",value:e-r.popoverWidth/2-20+l/2}),o},this.calculateByTarget=function(e,t){var r=e.getClientRects()[0],n=r.left,a=r.top,i=r.right,o=r.bottom;return this.calculate(n,a,i,o,t)}}]),o.service("StringUtility",function(){this.uid=function(e,t){return e=e||"",t=t||"",""!==e&&(e+="-"),""!==t&&(t="."+t),e+Math.random().toString(36).substr(2).toUpperCase()+Math.random().toString(36).substr(2).toUpperCase()+t},this.uri=function(e,t){e=e||"";var r=e.toString().toLowerCase().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");if(""===r&&(r="-"),t(r))return r;if(r.indexOf("-")===-1&&(r+="-1",t(r)))return r;do{var n=r.lastIndexOf("-"),a=r.substr(0,n),i=r.substr(n+1);i.match(/^\d+$/)?(i=parseInt(i),i++,r=a+"-"+i):r+="-1"}while(t(r)===!1);return r}}),o.service("WebCalUtility",["$rootScope",function(e){this.allowDowngrade=function(e){return!e.startsWith("https://")},this.buildProxyURL=function(t){return e.baseUrl+"proxy?url="+encodeURIComponent(t)},this.downgradePossible=function(e,t){return e.startsWith("https://")&&t},this.downgradeURL=function(e){if(e.startsWith("https://"))return"http://"+e.substr(8)},this.fixURL=function(e){return e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("webcal://")?"https://"+e.substr(9):"https://"+e}}]);var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o.service("XMLUtility",function(){var e={};e.XMLify=function(t,r,n){var a=t.createElementNS(n.name[0],n.name[1]);if(n.attributes=n.attributes||[],n.attributes.forEach(function(e){2===e.length?a.setAttribute(e[0],e[1]):a.setAttributeNS(e[0],e[1],e[2])}),n.value)a.textContent=n.value;else if(n.children)for(var i in n.children)n.children.hasOwnProperty(i)&&e.XMLify(t,a,n.children[i]);r.appendChild(a)};var t=new XMLSerializer;this.getRootSkeleton=function(){if(0===arguments.length)return[{},null];var e={name:arguments[0],children:[]},t=e.children,r=Array.prototype.slice.call(arguments,1);return r.forEach(function(e){var r={name:e,children:[]};t.push(r),t=r.children}),[e,t]},this.serialize=function(r){if(r=r||{},"object"!==("undefined"==typeof r?"undefined":l(r))||!r.hasOwnProperty("name"))return"";var n=document.implementation.createDocument("","",null);return e.XMLify(n,n,r),t.serializeToString(n)}})}(angular,jQuery,oc_requesttoken); //# sourceMappingURL=app.min.js.map

georgehrke commented 7 years ago

@MisterCutely This fix was only about properly displaying an error message.

The actual 500 error has to be fixed in https://github.com/nextcloud/server That's why https://github.com/nextcloud/server/issues/4014 is still open ;)

MisterCutely commented 7 years ago

Oh sorry and thank you :-) The error message is vissible.